Hello. I have a small platform game engine. It uses a tilemap and tilemap collision based on Pizzaman's tutorial. There's one thing I don't know how to do though--Make slopes. Let's say that in the game I want one type of tile to be a slope. How can I make the sprite climb and descend the slope tile properly? How can I make it so that, after jumping, the sprite only lands on the ground part of the tile and not the blank part (the part of the image not taken up by the slope)? How could I work that into my current collision subroutine? I am using DBC.
In this code, tilemap is an array, wherein each tile's image is stored. Images 2 and 3 are tiles that you can collide with. Image 1 is a background (non-collidable) tile.
tilecollision:
rem camerax and cameray are scrolling variables that are added onto the player's coordinates for collision detection
lefttilenum=int((playerx+camerax)/tilesizex)
righttilenum=int((((playerx+camerax)+(tilesizex-1))/tilesizex))
toptilenum=int((playery+cameray)/tilesizey)
bottomtilenum=int((((playery+cameray)+(tilesizey-1))/tilesizey))
oldlefttilenum=int(((oldplayerx+oldcamerax)/tilesizex))
oldrighttilenum=int((((oldplayerx+oldcamerax)+(tilesizex-1))/tilesizex))
oldtoptilenum=int((oldplayery+oldcameray)/tilesizey)
oldbottomtilenum=int((((oldplayery+oldcameray)+(tilesizey-1))/tilesizey))
If tilemap(lefttilenum,oldtoptilenum)>=2 then playerx=oldplayerx:camerax=oldcamerax
If tilemap(oldlefttilenum,toptilenum)>=2 then playery=oldplayery:cameray=oldcameray
If tilemap(righttilenum,oldtoptilenum)>=2 then playerx=oldplayerx:camerax=oldcamerax
If tilemap(oldrighttilenum,toptilenum)>=2 then playery=oldplayery:cameray=oldcameray
If tilemap(righttilenum,oldbottomtilenum)>=2 then playerx=oldplayerx:camerax=oldcamerax
If tilemap(oldrighttilenum,bottomtilenum)>=2 then playery=oldplayery:cameray=oldcameray:jstart=1
If tilemap(lefttilenum,oldbottomtilenum)>=2 then playerx=oldplayerx:camerax=oldcamerax
If tilemap(oldlefttilenum,bottomtilenum)>=2 then playery=oldplayery:cameray=oldcameray:jstart=1
If tilemap(oldrighttilenum,bottomtilenum)<2 and tilemap(oldlefttilenum,bottomtilenum)<2 and jstart=1 then jstart=0:j=30:speedy=-1
return