Guest User

Untitled

a guest
Jan 25th, 2013
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Graphics 1000,700,0,2
  2. SetBuffer BackBuffer()
  3.  
  4. Global mapsx = 20
  5. Global mapsy = 14
  6.  
  7. Dim array(mapsx,mapsy)
  8.  
  9. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  10. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  11. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  12. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  13. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  14. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  15. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  16. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  17. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  18. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  19. Data 0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0
  20. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0
  21. Data 0,1,0,0,0,1,0,0,0,0,1,1,0,1,0,0,0,1,0,0
  22. Data 1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1
  23.  
  24.  
  25. ;~~~~~~~~LOADING IMAGES~~~~~~~~
  26.  
  27. Global tile1 = LoadImage("tile1.png")
  28. Global tile2 = LoadImage("tile2.png")
  29.  
  30. Global collboxPT = CreateImage(10,1) ;IS ON THE TOP OF THE PLAYER
  31. Global collboxPM = CreateImage(10,8) ;IS IN THE MIDDLE OF THE PLAYER
  32. Global collboxPB = CreateImage(10,1) ;IS ON THE BOTTOM OF THE PLAYER
  33. Global collboxT = CreateImage (50,50) ;IS ON THE TILES
  34.  
  35. Global player = LoadImage("player(2).png")
  36.  
  37. ;~~~~~~~~GLOBALS FOR THE TILE MAP~~~~~~~~
  38.  
  39. Global xoffset = 50
  40. Global yoffset = 50
  41. Global tilew = 50
  42. Global tilel = 50
  43.  
  44. Global readinfo = 1
  45.  
  46. ;~~~~~~~~GLOBALS FOR THE PLAYER AND THE JUMPING~~~~~~~~
  47.  
  48. Global playerx = 100
  49. Global playery = 540
  50. Global dir = 0
  51.  
  52. gravity# = .5
  53.  
  54. ;~~~~~~~~MAINLOOP~~~~~~~~
  55.  
  56. While Not KeyDown(1)
  57.     Cls
  58.  
  59.         Fdrawtiles()
  60.         player()
  61.  
  62.         Print dir
  63.         Print gravity
  64.        
  65.     Flip
  66.    
  67. Wend
  68. End
  69.  
  70.                                                         ;~~~~~~~~~~~~~~~~TILES~~~~~~~~~~~~~~~~
  71.  
  72. Function Fdrawtiles()
  73.  
  74. For y = 1 To mapsy
  75.     For x = 1 To mapsx
  76.         If readinfo = 1 Read array(x,y)
  77.             If array(x,y) = 0 Then
  78.                 DrawImage(tile1,(x*tilew)-xoffset,(y*tilel)-yoffset)
  79.             ElseIf array(x,y) = 1 Then
  80.                 DrawImage(tile2,(x*tilew)-xoffset,(y*tilel)-yoffset)
  81.  
  82.                                  ;~~~~~~~~COLLISION~~~~~~~~
  83.                                    
  84.                     If ImagesOverlap (collboxPM,playerx,playery+1,collboxT,(x*tilew)-xoffset,(y*tilel)-yoffset) And dir = 1 Then playerx = playerx - 10
  85.                     If ImagesOverlap (collboxPM,playerx,playery+1,collboxT,(x*tilew)-xoffset,(y*tilel)-yoffset) And dir = 2 Then playerx = playerx + 10
  86.                     If ImagesOverlap (collboxPB,playerx,playery+10,collboxT,(x*tilew)-xoffset,(y*tilel)-yoffset) Then
  87.                         gravity = 0
  88.                         Print "coll"
  89.                     Else
  90.                         gravity = .5
  91.                         Print "no coll"
  92.                     EndIf
  93.                        
  94.             EndIf
  95.     Next    
  96. Next
  97.  
  98. readinfo = 0
  99.  
  100.  
  101. End Function
  102.  
  103.                                                         ;~~~~~~~~~~~~~~~~THE PLAYER~~~~~~~~~~~~~~~~
  104.  
  105. Function player()
  106.  
  107.         playery = playery + gravity
  108.         DrawImage player,playerx,playery
  109.  
  110.         If KeyHit(200) And ImagesOverlap (collboxPB,playerx,playery+10,collboxT,(x*tilew)-xoffset,(y*tilel)-yoffset)
  111.                 gravity = - 5
  112.         EndIf
  113.  
  114.         If KeyDown(205) Then
  115.             playerx = playerx + 10
  116.             dir = 1
  117.         ElseIf KeyDown(203) Then
  118.             playerx = playerx - 10
  119.             dir = 2
  120.         Else
  121.             dir = 0
  122.         EndIf
  123.        
  124. End Function
Advertisement
Add Comment
Please, Sign In to add comment