GPWiki.org
GPWiki.org
It is currently Fri May 24, 2013 10:08 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Bevel in a Jump and Run
PostPosted: Fri Aug 19, 2011 3:01 pm 
Hello,

I'm currently have a problem with a 45° bevel in my Jump and Run. I use a tile map to coordinate the sprites but what is the easiest way to make the enemies and the guy walk on a bevel? I thought about a detection class but is there simple way to do it?

Hope anyone that can help me out?


Top
  
 
PostPosted: Sun Aug 21, 2011 8:34 am 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3810
Location: Ferriday, LA, US
Howdy,

If you are talking about sloping tiles, the math goes something like this:

First, take the change in Y (if your tiles are 32*32, then sloping up toward the right would be -32, while if you're sloping down as you go right, it would be 32), and divide it by the change in X (which would normally be -32, given 32*32 tiles). We'll call that the slope.

Now, with the slope figured, we can adjust the height of the object based on its X position. So, something like this:

Code:
object.Y = slope * (object.X - tile_object_is_on.X1) + tile_object_is_on.Y1;


Where "tile_object_is_on.X1" is the left-most point of the tile (i.e. object.X % 32), and "tile_object_is_on.Y1" would be the left-most point's elevation (tile_object_is_on.Y + 32 for an up-to-right slope, or tile_object_is_on.Y - 32 for a down-to-right slope).

Hopefully I explained it well enough (and got all my numbers right -- I'm no math scholar :) ). If you have any trouble or other questions, let us know!

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group