It is currently Thu Dec 12, 2013 12:50 pm

 All times are UTC

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Bevel in a Jump and RunPosted: 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

 Post subject: Re: Bevel in a Jump and RunPosted: Sun Aug 21, 2011 8:34 am
 Harmlessness does no harm

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3913
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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Baidu [Spider] and 2 guests

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

Search for:
 Jump to:  Select a forum ------------------ Forums    Forum Rules and Posting Guidelines Wiki Discussion    Help    Content Issues Game Programming Discussion    C and C++ Game Programming    Java Game Programming    Language Agnostic Programming    .NET Game Programming    VB Game Programming    Mobile Game Programming    Web-Based Game Programming    Other Languages    OpenGL Development    Direct X Development Game Development Discussion    Game Design    Game Media Off-Topic Discussion    Announcements    Off-Topic    Community Projects    News