Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mehrdad on Wed 02/03/2016 16:18:02

Title: Vertical obstacle with walkable area
Post by: Mehrdad on Wed 02/03/2016 16:18:02
Hi

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

Code (ags) Select
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) Select
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
Title: Re: Vertical obstacle with walkable area
Post by: Monsieur OUXX on Thu 03/03/2016 09:20:29
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
Title: Re: Vertical obstacle with walkable area
Post by: 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).

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.
Title: Re: Vertical obstacle with walkable area
Post by: Mehrdad on Thu 03/03/2016 13:21:50
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.
Title: Re: Vertical obstacle with walkable area
Post by: Monsieur OUXX on Fri 04/03/2016 09:12:49
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.
Title: Re: Vertical obstacle with walkable area
Post by: Crimson Wizard on Fri 04/03/2016 13:18:43
Also, there is PLATENG: http://www.adventuregamestudio.co.uk/forums/index.php?topic=40922.0
Title: Re: Vertical obstacle with walkable area
Post by: Mehrdad on Fri 04/03/2016 14:23:05
Thanks so much Monsieur OUXX and CW . Links was great and helpful ;-D