The Daily Click ::. Forums ::. Klik Coding Help ::. Positioning problem
 

Post Reply  Post Oekaki 
 

Posted By Message

Ruper



Registered
  11/02/2009
Points
  8
3rd December, 2009 at 04:09:03 -

I'm working on a movement engine that I want to have some 2.5d aspects to it.
I'm trying to make it so that when you walk on an obstacle background that has a slant to it, it will act as though it is a slope. Here's a picture to (sort of) show the effect I'm trying to get...
Image

Right now I have two sensors on either side of the player that sense where the walls are, and they calculate the slope of the wall at the same time. When the two slopes are similar it will add the average of the two slopes to the players Y position.

While this method sort of works, it's not as smooth as I would like. I've tried a number of things to make it look better but I'm still not satisfied with it. Can anybody give me some tips?

 
-Ruper

bigredron



Registered
  07/04/2007
Points
  299
3rd December, 2009 at 04:41:57 -

detectors should work really. Might need to see some of your code to help you out more

 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
3rd December, 2009 at 04:51:40 -

I made a 2.5D engine that used different active objects for different types of terrain (because I was too lazy to program a height map for the second time) and that used right-triangle trigonometry based on the position relative to the slope object and the height of the terrain as determined by alterable values, so that if it had a height of 64 (pixels) and length of 32 (as determined by the actual object size) with another value determining direction of going up as you move right, it would have a right triangle with base 32 and height 64, or 2 pixels of displacement per one pixel distance into the object.

Of course, that's completely different to what you're doing right now...

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

Xgoff



Registered
  22/02/2009
Points
  135
3rd December, 2009 at 06:14:28 -

i'm really not experienced in doing stuff like this, but i imagine it's rough since you're snapping the sensors to raw pixel slopes; you may draw a 30º line but once it's rasterized it becomes too rough to be reliably measured as 30º, without knowing the exact endpoints. this is possible with simpler angles such as 45º or 0º though.

what would work better is if you sampled each line at multiple points and averaged their slopes... however this has a problem of "softening" corners, which becomes more pronounced the further you sample from the base sensors. plus it's still not exact. there's also the additional overhead if you need this applied to many objects

if you wanted it to be perfect you'd almost have to have straight point data for your lines stored in a separate file, or have some other way of just telling your engine "this is a 30º" without needing to measure the lines themselves, which is of course less flexible.

 
Image
   

Post Reply



 



Advertisement

Worth A Click