Author Topic: Space Dodger in "Attack of the Giant Killer Space Hamsters!"  (Read 3116 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Space Dodger in "Attack of the Giant Killer Space Hamsters!"
« on: November 14, 2020, 04:03:37 pm »
A UniKorn ProDucKions original form 1998!
Space Dodger Eps 1, "Attack of the Giant Killer Space Hamsters!"

Converting this game from QB45 with DirectQB to QB64, A slow process but its coming along. Original background MIDI track has been lost to time so still playing with samples to use. Have not converted clear to the Boss yet, and a few other features that I just need to pull out of the DQB code. A lot of little tweaks that could use to be cleaned up to make it better. So a brief demo of the simple side scroll space shooter.

Arrow keys to move\speed up\down
Space Bar shoots

Current max score you can reach... 2^32.

Code: QB64: [Select]
  1. 'Space Dodger Eps 1: "Attack of the Giant Killer Space Hamsters!"
  2. 'UniKorn ProDucKions 2020
  3. 'Demo release
  4.  
  5. 'ToDo list:
  6. 'Adds:
  7. '-Title Screen
  8. '-Main Menu
  9. '-High Score list
  10. '-Boss Fight
  11. '-Better SFX
  12. '-Cleaned up Death Animation screen
  13. '-Game Over Screen
  14. '-Power Up drops
  15. '-Variable Hamster targets
  16.  
  17. TYPE SpriteLocation
  18.  X AS SINGLE ' Start X
  19.  Y AS SINGLE ' Start Y
  20.  Sx AS SINGLE 'End X
  21.  Sy AS SINGLE 'End Y
  22.  Ox AS INTEGER 'Offset X
  23.  Oy AS INTEGER 'Offset Y
  24.  
  25. TYPE PlayerData
  26.  Shield AS _BYTE
  27.  Score AS _UNSIGNED LONG
  28.  Lives AS _BYTE
  29.  SpeedX AS SINGLE
  30.  SpeedY AS SINGLE
  31.  WeaponPowerup AS _BYTE
  32.  ShieldPowerup AS _BYTE
  33.  
  34. TYPE stardata
  35.  colr AS _BYTE
  36.  speed AS SINGLE
  37.  
  38. TYPE Gamedata
  39.  CurrentShot AS _BYTE
  40.  PlayerDeath AS _BYTE
  41.  
  42. SCREEN _NEWIMAGE(640, 420, 32)
  43. DIM SHARED Layer(8) AS LONG, SFX(16) AS LONG, BGM(8) AS LONG
  44. DIM SHARED LED(9) AS SpriteLocation, ShipExplode(16) AS SpriteLocation
  45. DIM SHARED P AS PlayerData, G AS Gamedata, Stars(150) AS stardata, Shot(10) AS SpriteLocation
  46. DIM SHARED H(25) AS SpriteLocation
  47.  
  48. 'LED display sprite locations
  49. DATA 0,28,10,28,20,28,30,28,40,28,50,28,60,28,70,28,80,28,90,28
  50. 'Ship Explostion sprite locations
  51. DATA 0,160,107,221,0,0: '    0
  52. DATA 108,160,215,221,0,0: '  1
  53. DATA 216,160,323,221,0,0: '  2
  54. DATA 324,158,429,223,0,-2: ' 3
  55. DATA 432,148,533,229,0,-12: '4
  56. DATA 0,252,107,349,0,-20: '  5
  57. DATA 108,242,209,357,0,-30: '6
  58. DATA 216,238,317,365,0,-34: '7
  59. DATA 324,230,425,369,0,-42: '8
  60. DATA 432,236,539,363,0,-36: '9
  61. DATA 0,380,107,517,0,-40: '  10
  62. DATA 108,370,213,533,0,-46: '11
  63. DATA 214,370,319,533,14,-46: '12
  64. DATA 320,370,425,533,20,-46: '13
  65. DATA 442,372,529,529,12,-46: '14
  66. DATA 552,418,625,483,16,-46: '15
  67. DATA 652,372,739,533,20,-46: '16
  68.  
  69. FOR i%% = 0 TO 9 'load LED display sprite locations
  70.  READ LED(i%%).X, LED(i%%).Y
  71. FOR i%% = 0 TO 16
  72.  READ ShipExplode(i%%).X, ShipExplode(i%%).Y, ShipExplode(i%%).Sx, ShipExplode(i%%).Sy, ShipExplode(i%%).Ox, ShipExplode(i%%).Oy
  73. NEXT i%%
  74.  
  75. Layer(0) = _DISPLAY
  76. Layer(1) = _NEWIMAGE(640, 400, 32)
  77. Layer(4) = _NEWIMAGE(640, 400, 32) 'temp bgplate
  78. Layer(5) = _NEWIMAGE(640, 400, 32) 'Collision layer
  79.  
  80. MFI_Loader "SpaceDog.MFI"
  81.  
  82. _PUTIMAGE , Layer(3), Layer(4)
  83. _CLEARCOLOR _RGB32(0), Layer(2)
  84. _CLEARCOLOR _RGB32(0), Layer(4)
  85.  
  86.  
  87.  
  88. _SNDVOL SFX(0), .2
  89. _SNDVOL SFX(1), .2
  90. _SNDVOL SFX(2), .2
  91. _SNDVOL SFX(3), .2
  92. _SNDVOL SFX(4), .3
  93. _SNDVOL BGM(0), .25
  94.  
  95. CONST MaxStars = 55
  96. CONST TRUE = -1, FALSE = NOT TRUE
  97. CONST max = 7, min = 1, Stars = 50, Maxshotsfired = 3, MaxHamsters = 10
  98. CONST ShotSpeed = 5
  99.  
  100. P.Shield = 100
  101. P.Score = 0
  102. P.Lives = 3
  103. G.CurrentShot = -1
  104. G.PlayerDeath = 0
  105. FOR i% = 0 TO MaxStars
  106.  MakeNewStar i%
  107. NEXT i%
  108. FOR i%% = 0 TO MaxHamsters
  109.  MakeHamster i%%
  110. NEXT i%%
  111.  
  112. _SNDLOOP BGM(0)
  113.  
  114.  
  115. _SOURCE Layer(5)
  116. _DEST Layer(1)
  117.  ExitFlag%% = Controls
  118.  StarField
  119.  DisplayPlayer
  120.  IF G.CurrentShot >= 0 THEN Process_Shots: Displayshots
  121.  Process_Hamsters: Make_Collision_Layer_Hamsters: DisplayHamsters
  122.  
  123.  IF NOT G.PlayerDeath THEN
  124.   _PUTIMAGE , Layer(4), Layer(1)
  125.   DisplayExtraLives
  126.   DisplayShieldLevel
  127.   DisplayScore
  128.   DisplayEngineFlame
  129.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  130.   _LIMIT 60
  131.   LINE (0, 0)-STEP(639, 399), _RGB32(0), BF
  132.   _SNDVOL BGM(0), .01
  133.   _SNDSTOP SFX(1)
  134.   _SNDSTOP SFX(2)
  135.   _SNDPLAY SFX(3)
  136.   ExplodePlayer
  137.   FOR i%% = 0 TO MaxHamsters
  138.    MakeHamster i%%
  139.   NEXT i%%
  140.   P.Shield = 100
  141.   P.Lives = P.Lives - 1
  142.   IF P.Lives = -1 THEN ExitFlag%% = TRUE
  143.   _SNDVOL BGM(0), .3
  144.   G.PlayerDeath = FALSE
  145.   IF P.Lives = 0 THEN ExitFlag%% = TRUE
  146.  _PRINTSTRING (0, 400), STR$(G.CurrentShot), Layer(0)
  147. LOOP UNTIL ExitFlag%%
  148. _DEST Layer(0)
  149. _SOURCE Layer(0)
  150.  
  151. _SNDSTOP BGM(0)
  152. _PUTIMAGE , Layer(4), Layer(1)
  153. DisplayExtraLives
  154. DisplayScore
  155. _PUTIMAGE (0, 0), Layer(1), Layer(0)
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. FUNCTION Controls%% ()
  164.  STATIC SlowFlag%%, CoastFlag%%, KeyLocked%% ', BombLock%%
  165.  Result%% = FALSE
  166.  
  167.   IF NOT KeyLocked%% THEN
  168.    IF G.CurrentShot < Maxshotsfired THEN
  169.     _SNDPLAY SFX(0)
  170.     G.CurrentShot = G.CurrentShot + 1
  171.     Makeshot G.CurrentShot
  172.    END IF
  173.    KeyLocked%% = TRUE
  174.   END IF
  175.   KeyLocked%% = FALSE
  176.  
  177.  IF _KEYDOWN(27) THEN Result%% = TRUE
  178.  '20480
  179.  IF _KEYDOWN(20480) THEN P.SpeedY = P.SpeedY + .25: CoastFlag%% = FALSE
  180.  IF P.SpeedY >= 5 THEN P.SpeedY = 5
  181.  
  182.  IF _KEYDOWN(19200) THEN P.SpeedX = P.SpeedX - .25: IF P.SpeedX > 1 THEN SlowFlag%% = FALSE
  183.  IF P.SpeedX < .5 THEN P.SpeedX = .5
  184.  IF _KEYDOWN(19712) THEN P.SpeedX = P.SpeedX + .25: SlowFlag%% = FALSE
  185.  IF P.SpeedX > max THEN P.SpeedX = max
  186.  
  187.  IF _KEYDOWN(18432) THEN P.SpeedY = P.SpeedY - .25: CoastFlag%% = FALSE
  188.  IF P.SpeedY <= -5 THEN P.SpeedY = -5
  189.  
  190.  IF NOT SlowFlag%% THEN
  191.   IF NOT _KEYDOWN(19712) THEN
  192.    P.SpeedX = P.SpeedX - .05: IF P.SpeedX < min THEN P.SpeedX = min: SlowFlag%% = TRUE
  193.   END IF
  194.  
  195.  IF NOT CoastFlag%% THEN 'allow coast up and down
  196.   IF NOT _KEYDOWN(18432) AND NOT _KEYDOWN(20480) THEN
  197.    IF P.SpeedY > 0 THEN
  198.     P.SpeedY = P.SpeedY - .05
  199.     IF P.SpeedY <= .2 THEN CoastFlag%% = TRUE: P.SpeedY = 0
  200.    ELSE
  201.     P.SpeedY = P.SpeedY + .05
  202.     IF P.SpeedY >= -.2 THEN CoastFlag%% = TRUE: P.SpeedY = 0
  203.    END IF
  204.   END IF
  205.  
  206.  
  207.  Controls = Result%%
  208.  
  209. FUNCTION Hamster_Collision%% (id%%)
  210.  '((x-h)/a)^2 + ((y-k)/b)^2 <= 1
  211.  'H,K -center x,y
  212.  'x,y -hamster point to check
  213.  'a,b Radius X, radius Y
  214.  
  215.  Result%% = 0
  216.  hit%% = 0
  217.  'hamster size 48x28, check 8 points
  218.  'hit%% = _RED32(POINT(H(id%%).X + 0, H(id%%).Y)) 'check for hit box
  219.  'IF hit%% THEN hit%% = _RED32(POINT(H(id%%).X + 0, H(id%%).Y + 7)) 'check for hit box
  220.  'IF hit%% THEN hit%% = _RED32(POINT(H(id%%).X + 0, H(id%%).Y + 14)) 'check for hit box
  221.  'IF hit%% THEN hit%% = _RED32(POINT(H(id%%).X + 10, H(id%%).Y + 21)) 'check for hit box
  222.  'IF hit%% THEN hit%% = _RED32(POINT(H(id%%).X + 10, H(id%%).Y + 28)) 'check for hit box
  223.  'IF hit%% THEN hit%% = _RED32(POINT(H(id%%).X + 48, H(id%%).Y)) 'check for hit box
  224.  'IF hit%% THEN hit%% = _RED32(POINT(H(id%%).X + 48, H(id%%).Y + 14)) 'check for hit box
  225.  'IF hit%% THEN hit%% = _RED32(POINT(H(id%%).X + 48, H(id%%).Y + 28)) 'check for hit box
  226.  ' test~& = POINT(H(id%%).X + 0, H(id%%).Y)
  227.  ' _PRINTSTRING (16, 16 + 16 * id%%), STR$(_RED32(test~&)), Layer(1)
  228.  ' _PRINTSTRING (0, 220 + 16 * id%%), STR$(H(id%%).X + 0) + STR$(H(id%%).Y), Layer(1)
  229.  'IF hit%% = 1 THEN Result%% = hit%%
  230.  IF (((H(id%%).X + 24) - 113) / 53) ^ 2 + (((H(id%%).Y + 14) - 200) / 30) ^ 2 <= 1 THEN Result%% = TRUE
  231.  Hamster_Collision = Result%%
  232.  
  233.  
  234. FUNCTION Shot_Collision%% (id%%)
  235.  Result%% = -1
  236.  hit%% = 0
  237.  'shot size 16x10, check 6 points
  238.  hit%% = _RED32(POINT(Shot(id%%).X + 16, Shot(id%%).Y)) 'check for hit box
  239.  IF hit%% < 10 THEN hit%% = _RED32(POINT(Shot(id%%).X + 16, Shot(id%%).Y + 5)) 'check for hit box
  240.  IF hit%% < 10 THEN hit%% = _RED32(POINT(Shot(id%%).X + 16, Shot(id%%).Y + 10)) 'check for hit box
  241.  IF hit%% < 10 THEN hit%% = _RED32(POINT(Shot(id%%).X + 12, Shot(id%%).Y)) 'check for hit box
  242.  IF hit%% < 10 THEN hit%% = _RED32(POINT(Shot(id%%).X + 12, Shot(id%%).Y + 5)) 'check for hit box
  243.  IF hit%% < 10 THEN hit%% = _RED32(POINT(Shot(id%%).X + 12, Shot(id%%).Y + 10)) 'check for hit box
  244.  IF hit%% >= 10 THEN Result%% = hit%% - 10 'which hamster was hit?
  245.  
  246.  Shot_Collision = Result%%
  247.  
  248.  
  249. SUB DisplayEngineFlame
  250.  STATIC frame%%
  251.  IF P.SpeedX < .75 THEN
  252.   SELECT CASE frame%%
  253.    CASE 0
  254.     _PUTIMAGE (40, 189), Layer(2), Layer(1), (0, 126)-STEP(19, 24)
  255.    CASE 1
  256.     _PUTIMAGE (42, 189), Layer(2), Layer(1), (20, 126)-STEP(17, 24)
  257.    CASE 2
  258.     _PUTIMAGE (46, 189), Layer(2), Layer(1), (38, 126)-STEP(13, 24)
  259.   SELECT CASE frame%%
  260.    CASE 0
  261.     _PUTIMAGE (15 - P.SpeedX, 190)-STEP(44 + P.SpeedX, 21), Layer(2), Layer(1), (0, 104)-STEP(52, 21)
  262.    CASE 1
  263.     _PUTIMAGE (15 - P.SpeedX, 190)-STEP(44 + P.SpeedX, 21), Layer(2), Layer(1), (54, 104)-STEP(52, 21)
  264.    CASE 2
  265.     _PUTIMAGE (15 - P.SpeedX, 190)-STEP(44 + P.SpeedX, 21), Layer(2), Layer(1), (108, 104)-STEP(52, 21)
  266.    CASE 3
  267.     _PUTIMAGE (15 - P.SpeedX, 211)-STEP(44 + P.SpeedX, -21), Layer(2), Layer(1), (0, 104)-STEP(52, 21)
  268.    CASE 4
  269.     _PUTIMAGE (15 - P.SpeedX, 211)-STEP(44 + P.SpeedX, -21), Layer(2), Layer(1), (54, 104)-STEP(52, 21)
  270.    CASE 5
  271.     _PUTIMAGE (15 - P.SpeedX, 211)-STEP(44 + P.SpeedX, -21), Layer(2), Layer(1), (108, 104)-STEP(52, 21)
  272.  frame%% = INT(RND * 6)
  273.  
  274. SUB DisplayLED (X%, Y%, D%)
  275.  _PUTIMAGE (X%, Y%)-STEP(7, 13), Layer(2), Layer(1), (LED(D%).X, LED(D%).Y)-STEP(7, 13)
  276.  
  277. SUB DisplayPlayer
  278.  _PUTIMAGE (60, 170), Layer(2), Layer(1), (0, 42)-STEP(106, 60)
  279.  _PUTIMAGE (60, 170), Layer(2), Layer(5), (124, 42)-STEP(106, 60) 'collision shadow
  280.  
  281. SUB DisplayShieldLevel
  282.  Shld$ = LTRIM$(STR$(P.Shield))
  283.  FOR I%% = 1 TO LEN(Shld$)
  284.   DisplayLED 444 - (LEN(Shld$) * 10) + 10 * I%%, 382, VAL(MID$(Shld$, I%%, 1))
  285.  NEXT I%%
  286.  
  287. SUB DisplayScore
  288.  Score$ = LTRIM$(STR$(P.Score))
  289.  FOR I%% = 1 TO LEN(Score$)
  290.   DisplayLED 614 - (LEN(Score$) * 10) + 10 * I%%, 382, VAL(MID$(Score$, I%%, 1))
  291.  NEXT I%%
  292.  
  293. SUB DisplayExtraLives
  294.  _PUTIMAGE (322, 381)-STEP(23, 15), Layer(2), Layer(1), (0, 42)-STEP(106, 60)
  295.  DisplayLED 348, 382, P.Lives
  296.  
  297. SUB Displayshots
  298.  FOR i%% = 0 TO G.CurrentShot
  299.   _PUTIMAGE (Shot(i%%).X, Shot(i%%).Y), Layer(2), Layer(1), (108, 68)-STEP(15, 9)
  300.  NEXT i%%
  301.  
  302. SUB DisplayHamsters
  303.  FOR i%% = 0 TO MaxHamsters
  304.   IF NOT H(i%%).Ox THEN 'check flag for hamster death
  305.    _PUTIMAGE (H(i%%).X, H(i%%).Y), Layer(2), Layer(1), (0, 0)-STEP(47, 27)
  306.   ELSE 'this hamster is dead
  307.    IF H(i%%).Oy < 80 THEN
  308.     _PUTIMAGE (H(i%%).X, H(i%%).Y), Layer(2), Layer(1), (0 + 48 * (H(i%%).Oy \ 10), 0)-STEP(47, 27)
  309.    ELSE
  310.     _PUTIMAGE (H(i%%).X + INT(RND * 8) - 4, H(i%%).Y + INT(RND * 8) - 4), Layer(2), Layer(1), (0 + 48 * 7, 0)-STEP(47, 27)
  311.    END IF
  312.   END IF
  313.  NEXT i%%
  314.  
  315. SUB Make_Collision_Layer_Hamsters
  316.  _DEST Layer(5) 'collision check layer
  317.  LINE (0, 0)-STEP(639, 399), _RGB32(0), BF 'clear collision layer
  318.  FOR i%% = 0 TO MaxHamsters
  319.   'only draw collision box of live hamsters
  320.   IF NOT H(i%%).Ox THEN LINE (H(i%%).X, H(i%%).Y)-STEP(47, 27), _RGB32(10 + i%%, 0, 0), BF 'collision box
  321.  NEXT i%%
  322.  _DEST Layer(1) 'back to mix layer
  323.  
  324. SUB ExplodePlayer
  325.  FOR i%% = 0 TO 16
  326.   LINE (0, 0)-STEP(639, 399), _RGB32(0), BF
  327.   _PUTIMAGE (0, 0), Layer(4), Layer(1)
  328.   _PUTIMAGE (50 + ShipExplode(i%%).Ox + i%% * 10, 160 + ShipExplode(i%%).Oy), Layer(2), Layer(1), (ShipExplode(i%%).X, ShipExplode(i%%).Y)-(ShipExplode(i%%).Sx, ShipExplode(i%%).Sy)
  329.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  330.   _DELAY .35
  331.   IF INKEY$ = CHR$(27) THEN END
  332.  NEXT i%%
  333.  LINE (0, 0)-STEP(639, 399), _RGB32(0), BF
  334.  DO: _DELAY .01: LOOP WHILE _SNDPLAYING(SFX(3))
  335.  _SNDPLAY SFX(4)
  336.  FOR i% = 0 TO 320 STEP 5
  337.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  338.   _PUTIMAGE (50 + ShipExplode(16).Ox + 160, 160 + ShipExplode(16).Oy + i%), Layer(2), Layer(0), (ShipExplode(16).X, ShipExplode(16).Y)-(ShipExplode(16).Sx, ShipExplode(16).Sy)
  339.   _PUTIMAGE (0, 0), Layer(4), Layer(0)
  340.   _DELAY .1
  341.   IF INKEY$ = CHR$(27) THEN END
  342.  NEXT i%
  343.  P.SpeedX = 1: P.SpeedY = 0
  344.  
  345. SUB Process_Hamsters
  346.  FOR i%% = 0 TO MaxHamsters
  347.   H(i%%).X = H(i%%).X - H(i%%).Sx - P.SpeedX 'move hamsters
  348.   H(i%%).Y = H(i%%).Y - P.SpeedY
  349.  
  350.   IF Hamster_Collision(i%%) AND NOT H(i%%).Ox THEN 'does hamster hit player?
  351.    '   _DEST Layer(0)
  352.    _SNDPLAY SFX(1) 'impact
  353.    _SNDPLAY SFX(2) 'ouch
  354.    MakeHamster (i%%) 'replace hamster
  355.    P.Shield = P.Shield - 10 'damage shields
  356.    IF P.Shield = 0 THEN G.PlayerDeath = TRUE 'does player's ship explode?
  357.   END IF
  358.  
  359.   IF H(i%%).X < -48 THEN MakeHamster (i%%) 'hamster off screen
  360.   IF H(i%%).Y < -64 THEN 'transport hamster to other side of screen, to prevent sneeky way to HIGH score.
  361.    IF H(i%%).Ox THEN 'do not continue exploding hamster off screen
  362.     MakeHamster (i%%)
  363.    ELSE
  364.     H(i%%).Y = 440
  365.    END IF
  366.   END IF
  367.   IF H(i%%).Y > 464 THEN 'transport hamster to other side of screen, to prevent sneeky way to HIGH score.
  368.    IF H(i%%).Ox THEN 'do not continue exploding hamster off screen
  369.     MakeHamster (i%%)
  370.    ELSE
  371.     H(i%%).Y = -40
  372.    END IF
  373.   END IF
  374.  
  375.   IF H(i%%).Ox THEN 'has hamster been hit?
  376.    IF H(i%%).Oy = 120 THEN MakeHamster (i%%)
  377.    H(i%%).Oy = H(i%%).Oy + 1
  378.   END IF
  379.  NEXT i%%
  380.  
  381. SUB Process_Shots
  382.  FOR i%% = 0 TO G.CurrentShot
  383.   Shot(i%%).X = Shot(i%%).X + ShotSpeed + Shot(i%%).Sx
  384.   Shot(i%%).Y = Shot(i%%).Y - P.SpeedY / 2
  385.   IF Shot(i%%).X > 635 THEN 'drop shot
  386.    FOR j%% = i%% TO G.CurrentShot + 1
  387.     SWAP Shot(j%%), Shot(j%% + 1)
  388.    NEXT j%%
  389.    Shot(j%%).X = 0: Shot(j%%).Y = 0 'erase shot
  390.    Shot(j%%).Sx = 0: Shot(j%%).Sy = 0 'erase shot
  391.    G.CurrentShot = G.CurrentShot - 1 'reduce shot count
  392.   END IF
  393.   Check_hit%% = Shot_Collision(i%%)
  394.   IF Check_hit%% >= 0 THEN 'hamster has been shot
  395.    P.Score = P.Score + 25 * P.SpeedX
  396.  
  397.    H(Check_hit%%).Ox = TRUE 'set hamster death animation
  398.    H(Check_hit%%).Sx = 0
  399.    H(Check_hit%%).Oy = 0
  400.    FOR j%% = i%% TO G.CurrentShot + 1 'drop shot
  401.     SWAP Shot(j%%), Shot(j%% + 1)
  402.    NEXT j%%
  403.    Shot(j%%).X = 0: Shot(j%%).Y = 0 'erase shot
  404.    Shot(j%%).Sx = 0: Shot(j%%).Sy = 0 'erase shot
  405.    G.CurrentShot = G.CurrentShot - 1 'reduce shot count
  406.   END IF
  407.  NEXT i%%
  408.  
  409. FUNCTION FNR% (x%)
  410.  Result% = INT(RND * x%) + 1
  411.  FNR = Result%
  412.  
  413. SUB MakeNewStar (ID%)
  414.  Stars(ID%).x = FNR(639)
  415.  Stars(ID%).y = FNR(399)
  416.  Stars(ID%).colr = FNR(3) - 1
  417.  Stars(ID%).speed = FNR(INT(Stars(ID%).colr) / 10)
  418.  
  419. SUB Makeshot (ID%%)
  420.  Shot(ID%%).X = 145
  421.  Shot(ID%%).Y = 196
  422.  Shot(ID%%).Sx = P.SpeedX
  423.  Shot(ID%%).Sy = P.SpeedY
  424.  
  425. SUB MakeHamster (id%%)
  426.  H(id%%).X = 640 + FNR(92)
  427.  H(id%%).Y = FNR(480) - 40
  428.  H(id%%).Sx = FNR(3) 'hamster self speed
  429.  H(id%%).Ox = FALSE 'been shot flag
  430.  H(id%%).Oy = FALSE 'been shot animation frame
  431.  
  432. SUB StarField
  433.  FOR i% = 0 TO MaxStars
  434.   _PUTIMAGE (Stars(i%).x, Stars(i%).y), Layer(2), Layer(1), (100 + 6 * Stars(i%).colr, 28)-STEP(5, 5)
  435.  
  436.   Stars(i%).x = Stars(i%).x - Stars(i%).speed - P.SpeedX - ((8 - (Stars(i%).colr * 2)) / 10)
  437.   IF P.SpeedY THEN Stars(i%).y = Stars(i%).y + P.SpeedY
  438.  
  439.   IF Stars(i%).x <= 1 THEN
  440.    MakeNewStar i%
  441.    Stars(i%).x = 639
  442.   END IF
  443.   IF Stars(i%).x >= 640 THEN
  444.    MakeNewStar i%
  445.    Stars(i%).x = 2
  446.   END IF
  447.   IF Stars(i%).y <= 1 THEN
  448.    MakeNewStar i%
  449.    Stars(i%).y = 399
  450.   END IF
  451.   IF Stars(i%).y >= 400 THEN
  452.    MakeNewStar i%
  453.    Stars(i%).y = 2
  454.   END IF
  455.  NEXT i%
  456.  
  457. SUB MFI_Loader (FN$)
  458.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  459.  GET #1, , c~%% 'retrieve number of files
  460.  FOR I~%% = 1 TO c~%%
  461.   GET #1, , FOffset(I~%%)
  462.   GET #1, , Size(I~%%)
  463.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  464.  NEXT I~%%
  465.  
  466.  'Layer(2) = _LOADIMAGE("SpaceDodgerSpriteSheet.bmp", 32)
  467.  'Layer(3) = _LOADIMAGE("BGPlate.bmp", 32)
  468.  'SFX(0) = _SNDOPEN("gunshot.ogg")
  469.  'SFX(1) = _SNDOPEN("impactquick.ogg")
  470.  'SFX(2) = _SNDOPEN("ouch.ogg")
  471.  'SFX(3) = _SNDOPEN("PdiesMSTR.ogg")
  472.  'SFX(4) = _SNDOPEN("sqeek.ogg")
  473.  'BGM(0) = _SNDOPEN("BGM_Alt_LO.ogg")
  474.  
  475.  
  476.  Layer(2) = LoadGFX(FOffset(2), Size(2))
  477.  Layer(3) = LoadGFX(FOffset(1), Size(1))
  478.  
  479.  SFX(0) = LoadSFX(FOffset(7), Size(7))
  480.  SFX(1) = LoadSFX(FOffset(3), Size(3))
  481.  SFX(2) = LoadSFX(FOffset(6), Size(6))
  482.  SFX(3) = LoadSFX(FOffset(5), Size(5))
  483.  SFX(4) = LoadSFX(FOffset(4), Size(4))
  484.  
  485.  BGM(0) = LoadSFX(FOffset(8), Size(8))
  486.  CLOSE #1
  487.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  488.  
  489. FUNCTION LoadGFX& (Foff&, Size&)
  490.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  491.  OPEN "temp.dat" FOR BINARY AS #3
  492.  dat$ = SPACE$(Size&)
  493.  GET #1, Foff&, dat$
  494.  PUT #3, , dat$
  495.  CLOSE #3
  496.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  497.  
  498. FUNCTION LoadFFX& (Foff&, Size&, Fize%%)
  499.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  500.  OPEN "temp.dat" FOR BINARY AS #3
  501.  dat$ = SPACE$(Size&)
  502.  GET #1, Foff&, dat$
  503.  PUT #3, , dat$
  504.  CLOSE #3
  505.  LoadFFX& = _LOADFONT("temp.dat", Fize%%, "monospace")
  506.  
  507. FUNCTION LoadSFX& (Foff&, Size&)
  508.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  509.  OPEN "temp.dat" FOR BINARY AS #3
  510.  dat$ = SPACE$(Size&)
  511.  GET #1, Foff&, dat$
  512.  PUT #3, , dat$
  513.  CLOSE #3
  514.  LoadSFX& = _SNDOPEN("temp.dat")
  515.  
* SpaceDog.MFI (Filesize: 693.58 KB, Downloads: 174)
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Space Dodger in "Attack of the Giant Killer Space Hamsters!"
« Reply #1 on: November 14, 2020, 04:34:05 pm »
Whoa, that's some cool parallax effect, Cobalt!