Vertical obstacle with walkable area

Started by Mehrdad, Wed 02/03/2016 16:18:02

Previous topic - Next topic

Mehrdad

Hi

I made a very simple platformer and use walkable area for horizontal solid or obstacle

Code: ags
GetWalkableAreaAt (player.x-GetViewportX(), player.y-GetViewportY()) //Checks if player is in an walkable area, returns number, if not on walkable returns 0


with simple gravity

Code: ags
if (GetWalkableAreaAt (player.x-GetViewportX(), player.y-GetViewportY()) == 0) player.y++; //Moves player down one pixel as long as it is in the air


It works fine .How can I write make vertical solid with same walkable area?
I'm appreciate for any help or suggestion or any code
My official site: http://www.pershaland.com/

Monsieur OUXX

I did not understand the question.

Off-topic: I would recommend NOt to program your own platformer, as the complexity becomes exponential. Use one of the two engines already existing in AGS instead. they come with level editor and everything : http://www.adventuregamestudio.co.uk/forums/index.php?topic=45261.msg607397#msg607397
 

Khris

The basic idea is to choose a resolution for collisions, then check multiple points near the edge of the character.
Say you decide that any obstacle is at least 10x10 pixels in size. If your character sprite is 20x30, you check (0,0) (10,0) (19,0) on top, then (0,10), (0,20), (0,29) on the left edge, and so on. (Right now you're only checking the character's position, the center bottom).

Each loop, you move the character according to its current x and y speed, then you check for possible collisions, and if one occurs, you move them back accordingly, right before the screen is redrawn.

Or do like Monsieur OUXX says and use an existing engine, like the one he linked to or DKH's.

Mehrdad

Quote from: Khris on Thu 03/03/2016 11:58:25
The basic idea is to choose a resolution for collisions, then check multiple points near the edge of the character.
Say you decide that any obstacle is at least 10x10 pixels in size. If your character sprite is 20x30, you check (0,0) (10,0) (19,0) on top, then (0,10), (0,20), (0,29) on the left edge, and so on. (Right now you're only checking the character's position, the center bottom).

Great idea. I'll try it. Thanks Khris

@Monsieur OUXX
Download link was broken. Is it open source ?
Would you mind upload it another location.
My official site: http://www.pershaland.com/

Monsieur OUXX

If the download link is broken, then send a Personal Message (PM) to the original developer.
Otherwise, as Khris suggested, the other heavywieght engine made with AGS is by DoorKnobHandle (DHK) and can be found here (small "download sources" link) : http://www.adventuregamestudio.co.uk/forums/index.php?topic=49687.0

I don't know the pros and cons of each of these engines so you should really try to get your hands on both of them and try them out to see if they're easy to adapt to your purposes.
 


Mehrdad

Thanks so much Monsieur OUXX and CW . Links was great and helpful ;-D
My official site: http://www.pershaland.com/

SMF spam blocked by CleanTalk