The Daily Click ::. Forums ::. Non-Klik Coding Help ::. C++ & Allegro
 

Post Reply  Post Oekaki 
 

Posted By Message

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
25th April, 2006 at 07:27:08 -

I've recently gotten into programming using Allegro, and I must say it's pretty cool. I've tried programming a platform engine, but I run into problems similar to when you make a custom platform engine in MMF and don't use MMF and/or Platform Movement Object. I can control my character left and right, he falls down when in the air, and collides with obstacles. But when standing on ground, he "twitches" up and down just like in MMF. Anybody know what to do ?

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
25th April, 2006 at 08:35:16 -

It probably has something to do with your programming. My theory is that when your player is touching the ground he is pushed up to get him out of the ground, but as soon as he is out of the ground, he is pushed back in because of gravity. You probably need to balance it out somehow.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
25th April, 2006 at 09:07:17 -

That's exactly what's happening. I just have no idea how to balance it. I've tried pushing the player up by 2 pixels if he collides, and down by 1 if he doesnt. ALso tried 1 up, 2 down etc. nothing works..

 
n/a

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
25th April, 2006 at 14:53:40 -

You'll have to figure out a way for the character to be exactly 1 pixel above before the screen is drawn. Lots of things can be done before that happens.

 
thinking is like pong, it's easy, but you miss sometimes.

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
25th April, 2006 at 17:59:16 -

Concepts like detectors in MMF carry over to C++. You could experiment with using a zone under the player's feet. You only make him fall if the zone isn't over something, and only raise him if his feet are overlapping.

 
- Tigerworks

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
25th April, 2006 at 18:48:06 -

That's what i did. The player's zone is 32x32. I check for collisions in a zone that's 32x4 and positioned under the player:

Image

Image Edited by the Author.

 
n/a

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
25th April, 2006 at 20:35:29 -

You check if nothing is in the 32x4 zone area, and check if there is a backdrop in the 32x32 player area.

 
- Tigerworks

renkin



Registered
  31/05/2002
Points
  311
15th May, 2006 at 03:27:25 -

One way would be:

IF the first row of pixels beneath the player collision box are free from collision
THEN Apply gravity code (increase falling speed or whatever)
ELSE do nothing

Then you move the character according to its vertical and horizontal speed, check for collisions and stuff to find the appropriate position.

That way you won't have to handle a lot of collisions with the ground when just walking left and right, since the gravity code won't run as long as the character is standing on something.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click