Author Topic: Invaders bplus style  (Read 8503 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Invaders bplus style
« on: July 28, 2019, 11:19:27 am »
I love the play action in Ken's Invader series, so I have abstracted it in my own mod style for further development.

Here is b0_1:
Code: QB64: [Select]
  1. _TITLE "Invaders b0_1" 'Bplus started 2019-07-27 inspired by Ken's fun program series at QB64 Forum
  2.  
  3. CONST xmax = 1200, ymax = 720, PI = 3.141592653589793, PD2 = 1.570796326794897, PT2 = 6.283185307
  4. SCREEN _NEWIMAGE(xmax, ymax, 32)
  5. _SCREENMOVE 100, 20
  6.  
  7. TYPE typeO
  8.     x AS SINGLE
  9.     y AS SINGLE
  10.     xc AS SINGLE
  11.     yc AS SINGLE
  12.     dx AS SINGLE
  13.     dy AS SINGLE
  14.     a AS SINGLE
  15.     v1 AS SINGLE
  16.     v2 AS SINGLE
  17.     size AS SINGLE
  18.     live AS INTEGER
  19.     exploding AS INTEGER
  20.     lastShot AS SINGLE
  21.     c AS _UNSIGNED LONG
  22.  
  23. DIM SHARED o(100) AS typeO, shoot AS INTEGER
  24. DIM i AS INTEGER, j AS INTEGER, kh AS LONG, red
  25. setUp
  26. WHILE o(0).live
  27.     LINE (0, 0)-(xmax, ymax), _RGBA(0, 0, 0, 10), BF
  28.     kh = _KEYHIT
  29.     IF kh = 32 THEN shoot = -1
  30.     IF kh = 18432 THEN o(0).dx = 0
  31.     IF kh = 19200 THEN o(0).dx = -3
  32.     IF kh = 19712 THEN o(0).dx = 3
  33.     _TITLE "Cat's lives: " + STR$(o(0).live)
  34.     FOR i = 0 TO 100
  35.         IF o(i).live <> 0 THEN 'draw everything, update positions, check updated position
  36.             IF i = 0 THEN 'shooter
  37.                 IF o(0).exploding = 0 THEN
  38.                     drawshooter o(i).x
  39.                     IF shoot AND (TIMER(.001) - o(0).lastShot) > .2 THEN
  40.                         newBullet 0, o(0).x, ymax - 60
  41.                     END IF
  42.                     IF o(i).x + o(i).dx > 0 AND o(i).x + o(i).dx < xmax THEN
  43.                         o(i).x = o(i).x + o(i).dx
  44.                     ELSE
  45.                         o(i).dx = -o(i).dx
  46.                     END IF
  47.                 ELSEIF o(i).exploding > 0 THEN
  48.                     o(0).exploding = o(0).exploding - 1
  49.                     IF o(0).exploding = 0 THEN 'exploded enough
  50.                         o(0).live = o(0).live - 1
  51.                         drawshooter o(i).x
  52.                         IF o(0).live = 0 THEN EXIT FOR
  53.                     ELSE
  54.                         red = rand(60, 255)
  55.                         fcirc o(0).x, ymax - 75, o(0).exploding * 6, _RGB32(red, rand(0, red), 0)
  56.                     END IF
  57.                 END IF
  58.             ELSEIF i > 0 AND i < 4 THEN 'enemy ships
  59.                 'from celtic knot model
  60.                 'xReturn = xc + r * (COS(a) + COS(5 * a) / 1.6 + SIN(2 * a) / 3)
  61.                 'yReturn = yc + r * (SIN(a) + SIN(5 * a) / 1.6 + COS(2 * a) / 3)
  62.                 IF o(i).exploding = 0 THEN
  63.                     o(i).x = o(i).xc + 150 * (COS(o(i).a) + COS(o(i).v1 * o(i).a) / 2 + SIN(o(i).v2 * o(i).a) / 3)
  64.                     o(i).y = o(i).yc + 150 * (SIN(o(i).a) + SIN(o(i).v1 * o(i).a) / 2 + COS(o(i).v2 * o(i).a) / 3)
  65.                     fcirc o(i).x, o(i).y, o(i).size, o(i).c
  66.                     o(i).a = o(i).a + PI / 1440
  67.                     IF o(i).xc + o(i).dx > 0 AND o(i).xc + o(i).dx < xmax THEN
  68.                         o(i).xc = o(i).xc + o(i).dx
  69.                     ELSE
  70.                         o(i).dx = -o(i).dx
  71.                     END IF
  72.                     'drop bombs
  73.                     IF TIMER(.001) - o(i).lastShot > 3 THEN
  74.                         newBullet i, o(i).x, o(i).y + o(i).size
  75.                     END IF
  76.                 ELSEIF o(i).exploding > 0 THEN
  77.                     o(i).exploding = o(i).exploding - 1
  78.                     IF o(i).exploding = 0 THEN
  79.                         newEnemy i
  80.                     ELSE
  81.                         red = rand(60, 255)
  82.                         fcirc o(i).x, o(i).y, o(i).exploding * 3, _RGB32(red, rand(0, red), 0)
  83.                     END IF
  84.                 END IF
  85.             ELSEIF i > 3 AND i < 101 THEN 'bullets
  86.                 fcirc o(i).x, o(i).y, o(i).size, o(i).c
  87.                 IF o(i).x + o(i).dx > 0 AND o(i).x + o(i).dx < xmax THEN
  88.                     o(i).x = o(i).x + o(i).dx
  89.                 ELSE
  90.                     o(i).live = 0: o(i).x = -999: o(i).y = -999: o(i).dy = 0
  91.                 END IF
  92.                 IF o(i).y + o(i).dy > 0 AND o(i).y + o(i).dy < ymax THEN
  93.                     IF o(i).dy > 0 THEN o(i).dy = o(i).dy + .1 'gravity
  94.                     o(i).y = o(i).y + o(i).dy
  95.                 ELSE
  96.                     o(i).live = 0: o(i).x = -999: o(i).y = -999: o(i).dy = 0
  97.                 END IF
  98.                 'did this bullet hit anything
  99.                 IF o(i).dy > 0 THEN 'did it hit the shooter
  100.                     IF ((o(i).x - o(0).x) ^ 2 + (o(i).y - o(0).y) ^ 2) ^ .5 <= 50 THEN
  101.                         'explode shooter
  102.                         BEEP
  103.                         o(0).exploding = 20 'signal exploding
  104.                         o(i).live = 0: o(i).x = -999: o(i).y = -999: o(i).dy = 0
  105.                     END IF
  106.                 ELSEIF o(i).dy < 0 AND o(i).c = &HFFFFFFFF THEN 'did it hit the enemy?
  107.                     FOR j = 1 TO 3
  108.                         IF ((o(i).x - o(j).x) ^ 2 + (o(i).y - o(j).y) ^ 2) ^ .5 <= o(j).size + 2 THEN
  109.                             IF o(j).exploding = 0 THEN
  110.                                 o(j).exploding = 20
  111.                                 o(i).live = 0: o(i).x = -999: o(i).y = -999: o(i).dy = 0
  112.                             END IF
  113.                         END IF
  114.                     NEXT
  115.                 END IF 'bullet hit
  116.             END IF 'shooter
  117.         END IF 'live
  118.     NEXT
  119.     _DISPLAY
  120.     _LIMIT 60
  121.  
  122. SUB setUp
  123.     'obj 0 is the player's shooter
  124.     DIM i AS INTEGER
  125.     o(0).x = xmax / 2: o(0).y = ymax - 25
  126.     o(0).live = 9
  127.     FOR i = 1 TO 3 'enemy
  128.         newEnemy i
  129.     NEXT
  130.  
  131. SUB newEnemy (i)
  132.     IF i < 1 OR i > 3 THEN BEEP: EXIT SUB
  133.     o(i).a = RND * PT2: o(i).live = 1: o(i).v1 = rand(2, 19): o(i).v2 = rand(2, 19)
  134.     o(i).size = rand(10, 30): o(i).c = _RGB32(rand(128, 255), rand(0, 128), rand(0, 128))
  135.     o(i).yc = ymax / 2 - 30: o(i).lastShot = TIMER(.003) + .67 * i
  136.     IF RND < .5 THEN
  137.         o(i).xc = 0: o(i).dx = 1
  138.     ELSE
  139.         o(i).xc = xmax: o(i).dx = -1
  140.     END IF
  141.  
  142. SUB newBullet (who, x, y)
  143.     DIM ii AS INTEGER
  144.     FOR ii = 4 TO 100 'find bullet slot
  145.         IF o(ii).live = 0 THEN EXIT FOR 'got slot
  146.     NEXT
  147.     IF ii >= 4 AND ii <= 100 THEN
  148.         o(ii).x = x: o(ii).y = y: o(ii).size = 2: o(ii).live = -1: o(who).lastShot = TIMER(.001)
  149.         IF shoot AND who = 0 THEN
  150.             o(ii).dy = -10: o(ii).c = &HFFFFFFFF
  151.         ELSEIF who > 0 AND who < 4 THEN
  152.             o(ii).dy = 1: o(ii).c = &HFFFFFF00
  153.         END IF
  154.     END IF
  155.     shoot = 0
  156.  
  157. SUB drawshooter (x) 'simple red iso triangle pointed towards radianAngle
  158.     DIM y1, y2, x1, x2
  159.     'calculate 3 points of triangle shooter
  160.     y1 = ymax - 10
  161.     y2 = ymax - 60
  162.     x1 = x - 50
  163.     x2 = x + 50
  164.     fTri x, y1, x1, ymax, x, y2, _RGB(0, 0, 200)
  165.     fTri x, y1, x2, ymax, x, y2, _RGB(0, 0, 200)
  166.     ln x, y1, x1, ymax, _RGB32(255, 255, 128)
  167.     ln x1, ymax, x, y2, _RGB32(255, 255, 128)
  168.     ln x, y1, x2, ymax, _RGB32(255, 255, 128)
  169.     ln x2, ymax, x, y2, _RGB32(255, 255, 128)
  170.     ln x, y1, x, y2, _RGB32(255, 255, 128)
  171.  
  172. FUNCTION rand% (lo%, hi%)
  173.     rand% = INT(RND * (hi% - lo% + 1)) + lo%
  174.  
  175. ' found at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]:    http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14425.0
  176. SUB fTri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
  177.     DIM a&
  178.     a& = _NEWIMAGE(1, 1, 32)
  179.     _DEST a&
  180.     PSET (0, 0), K
  181.     _DEST 0
  182.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
  183.     _FREEIMAGE a& '<<< this is important!
  184.  
  185. SUB ln (x1, y1, x2, y2, K AS _UNSIGNED LONG) 'box frame
  186.     LINE (x1, y1)-(x2, y2), K
  187.  
  188. 'from Steve Gold standard
  189. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  190.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  191.     DIM X AS INTEGER, Y AS INTEGER
  192.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  193.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  194.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  195.     WHILE X > Y
  196.         RadiusError = RadiusError + Y * 2 + 1
  197.         IF RadiusError >= 0 THEN
  198.             IF X <> Y + 1 THEN
  199.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  200.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  201.             END IF
  202.             X = X - 1
  203.             RadiusError = RadiusError - X * 2
  204.         END IF
  205.         Y = Y + 1
  206.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  207.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  208.     WEND
  209.  
  210.  

Turn down the volume you are about to be BEEPed to death!

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Invaders bplus style
« Reply #1 on: July 28, 2019, 11:52:38 am »
Nice Job!
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Invaders bplus style
« Reply #2 on: July 28, 2019, 12:08:35 pm »
Pretty neat B+! Awesome graphics. Did you get my newest version that has particle explosions? I added that last night.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Invaders bplus style
« Reply #3 on: July 28, 2019, 12:51:00 pm »
Pretty neat B+! Awesome graphics. Did you get my newest version that has particle explosions? I added that last night.

Thanks guys,

Yes Ken, if you want, I can dig up some more spectacular exploding code, Bill did some too, way more particles per explosion! Fun stuff, explosions :D


Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Invaders bplus style
« Reply #4 on: July 28, 2019, 01:33:13 pm »
Thanks for the acid trip. I ran out of mine in the 60's.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Invaders bplus style
« Reply #5 on: July 28, 2019, 02:51:23 pm »
That's pretty my eyesight these days, specially after coding or Sudoku practice all evening.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Invaders bplus style
« Reply #6 on: July 28, 2019, 10:07:27 pm »
They're back...

Code: QB64: [Select]
  1. _TITLE "Invaders b0_2" 'Bplus started 2019-07-27 inspired by Ken's fun program series
  2.  
  3. CONST xmax = 1200, ymax = 720, PI = 3.141592653589793, PD2 = 1.570796326794897, PT2 = 6.283185307
  4. SCREEN _NEWIMAGE(xmax, ymax, 32)
  5. _SCREENMOVE 100, 20
  6.  
  7. TYPE typeO
  8.     x AS SINGLE
  9.     y AS SINGLE
  10.     xc AS SINGLE
  11.     yc AS SINGLE
  12.     dx AS SINGLE
  13.     dy AS SINGLE
  14.     a AS SINGLE
  15.     lastX AS SINGLE
  16.     lastY AS SINGLE
  17.     v1 AS SINGLE
  18.     v2 AS SINGLE
  19.     size AS SINGLE
  20.     live AS INTEGER
  21.     exploding AS INTEGER
  22.     lastShot AS SINGLE
  23.     c AS _UNSIGNED LONG
  24.  
  25. DIM SHARED o(100) AS typeO, shoot AS INTEGER, points
  26. DIM i AS INTEGER, j AS INTEGER, kh AS LONG, red, again$
  27.  
  28.     setUp
  29.     WHILE o(0).live
  30.         LINE (0, 0)-(xmax, ymax), _RGBA(0, 0, 0, 255), BF
  31.         kh = _KEYHIT
  32.         IF kh = 32 THEN shoot = -1
  33.         IF kh = 18432 THEN o(0).dx = 0
  34.         IF kh = 19200 THEN o(0).dx = -3
  35.         IF kh = 19712 THEN o(0).dx = 3
  36.  
  37.         cText xmax / 2, 30, 20, &HFF009900, "Cat's lives: " + STR$(o(0).live) + "   Cat's Points: " + STR$(points)
  38.         FOR i = 0 TO 100
  39.             IF o(i).live <> 0 THEN 'draw everything, update positions, check updated position
  40.                 IF i = 0 THEN 'shooter
  41.                     IF o(0).exploding = 0 THEN
  42.                         drawshooter o(i).x
  43.                         IF shoot AND (TIMER(.001) - o(0).lastShot) > .2 THEN
  44.                             newBullet 0, o(0).x, ymax - 60
  45.                         END IF
  46.                         IF o(i).x + o(i).dx > 0 AND o(i).x + o(i).dx < xmax THEN
  47.                             o(i).x = o(i).x + o(i).dx
  48.                         ELSE
  49.                             o(i).dx = -o(i).dx
  50.                         END IF
  51.                     ELSEIF o(i).exploding > 0 THEN
  52.                         o(0).exploding = o(0).exploding - 1
  53.                         IF o(0).exploding = 0 THEN 'exploded enough
  54.                             o(0).live = o(0).live - 1
  55.                             drawshooter o(i).x
  56.                             IF o(0).live = 0 THEN EXIT FOR
  57.                         ELSE
  58.                             red = rand(60, 255)
  59.                             fcirc o(0).x, ymax - 75, o(0).exploding * 6, _RGB32(red, rand(0, red), 0)
  60.                         END IF
  61.                     END IF
  62.                 ELSEIF i > 0 AND i < 4 THEN 'enemy ships
  63.                     'from celtic knot model
  64.                     'xReturn = xc + r * (COS(a) + COS(5 * a) / 1.6 + SIN(2 * a) / 3)
  65.                     'yReturn = yc + r * (SIN(a) + SIN(5 * a) / 1.6 + COS(2 * a) / 3)
  66.                     IF o(i).exploding = 0 THEN
  67.                         o(i).lastX = o(i).x: o(i).lastY = o(i).y
  68.                         o(i).x = o(i).xc + 150 * (COS(o(i).a) + COS(o(i).v1 * o(i).a) / 2 + SIN(o(i).v2 * o(i).a) / 3)
  69.                         o(i).y = o(i).yc + 150 * (SIN(o(i).a) + SIN(o(i).v1 * o(i).a) / 2 + COS(o(i).v2 * o(i).a) / 3)
  70.                         'fcirc o(i).x, o(i).y, o(i).size, o(i).c
  71.                         drawRat i
  72.                         o(i).a = o(i).a + PI / 1440
  73.                         IF o(i).xc + o(i).dx > 0 AND o(i).xc + o(i).dx < xmax THEN
  74.                             o(i).xc = o(i).xc + o(i).dx
  75.                         ELSE
  76.                             o(i).dx = -o(i).dx
  77.                         END IF
  78.                         'drop bombs
  79.                         IF TIMER(.001) - o(i).lastShot > 3 THEN
  80.                             newBullet i, o(i).x, o(i).y + o(i).size
  81.                         END IF
  82.                     ELSEIF o(i).exploding > 0 THEN
  83.                         o(i).exploding = o(i).exploding - 1
  84.                         IF o(i).exploding = 0 THEN
  85.                             newEnemy i
  86.                         ELSE
  87.                             red = rand(60, 255)
  88.                             fcirc o(i).x, o(i).y, o(i).exploding * 3, _RGB32(red, rand(0, red), 0)
  89.                         END IF
  90.                     END IF
  91.                 ELSEIF i > 3 AND i < 101 THEN 'bullets
  92.                     fcirc o(i).x, o(i).y, o(i).size, o(i).c
  93.                     IF o(i).x + o(i).dx > 0 AND o(i).x + o(i).dx < xmax THEN
  94.                         o(i).x = o(i).x + o(i).dx
  95.                     ELSE
  96.                         o(i).live = 0: o(i).x = -999: o(i).y = -999: o(i).dy = 0
  97.                     END IF
  98.                     IF o(i).y + o(i).dy > 0 AND o(i).y + o(i).dy < ymax THEN
  99.                         IF o(i).dy > 0 THEN o(i).dy = o(i).dy + .1 'gravity
  100.                         o(i).y = o(i).y + o(i).dy
  101.                     ELSE
  102.                         o(i).live = 0: o(i).x = -999: o(i).y = -999: o(i).dy = 0
  103.                     END IF
  104.                     'did this bullet hit anything
  105.                     IF o(i).dy > 0 THEN 'did it hit the shooter
  106.                         IF ((o(i).x - o(0).x) ^ 2 + (o(i).y - o(0).y) ^ 2) ^ .5 <= 50 THEN
  107.                             'explode shooter
  108.                             BEEP
  109.                             o(0).exploding = 20 'signal exploding
  110.                             o(i).live = 0: o(i).x = -999: o(i).y = -999: o(i).dy = 0
  111.                         END IF
  112.                     ELSEIF o(i).dy < 0 AND o(i).c = &HFFFFFFFF THEN 'did it hit the enemy?
  113.                         FOR j = 1 TO 3
  114.                             IF ((o(i).x - o(j).x) ^ 2 + (o(i).y - o(j).y) ^ 2) ^ .5 <= o(j).size + 2 THEN
  115.                                 IF o(j).exploding = 0 THEN
  116.                                     o(j).exploding = 20
  117.                                     points = points + 50 - o(j).size
  118.                                     o(i).live = 0: o(i).x = -999: o(i).y = -999: o(i).dy = 0
  119.                                 END IF
  120.                             END IF
  121.                         NEXT
  122.                     END IF 'bullet hit
  123.                 END IF 'shooter
  124.             END IF 'live
  125.         NEXT
  126.         _DISPLAY
  127.         _LIMIT 60
  128.     WEND
  129.     CLS: _DISPLAY: _DELAY 2.5: _KEYCLEAR ' stop hammer'n the keys!  ;-))
  130.     topTen points
  131.     _KEYCLEAR
  132.     PRINT: INPUT "Press enter to go again, any other, eg q, to quit "; again$
  133. LOOP UNTIL LEN(again$)
  134.  
  135. SUB setUp
  136.     'obj 0 is the player's shooter
  137.     DIM i AS INTEGER
  138.     ERASE o
  139.     points = 0
  140.     o(0).x = xmax / 2: o(0).y = ymax - 25
  141.     o(0).live = 9
  142.     FOR i = 1 TO 3 'enemy
  143.         newEnemy i
  144.     NEXT
  145.  
  146. SUB newEnemy (i)
  147.     DIM r, g, b
  148.     IF i < 1 OR i > 3 THEN BEEP: EXIT SUB
  149.     o(i).a = RND * PT2: o(i).live = 1: o(i).v1 = rand(2, 19): o(i).v2 = rand(2, 19)
  150.     r = rand(128, 255): g = rand(0, .5 * r): b = rand(0, .25 * r)
  151.     o(i).size = rand(10, 45): o(i).c = _RGB32(r, g, b)
  152.     o(i).yc = ymax / 2 - 30: o(i).lastShot = TIMER(.003) + .67 * i
  153.     IF RND < .5 THEN
  154.         o(i).xc = 0: o(i).dx = 1
  155.     ELSE
  156.         o(i).xc = xmax: o(i).dx = -1
  157.     END IF
  158.  
  159. SUB newBullet (who, x, y)
  160.     DIM ii AS INTEGER
  161.     FOR ii = 4 TO 100 'find bullet slot
  162.         IF o(ii).live = 0 THEN EXIT FOR 'got slot
  163.     NEXT
  164.     IF ii >= 4 AND ii <= 100 THEN
  165.         o(ii).x = x: o(ii).y = y: o(ii).size = 2: o(ii).live = -1: o(who).lastShot = TIMER(.001)
  166.         IF shoot AND who = 0 THEN
  167.             o(ii).dy = -10: o(ii).c = &HFFFFFFFF
  168.         ELSEIF who > 0 AND who < 4 THEN
  169.             o(ii).dy = 1: o(ii).c = &HFFFFFF00
  170.         END IF
  171.     END IF
  172.     shoot = 0
  173.  
  174. SUB drawRat (i)
  175.     DIM noseX, noseY, neckX, neckY, tailX, tailY, earLX, earLY, earRX, earRY, wX, wY, rh
  176.     rh = _ATAN2(o(i).y - o(i).lastY, o(i).x - o(i).lastX)
  177.     noseX = o(i).x + 2 * o(i).size * COS(rh)
  178.     noseY = o(i).y + 2 * o(i).size * SIN(rh)
  179.     neckX = o(i).x + .75 * o(i).size * COS(rh)
  180.     neckY = o(i).y + .75 * o(i).size * SIN(rh)
  181.     tailX = o(i).x + 2 * o(i).size * COS(rh + _PI)
  182.     tailY = o(i).y + 2 * o(i).size * SIN(rh + _PI)
  183.     earLX = o(i).x + o(i).size * COS(rh - _PI(1 / 12))
  184.     earLY = o(i).y + o(i).size * SIN(rh - _PI(1 / 12))
  185.     earRX = o(i).x + o(i).size * COS(rh + _PI(1 / 12))
  186.     earRY = o(i).y + o(i).size * SIN(rh + _PI(1 / 12))
  187.     fcirc o(i).x, o(i).y, .65 * o(i).size, o(i).c
  188.     fcirc neckX, neckY, o(i).size * .3, o(i).c
  189.     fTri noseX, noseY, earLX, earLY, earRX, earRY, o(i).c
  190.     fcirc earLX, earLY, o(i).size * .3, o(i).c
  191.     fcirc earRX, earRY, o(i).size * .3, o(i).c
  192.     wX = .5 * o(i).size * COS(rh - _PI(11 / 18))
  193.     wY = .5 * o(i).size * SIN(rh - _PI(11 / 18))
  194.     ln noseX + wX, noseY + wY, noseX - wX, noseY - wY, o(i).c
  195.     wX = .5 * o(i).size * COS(rh - _PI(7 / 18))
  196.     wY = .5 * o(i).size * SIN(rh - _PI(7 / 18))
  197.     ln noseX + wX, noseY + wY, noseX - wX, noseY - wY, o(i).c
  198.     ln o(i).x, o(i).y, tailX, tailY, o(i).c
  199.  
  200. SUB drawshooter (x) 'simple red iso triangle pointed towards radianAngle
  201.     DIM y1, y2, x1, x2
  202.     'calculate 3 points of triangle shooter
  203.     y1 = ymax - 10
  204.     y2 = ymax - 60
  205.     x1 = x - 50
  206.     x2 = x + 50
  207.     fTri x, y1, x1, ymax, x, y2, _RGB(0, 0, 200)
  208.     fTri x, y1, x2, ymax, x, y2, _RGB(0, 0, 200)
  209.     ln x, y1, x1, ymax, _RGB32(255, 255, 128)
  210.     ln x1, ymax, x, y2, _RGB32(255, 255, 128)
  211.     ln x, y1, x2, ymax, _RGB32(255, 255, 128)
  212.     ln x2, ymax, x, y2, _RGB32(255, 255, 128)
  213.     ln x, y1, x, y2, _RGB32(255, 255, 128)
  214.  
  215. SUB topTen (compareScore AS INTEGER)
  216.     DIM fName$, n, Names$(1 TO 10), scores(1 TO 10), name$, score AS INTEGER, settleScore, i
  217.  
  218.     fName$ = "Top 10 Scores.txt" '<<<  since this is toolbox code change this as needed for app
  219.     CLS: PRINT: PRINT "Top Ten Scorers and Scores:"
  220.     IF _FILEEXISTS(fName$) THEN
  221.         OPEN fName$ FOR INPUT AS #1
  222.         WHILE EOF(1) = 0 AND n < 10
  223.             n = n + 1
  224.             INPUT #1, name$
  225.             INPUT #1, score
  226.             IF compareScore >= score AND settleScore = 0 THEN
  227.                 PRINT "You have made the Top Ten!"
  228.                 INPUT "Type your name here: ", Names$(n)
  229.                 scores(n) = compareScore
  230.                 settleScore = -1
  231.                 n = n + 1
  232.                 IF n <= 10 THEN Names$(n) = name$: scores(n) = score
  233.             ELSE
  234.                 scores(n) = score: Names$(n) = name$
  235.             END IF
  236.         WEND
  237.         CLOSE #1
  238.         IF n < 10 AND settleScore = 0 THEN
  239.             PRINT "There is a slot open for your name and score."
  240.             INPUT "Type your name here: ", name$
  241.             IF name$ <> "" THEN n = n + 1: Names$(n) = name$: scores(n) = compareScore
  242.         END IF
  243.         OPEN fName$ FOR OUTPUT AS #1
  244.         FOR i = 1 TO n
  245.             PRINT #1, Names$(i): PRINT #1, scores(i)
  246.             PRINT i, Names$(i), scores(i)
  247.         NEXT
  248.         CLOSE #1
  249.         INPUT "That's the list, press Enter to continue... "; name$
  250.     ELSE
  251.         PRINT "You are first into file!"
  252.         INPUT "Type your name here:"; name$
  253.         OPEN fName$ FOR OUTPUT AS #1
  254.         PRINT #1, name$: PRINT #1, compareScore
  255.         CLOSE #1
  256.     END IF
  257.  
  258. 'center the text
  259. SUB cText (x, y, textHeight, K AS _UNSIGNED LONG, txt$)
  260.     DIM fg AS _UNSIGNED LONG, cur&, I&, mult, xlen
  261.     fg = _DEFAULTCOLOR
  262.     'screen snapshot
  263.     cur& = _DEST
  264.     I& = _NEWIMAGE(8 * LEN(txt$), 16, 32)
  265.     _DEST I&
  266.     COLOR K, _RGBA32(0, 0, 0, 0)
  267.     _PRINTSTRING (0, 0), txt$
  268.     mult = textHeight / 16
  269.     xlen = LEN(txt$) * 8 * mult
  270.     _PUTIMAGE (x - .5 * xlen, y - .5 * textHeight)-STEP(xlen, textHeight), I&, cur&
  271.     COLOR fg
  272.     _FREEIMAGE I&
  273.  
  274. FUNCTION rand% (lo%, hi%)
  275.     rand% = INT(RND * (hi% - lo% + 1)) + lo%
  276.  
  277. ' found at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]:    http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14425.0
  278. SUB fTri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
  279.     DIM a&
  280.     a& = _NEWIMAGE(1, 1, 32)
  281.     _DEST a&
  282.     PSET (0, 0), K
  283.     _DEST 0
  284.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
  285.     _FREEIMAGE a& '<<< this is important!
  286.  
  287. SUB ln (x1, y1, x2, y2, K AS _UNSIGNED LONG) 'box frame
  288.     LINE (x1, y1)-(x2, y2), K
  289.  
  290. 'from Steve Gold standard
  291. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  292.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  293.     DIM X AS INTEGER, Y AS INTEGER
  294.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  295.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  296.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  297.     WHILE X > Y
  298.         RadiusError = RadiusError + Y * 2 + 1
  299.         IF RadiusError >= 0 THEN
  300.             IF X <> Y + 1 THEN
  301.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  302.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  303.             END IF
  304.             X = X - 1
  305.             RadiusError = RadiusError - X * 2
  306.         END IF
  307.         Y = Y + 1
  308.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  309.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  310.     WEND
  311.  

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Invaders bplus style
« Reply #7 on: July 29, 2019, 01:44:43 am »
Ah, you decided to ratchet it up a bit. Well, I've had enough rat-chet for one day, thank you very much. Got to around 2000 pts, but after you type your name, it doesn't show you your final score or position.  Other than that, it functions great, except I swear I hit the little varmints at times and they don't explode. In fact, that makes it just like the arcade games of old. YOu'd swear you hit them, but nah, they just keep gunning for ya!

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Invaders bplus style
« Reply #8 on: July 29, 2019, 07:32:20 am »
Hi Bplus
fine RatInvaders!...

but why it seems that they fire from the bottom side of body? And why do they die if you hit their bottom side?
It is possible that they have a retro-problem (back-problem)  :-)

It was a joke,
thanks to share
Programming isn't difficult, only it's  consuming time and coffee

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Invaders bplus style
« Reply #9 on: July 29, 2019, 09:51:12 am »
Cool.... Maze refugees.... Nicely done!
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Invaders bplus style
« Reply #10 on: July 29, 2019, 10:50:48 am »
Ah, you decided to ratchet it up a bit. Well, I've had enough rat-chet for one day, thank you very much. Got to around 2000 pts, but after you type your name, it doesn't show you your final score or position.  Other than that, it functions great, except I swear I hit the little varmints at times and they don't explode. In fact, that makes it just like the arcade games of old. YOu'd swear you hit them, but nah, they just keep gunning for ya!

Pete

OK, I will fix the ending with big "Game Over" text message in middle and then freeze/delay before Top Ten review.

Sorry, I am so use to targeting the rat butts, I don't expect a hit to register anywhere else... the hits are based of main radius distance to center of butt, but I can increase... still, if you got to 2000 you are doing way better than I! My best score filling up Top Ten list was 1500+.

Hi Bplus
fine RatInvaders!...

but why it seems that they fire from the bottom side of body? And why do they die if you hit their bottom side?
It is possible that they have a retro-problem (back-problem)  :-)

It was a joke,
thanks to share

Joke, yeah, the rats eat nuclear waste and have deadly excrement! (Which also explains why they fly sideways!) I think you got it! :)

I guess I do have to increase Radius of a hit but do aim for their backsides.

Cool.... Maze refugees.... Nicely done!

LOL "Maze refugees" :)

Thanks all for your feed back, I will make edits to posted code.

« Last Edit: July 29, 2019, 10:53:47 am by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Invaders bplus style
« Reply #11 on: July 29, 2019, 01:17:09 pm »
LOL cool game! You can add some falling cheese to get a free shooter if you want. I thought about something like that myself, but starting with 5 shooters was plenty. :)

  ()()             ____
  (..)            /|o     |
  /\/\          /o|    o|
c\db/o...  /o_|_o_| 
« Last Edit: July 29, 2019, 01:18:22 pm by SierraKen »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Invaders bplus style
« Reply #12 on: July 29, 2019, 01:54:03 pm »
Hi Bplus

about
Quote
Joke, yeah, the rats eat nuclear waste and have deadly excrement! (Which also explains why they fly sideways!) I think you got it! :)
I find this your storyboard very cool!
Please don't enlarge the radius... it can be that SpaceMutantRats are they are imperforable and their back explodes by vibration done from collision between back and the missile.
What do you tink about it?
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Invaders bplus style
« Reply #13 on: July 29, 2019, 02:33:48 pm »
LOL cool game! You can add some falling cheese to get a free shooter if you want. I thought about something like that myself, but starting with 5 shooters was plenty. :)

  ()()             ____
  (..)            /|o     |
  /\/\          /o|    o|
c\db/o...  /o_|_o_|

Nice! Instead of Big Boss, I use Big Cheese! It just so happens I do have cheese making code. ;-))
(Some of have seen these rats before.) Actually I had an idea for a little surprise equivalent to a Boss break from the triple threats, sort of an opposite of Boss...

Hi Bplus

about I find this your storyboard very cool!
Please don't enlarge the radius... it can be that SpaceMutantRats are they are imperforable and their back explodes by vibration done from collision between back and the missile.
What do you tink about it?

Yes! as a matter of fact I tried increasing hit radius by a percentage of rat size and it sucked. The small ones still impossible to eRATicate compared to big ones which are so much easier. I decided to try just a flat 10 pixel space of grace because the shooters bullets move 10 pixels between frames and that is most likely cause of misses that shouldn't be.

Storyboard!?! hmm... well as far as explaining explosions because you hit there butts and nothing happens if you hit their heads, I say that's because all the explosive nuclear waste builds up in the bowels of their ships and the "heads" are just decoys to fool human shooters. ;-))

I am adding a 1 point charge for each bullet used and have begun tracking hit% per bullet, I think I might give bonus points at end of game for good %'s and deduct for machine gun Kelly's. I am also considering a hit rate by duration of game, to penalize that player who waits and waits for perfect kill shot. Ah! here is where a free shooter reward belongs!

What do you think?

You all should know I started this because I wanted to see bullets colliding with bullets and exploding. Have yet to get to that.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Invaders bplus style
« Reply #14 on: July 29, 2019, 02:42:31 pm »
Storyboard:  Aliens invade the world!

After intercepting our broadcast transmissions of Tom and Jerry shows, Aliens decide that mice are the dominant life-form upon our planet.  Though their ships are circular in design (as all good UFOs should be), they have a “mouse cloaking device” which produces a 3-dimensional hologram around the ship.  Attacking the head causes the bullet to pass harmlessly through the hologram, doing zero damage to the actual alien spaceship.  Only by targeting the rear of the hologram can actual damage be accrued to destroy the alien ship...
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!