Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Graphics 1000,700,0,2
- SetBuffer BackBuffer()
- Global mapsx = 20
- Global mapsy = 14
- Dim array(mapsx,mapsy)
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- Data 0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0
- Data 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0
- Data 0,1,0,0,0,1,0,0,0,0,1,1,0,1,0,0,0,1,0,0
- Data 1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1
- ;~~~~~~~~LOADING IMAGES~~~~~~~~
- Global tile1 = LoadImage("tile1.png")
- Global tile2 = LoadImage("tile2.png")
- Global collboxPT = CreateImage(10,1) ;IS ON THE TOP OF THE PLAYER
- Global collboxPM = CreateImage(10,8) ;IS IN THE MIDDLE OF THE PLAYER
- Global collboxPB = CreateImage(10,1) ;IS ON THE BOTTOM OF THE PLAYER
- Global collboxT = CreateImage (50,50) ;IS ON THE TILES
- Global player = LoadImage("player(2).png")
- ;~~~~~~~~GLOBALS FOR THE TILE MAP~~~~~~~~
- Global xoffset = 50
- Global yoffset = 50
- Global tilew = 50
- Global tilel = 50
- Global readinfo = 1
- ;~~~~~~~~GLOBALS FOR THE PLAYER AND THE JUMPING~~~~~~~~
- Global playerx = 100
- Global playery = 540
- Global dir = 0
- gravity# = .5
- ;~~~~~~~~MAINLOOP~~~~~~~~
- While Not KeyDown(1)
- Cls
- Fdrawtiles()
- player()
- Print dir
- Print gravity
- Flip
- Wend
- End
- ;~~~~~~~~~~~~~~~~TILES~~~~~~~~~~~~~~~~
- Function Fdrawtiles()
- For y = 1 To mapsy
- For x = 1 To mapsx
- If readinfo = 1 Read array(x,y)
- If array(x,y) = 0 Then
- DrawImage(tile1,(x*tilew)-xoffset,(y*tilel)-yoffset)
- ElseIf array(x,y) = 1 Then
- DrawImage(tile2,(x*tilew)-xoffset,(y*tilel)-yoffset)
- ;~~~~~~~~COLLISION~~~~~~~~
- If ImagesOverlap (collboxPM,playerx,playery+1,collboxT,(x*tilew)-xoffset,(y*tilel)-yoffset) And dir = 1 Then playerx = playerx - 10
- If ImagesOverlap (collboxPM,playerx,playery+1,collboxT,(x*tilew)-xoffset,(y*tilel)-yoffset) And dir = 2 Then playerx = playerx + 10
- If ImagesOverlap (collboxPB,playerx,playery+10,collboxT,(x*tilew)-xoffset,(y*tilel)-yoffset) Then
- gravity = 0
- Print "coll"
- Else
- gravity = .5
- Print "no coll"
- EndIf
- EndIf
- Next
- Next
- readinfo = 0
- End Function
- ;~~~~~~~~~~~~~~~~THE PLAYER~~~~~~~~~~~~~~~~
- Function player()
- playery = playery + gravity
- DrawImage player,playerx,playery
- If KeyHit(200) And ImagesOverlap (collboxPB,playerx,playery+10,collboxT,(x*tilew)-xoffset,(y*tilel)-yoffset)
- gravity = - 5
- EndIf
- If KeyDown(205) Then
- playerx = playerx + 10
- dir = 1
- ElseIf KeyDown(203) Then
- playerx = playerx - 10
- dir = 2
- Else
- dir = 0
- EndIf
- End Function
Advertisement
Add Comment
Please, Sign In to add comment