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.

AppGameKit Classic Chat / Controlling a character in a platforming game

Author
Message
KareDev
12
Years of Service
User Offline
Joined: 6th Feb 2012
Location:
Posted: 12th Feb 2012 22:43
So I've been working on a quick project to learn how to use AppGameKit, and I'm doing OK so far - I have images loaded in, sprites moving onscreen, a few other things - but now I want to look into how to manage my character's movement.

I've got to the point where I could click on quadrants of the screen, and the character sprite would drift in a diagonal direction based on where I clicked.

What I want to do next though is have a character sprite who stands on a floor sprite, and when I click, jumps up in the air - like in a 2D platforming game.

What is generally seen to be the optimum solution for this in AppGameKit?

I spent a few hours tonight adding variables to my character TYPE - forceX, forceY, speedX, speedY, weight etc. and trying to code in the functions to handle his speed, acceleration, sudden burst of force when you hit the jump button - but this seems to be a bit daunting when I'm trying to deal with collisions, and the problems that can occur (such as if my character sprite overlaps with another that it is supposed to be colliding with).

Is there a physics-based solution to this problem? Or do I just generally need to do what I'm doing, except better?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Feb 2012 07:33 Edited at: 13th Feb 2012 08:13
I have just finished a tutorial on this for the next AppGameKit Bitesize tutorial in the TGC newsletter. There was recently another post on the forum where I posted a simple example using physics sprites. I'll find the link...

Edit: better still here is the code I posted.


Mark Harrison
13
Years of Service
User Offline
Joined: 28th Oct 2011
Location: Australia
Posted: 13th Feb 2012 11:17
Is there an example that only lets you jump when your on a surface?

yo
Greg_C
14
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 13th Feb 2012 18:00
You can use a raycast from the middle of your character to just below his feet and then check if it hits anything. If it does then your character is on the ground and you can set Jump to true.

This was suggested to me and works great.

Login to post a reply

Server time is: 2024-11-23 04:16:33
Your offset time is: 2024-11-23 04:16:33