Advertisement
atm959

QB64 Platformer

Oct 21st, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 2.28 KB | None | 0 0
  1. OPTION BASE 0
  2. windowDisplay& = _NEWIMAGE(800, 600, 32) 'Set up the window screen
  3. SCREEN windowDisplay& 'Apply the window screen
  4. _TITLE "Platformer" 'Set the window title
  5.  
  6. DIM stp% 'Global timer
  7. DIM level%(64, 64) 'Tile IDs within the level
  8. DIM tiles&(128) 'Tile graphics
  9. DIM scrollX% 'Camera X position
  10. DIM scrollY% 'Camera Y position
  11. DIM tempFile$ 'Used for the tile loading routine
  12. DIM index% 'Used for the tile loading routine
  13.  
  14. index% = -1 'This is set to -1 because the routine changes it to 0 when it begins
  15.  
  16. CHDIR "Platformer/Tiles"
  17. RESTORE tilePaths
  18. DO 'Load all of the tile graphics
  19.     READ tempFile$
  20.     IF tempFile$ <> "0" THEN
  21.         index% = index% + 1
  22.         tiles&(index%) = _LOADIMAGE(tempFile$)
  23.     ELSE
  24.         GOTO Done
  25.     END IF
  26. LOOP
  27. Done:
  28.  
  29. CHDIR "../BGM"
  30. bgMusic& = _SNDOPEN("NormalTheme.wav") 'Load a music file into the long variable called "bgMusic&"
  31.  
  32. RESTORE LevelData
  33. FOR i = 0 TO 7
  34.     READ level%(0, i), level%(1, i), level%(2, i), level%(3, i), level%(4, i), level%(5, i), level%(6, i), level%(7, i)
  35. NEXT
  36.  
  37. _SNDLOOP bgMusic& 'Loop the music
  38.  
  39. WHILE 1 'Main game loop
  40.     CLS
  41.     stp% = stp% + 1
  42.     scrollX% = 80 * SIN(25 * stp% / 2)
  43.     scrollY% = 80 * COS(25 * stp% / 2)
  44.     FOR x% = 0 TO 63
  45.         FOR y% = 0 TO 63
  46.             _PUTIMAGE ((x% * 32) + scrollX%, (y% * 32) + scrollY%)-(((x% * 32) + scrollX%) + 31, ((y% * 32) + scrollY%) + 31), tiles&(level%(x%, y%))
  47.         NEXT
  48.     NEXT
  49.     PRINT "TIME: "; MID$(TIME$, 7, 2)
  50.     _DISPLAY 'Update the graphics
  51.     _LIMIT 60 'Limit to 60 FPS
  52. WEND
  53.  
  54. tilePaths: 'The paths for the tile graphics
  55. DATA "air.png"
  56. DATA "Grass/grassFloorLeftLedge.png"
  57. DATA "Grass/grassFloor.png"
  58. DATA "Grass/grassFloorRightLedge.png"
  59. DATA "Grass/grassLeftLedge.png"
  60. DATA "Grass/grassInside.png"
  61. DATA "Grass/grassRightLedge.png"
  62. DATA "Grass/grassCeilLeftLedge.png"
  63. DATA "Grass/grassCeil.png"
  64. DATA "Grass/grassCeilRightLedge.png"
  65. DATA "Grass/grassCornerTL.png"
  66. DATA "Grass/grassCornerTR.png"
  67. DATA "Grass/grassCornerBL.png"
  68. DATA "Grass/grassCornerBR.png"
  69. DATA "Grass/grassRampUpLeft.png"
  70. DATA "0"
  71.  
  72. LevelData: 'Test level data
  73. DATA 0,0,0,0,0,0,0,0
  74. DATA 0,0,0,0,0,0,0,14
  75. DATA 0,0,0,0,0,0,14,10
  76. DATA 0,0,0,1,2,2,10,0
  77. DATA 0,0,0,4,0,0,0,0
  78. DATA 0,0,0,4,0,0,0,0
  79. DATA 0,0,0,4,0,0,0,0
  80. DATA 2,2,2,10,0,0,0,0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement