Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. #include "FBGFX.BI"
  2. #include "STRING.BI"
  3. #include "BITMAP.BI"
  4. Using FB
  5.  
  6. Const As Double pi = 3.1415926
  7. Const As Integer false = 0, true = Not false
  8. Const As Integer w = 1400, h = 800, full_screen = false, show_fps = true
  9. Const As Double target_frame_rate = 60
  10.  
  11. Dim As Double frame_start, frame_length, game_timer, frames_per_second
  12. Dim As Integer frame_counter
  13.  
  14. Screenres w, h, 32, 2, full_screen
  15. Screenset 0,1
  16.  
  17. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  18. ' DECLARATIONS ... Add anything you need here :)
  19. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  20. Type Hat
  21. As Integer x,y,GID,Hat_Height
  22. End Type
  23.  
  24. Dim HatImages(1 To 3) As Bitmap
  25. HatImages(1) = LoadBitmap("res/Bowler.bmp")
  26. Dim Bowler As Hat
  27. Bowler.GID = 1
  28. Bowler.Hat_Height = 28
  29.  
  30. HatImages(2) = LoadBitmap("res/Fedora.bmp")
  31. Dim Fedora As Hat
  32. Fedora.GID = 2
  33. Fedora.Hat_Height = 41
  34.  
  35. Dim As Integer Row, Speed
  36. Row = h/10
  37. Speed = 1
  38.  
  39. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  40.  
  41. While Not Multikey(SC_ESCAPE)
  42.  
  43. frame_start = Timer()
  44. If frame_length > 0 Then
  45. game_timer += frame_length
  46. frames_per_second = 1/frame_length
  47. End If
  48.  
  49. Cls
  50.  
  51. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  52. ' INPUTS ... Anything the user can interact with
  53. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  54.  
  55. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  56. ' PROCESSES ... Where the 'thinking' takes place
  57. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  58. Scope
  59. Dim As Integer i
  60.  
  61. For i = 1 to 2
  62. If(Row < (h/10)*9) Then
  63. Speed += 1
  64. Row += Speed
  65. If Row > ((h/10)*9)- HatImages(i).Hat_Height Then
  66. Row = (h/10)*9 - HatImages(i).Hat_Height
  67. End If
  68. End If
  69. Next i
  70. End Scope
  71.  
  72. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  73. ' OUTPUTS ... Where everything is drawn
  74. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  75. DrawBitmap(w/3, Row, HatImages(Bowler.GID))
  76. DrawBitmap(w/7, Row, HatImages(Fedora.GID))
  77.  
  78.  
  79. ' - - - - - - - - - - - - - - - - - - - - - - - - - -
  80.  
  81. If show_fps Then
  82. Draw String (10,10), "FRAMES PER SECOND " + Format(frames_per_second, "0")
  83. Draw String (10,20), "FRAME LENGTH " + Format(frame_length*1000, "0.00") + "ms"
  84. Draw String (10,30), "GAME TIMER " + Format(game_timer, "0.00") + "s"
  85. Draw String (10,40), "GAME FRAMES " + Format(frame_counter, "0")
  86. End If
  87.  
  88. Screencopy 0,1
  89.  
  90. frame_counter += 1
  91. Do : frame_length = Timer() - frame_start
  92. Loop Until frame_length > 1/target_frame_rate
  93.  
  94. Wend
  95.  
  96. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement