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.

2D All the way! / Another annoying perplexing question

Author
Message
aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 9th May 2007 00:40
How do youGet the angle of ground right in front of a character?

I will Learn to rule 2d. Someday...
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 9th May 2007 21:37
In 2d? Are we talking sidescroller, overhead tile map? It would help if you could explain the situation in a bit more detail.

aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 9th May 2007 23:44
2d this is the 2d forum after all.

WHat i mean is to examine the ground right in front of the character on a 2d platformer and get its angle.

I will Learn to rule 2d. Someday...
Zergei
20
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 10th May 2007 13:42 Edited at: 10th May 2007 13:42
You mean on a sidescrolling game?, something such as this?...


Further on my stuff at...

Attachments

Login to view attachments
aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 10th May 2007 15:16
Yes.

I will Learn to rule 2d. Someday...
stoned coder
18
Years of Service
User Offline
Joined: 6th May 2007
Location:
Posted: 11th May 2007 06:46
if u use seperate tiles to make the ground you could just make a label for each tile. ie state that the image for a 45 degree slope is slopeanlge45(or something) then you can create code that detects which tile the player is on and will react accordingly?????? i mean i dont know its just a thought while reading your question.
would this work...discuss...
stoned coder
18
Years of Service
User Offline
Joined: 6th May 2007
Location:
Posted: 11th May 2007 07:01
oh yes ive just read this ...
zenessem wrote this on the same topic..
Quote: "It really depends on how you code your tile mapper. And is this a straght down 2D tile map game? Isometric? please elaborate.

I can explain the basics of the method(s) I've used.

method 1:
I would use 2 layers of my multidimensional array (or a seperate array) that would have a value depending on the tiles slope, or other facter (eg. Speed, like swamps, forest, deep water etc...).
As the player moved my tile-engine processing routines would look to those values (in the same way I would look at other values to decide which tile to draw)

So depending on how many different angle slopes you have:
The first layer
A value of...
0 = mean no slope
45 = a 45 degree slope this would trigger me to call my routine to slow character speed, and adjust the character Y position accordingly

The second Layer:
was used to indicate which direction the angle going up was
1 = Up to the north
2 = Up to the south
3 = Up to the east
4 = Up to the west


same would go for other angles.

I would use other values in the first array to determine speed of tiles
0 = Normal speed
1 = Faster speed
2 = Slower speed
3 = Extremely fast
4 = Extremely slow

etc...

Method 2:
I used something similar to a height map in 3D games. Pretty much each pixel of the image represented a tile on the map. Each color or shade (depending on what I needed I either used a gray scale image and other times I would use colors) of the image refrenced the same values in method 1.

For instance a white pixel meant 0 slope and normal speed
a green pixel meant extemely fast speed.

etc...
"

Thats what i meant..
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 11th May 2007 09:34
Take a look at this thread. Because you both are asking the same question, even though his example is top down and yours is a scroller it doesn't make a difference in theory. Especially if your 2d Platformer is created out of tiles.

Another method, is to out line the tiles image edge with a color, then you just check for that color pixel and move the character above it (on a platformer).

Another method, is like the other thread i refered to. Where as the tile collisions are handled in the structure of the array for the map itself. And you can have code that for specific tile numbers move the character at a 45 degree angle.

Your next question will probably be the same as the other thread. How do i predict jumps and landings onto these tiles.

aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 11th May 2007 23:46
That's not exactly what I meant...

I mean how would I get the angle of the ground in front of me without using arrays?

If I do decide to use this method, my next question is actually how to load the arrays....

Your signature has been deleted by a moderator because this joke is getting old.
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 11th May 2007 23:58
How are you creating your scrolling map if not using tile images stored in arrays. Are you just using a large image and scrolling it in the backround? If so it's not the most efficient way to handle a platformer, as many of the graphics are just repeated.

So in order for me to help aluseus, I honestly need to know how your world graphics are stored, and how they are being blitted to the screen.

The use of arrays makes sense for so many reasons. The map is made of positioning a number of small tiles (sprites or texured 3D plains) that can be repeated throughout, animated, and even color adjusted to be used in multiple levels. by using an array, the collision detection is built into the structure as well as positioning enemies, triggers, items, hidden paths. The Z-Ordering is also inherrent in the array.

Now just becuase you use an array of images, doesn't mean that the character is limited to walking 1 tile every time. You can either just keep track of boundaries (so every so many pixels the character moves), you increase it's tile location. You could also use a polar coordinate system.

aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 12th May 2007 01:58
My graphics are one big image saved to a bitmap which I then cut the part that will actually be seen.

Your signature has been deleted by a moderator because this joke is getting old.
stoned coder
18
Years of Service
User Offline
Joined: 6th May 2007
Location:
Posted: 12th May 2007 13:30 Edited at: 12th May 2007 13:32
well in that case i dont think you can .unless u create your own type of file that somehow extracts such info about the image on it.Which sounds like it may take some doing , i would make seperate tiles .... I suppose you could find every angle of flooring on your large screen ,map the coordinants were the player would make contact as in 3d space....this is geting hard to explain ..basicly the problem is you have one large map which you want the program to treat differently in different areas but it has no way to know, there is no information stored in the image which can indicate the differences, so either you make a very clever prog that will analise images and get line angle data from it or you make seperate tiles which you can easily tag all the info your prog needs to make the right movement over the right tile..
all you have to do is cut up your image so there is only one type of floor angle on each bit.
Or make an overlying invisible map that does hold the data and detection info.
aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 12th May 2007 15:18
See, I was thinking of getting the y location of the ground your standing on and the y location of the ground in front of you...
Well, thanks for trying guys.

Your signature has been deleted by a moderator because this joke is getting old.
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th May 2007 20:10
You can still do it the way you have it:

Method 1: You can code your movement code to look for the color of the ground. Then you apply som simple gravity, and whenever the pixels below the character are a given color that's the groun.

If you have a lot of different color grounds, platforms, the trick is to surround your platform collisions with a border value. Depending on your resolution they can hardly be seen, and actually can help the visuals by making things pop.

If you don't like the above see method2:

Method2: You create a gray scale collision bitmap (boxy like a tile representaton of your world) reperesenting your world, this bitmap is never drawn to the screen, but it is simply used as a collision checking zone. the different shades of gray define the slope and platforms. I usually use black for any hard platforms and ground, white for open space. And differect shades of gray to reflect what the sloaps are for that square.

Method3: You actually do it mathematically, calculating tagent lines in look-ahead ahead code. It's not that hard, but needs some thought.

aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 12th May 2007 20:12
I like method 3. Can you explain it some more?

Your signature has been deleted by a moderator because this joke is getting old.
Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 22nd May 2007 21:09
Here's a simple method. You need to get two points: point A would be the player's position X and Y (at the feet), and point B would be a bit in front of the player for X and for Y you would get the height of the ground at that point.

To calculate the angle between point A and point B:



Login to post a reply

Server time is: 2025-05-16 04:46:14
Your offset time is: 2025-05-16 04:46:14