Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / How do you make a sprite properly interact with a slope in a platform game?

Author
Message
Garfield rules
21
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 17th Dec 2006 23:00
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.
Monty87
22
Years of Service
User Offline
Joined: 8th Dec 2003
Location: not very deep in the west country, eng
Posted: 28th Dec 2006 16:29
Umm answering you questions but ignoring the code...
1) sprite collisions automatically doesnt include the black elements of the picture (You can change this if you need, look in the manual) so if you make a sprite based slope (just overlay it) then that will work.
2) Making sprites slide down a sprite slope is tricky. You need gravity (sprite 1,x,y+1,1) but you also need it to go out to the side one. If you have a slope no steeper than 45deg then you can place two tiny little sprites to either side of the character sprite. If character hits and tiny left sprite isnt hit but right is then goes left (and down). If right isnt but left is then go right and if nether than dont move at all (except down). Its not very elegant but it does work.

Monty

Login to post a reply

Server time is: 2026-07-04 23:28:04
Your offset time is: 2026-07-04 23:28:04