walkability for a side scroller questions...

Started by
16 comments, last by Ferinorius 22 years, 5 months ago
Question:
Will snapping to the next tile create jerky movement?

If so, is there a better way?

Let me explain a little more about the program:

Spark (the sprite) has different states; when a key is pressed left or right, or when the space (jump button) bar is hit, or when the sprite is falling.

Before, the code where the picture was taken, was horribly slow because I checked to see (using that equation) if the sprite is on the tiles each key press. I took that out in search of a better way. I know that the sprite needs to always be falling.

No one seems to be elaborating, and I know im not being clear enough.

When the space bar is pressed, spark''s velocity is set to something like 35. then, it is decreased each frame by gravity, which is 3. this is a nice quick and low jump.

but the problem is that spark doesnt jump from a paltform, he jumps from some y coords. if spark''s y position less than a certain point, i reset it. this is one problem. Now, when i take that out, its like the program doenst know its falling over tiles, but its falling across the screen.

Here is where i need the help. I need more elaboration. As I said once before, there is no tutorials that fully explain it, I am having to learn this from the start....I know you all know what you are talking about, so let''s pretend I dont.



Neo-Toshi - The City That Never Sleeps
Advertisement
When you say that Spark does not jump from a platform are you
saying that if he is in mid air you can still jump ?

Please do the following it will help I promise you. I am not
preaching but rather trying to get your mind into a different
mode

Forget code right now. Get a piece of paper and draw a rectangle
now put this rectangle through a series of states.

You know what you want from the code. Move away from the code
look at the problem and come back.

I am not saying this is the best way. But I spend days drawing
the permutations before even going near code.

At the end of the day this is a collision problem. You have a
vector from X0,Y0 through to X1,Y1. Knowing that fact you have
to project what would have been hit.

It could be that other code in your logic is getting in the
way of solving the problem. Isolate the problem. Set Spark to
a known state for example making him fall and process the
collsion rather than test him in the game environment.

Isolate the problem if you can , other code could be the
culprit.





I took your advice and looked at the problem, and then i hurridly removed ALL the tile checking and collision stuff from the program so that I can have a clean start.

I appreciate this ancientcoder, by the way, for being patient with me on this.

Now that I have a clean start, I have all these things to draw out:

akwardly shaped sprite 96 tall by 79 wide, and 64x64 sized tiles.

Now, to look at it from this different perspective, am I trying to check tile by tile, or point to point?
It might be easier tile by tile, but I get all confuddeled doing a switch from tile coords to point coords urgh.

I also want to mention, I wasn't getting stuck, I meant that Spark just jumps from the y position at 290. then he jumps, the velocity decreases, he falls, and only stops when he reaches 290 again. so spark didnt know if he was on a tile or not, just that he was getting told to jump


Ya see, I am more hands on so I learn slowly this way, but I am so eager to learn this.

Neo-Toshi - The City That Never Sleeps

Edited by - Ferinorius on November 7, 2001 2:21:39 PM
Ok, new post.

I have all these state:
falling, jumping, pressing right, pressing left, dying and so on.

the states pressing right, left and jumping should all be included under the falling state. then, if a key is pressed, check the tile NEXT to spark. if it is ok, then increase position to the next tile. now check to see if there is a valid tile BELOW spark. if there isn''t a valid tile, decrease y value, else, dont decrease, dont fall.

or at start of loop check tile below spark, if it is valid, dont decrease the y, it there is no tile, or it is a fall through tile, then fall and decrease y value. If y value is more than the height of the screen, Spark has fallen, all bow.

am I getting on the right track now?
Sorry for my previous post, got a little muddled and this machine crashed in the middle. What I was trying to illustrate/convey I suppose is that it is a problem of rectangular collisions.
Most of the movement is within the same tile, you only do collision detection when any corner of your bounding rect crosses a tile boundary. But you have to check every corner. If the bottom right corner is over a valid tile, you can''t fall.
If the bottom left corner is over a valid tile you can''t fall. etc...
If you maintain the always falling concept, then this collision detection will be occuring every frame as you try and move through the tile beneath it.
I think you may be getting mixed up, or maybe I am , with states versus input reaction. Unless you''re dying, the only state you''re in "moving" (whether you are or not ) The users input should do something like if the right key is press send message to object to add to right velocity. The the object does something like do I have traction and if so then if I''m at less than maximum velocity to the right, then add so much that velocity. It doesn''t really change state, just sends a message to the object which changes the velocity vector. Traction would be defined as having my foot on the ground, i.e. I was stopped from falling in the last frame.
Then later in your update loop the object then says, ok I''m moving right, so I need to be in the run animation to the right. Every successful motion then updates the current frame. The the only real "state" is the kind of the animation sequence I''m in. When you get an input message you check and respond to it by setting the various parameters (velocity, animation state, etc...) But you don''t do anything until the update segment when you validate it all/process any change.
blah, hope that helps focus,
cheers,
-m








mat williams
Lead Programmer, Designer
Zero Sum Software
www.zero-sum.com
mat williamsLead Programmer, DesignerZero Sum Softwarewww.zero-sum.com
From what I understand is that Spark can be steered when
he is falling ?

He commits to a jump but you can manipulate his movement during
the jump ? Is this what you mean?

Write down what you want your character to do.

For instance....

When I press the jump key my character will move in an arc
he will move X units in a positive direction and Y units in
a negative direction. When the character reaches the top of
the arc his X and Y will increase according to gravity.

During the course of this jump the user may press the left
arrow to steer the character back from the jump. By pressing
left the user will be allowed to correct the jump and decide
that he does not want to commit. However if he presses right
the jump will continue.

Do you have access to any good platform games? Have a look at
Mario / Jazz Jackrabbit and see what they do.

Press the spacebar for a short while and you get a lesser jump,
press it a bit longer and you get more height.

Most good platform games allow you to correct a mistake. It is
very important that you understand the functionality you require.

Sorry for sounding so vague but please write down what you require. Forget the code , forget the code!!!!


FOR THE LOVE OF GOD STOP LOOKING AT CODE!!!!!!!!!!!!!!!!!!

You have got a problem in design, throwing codes only gonna make the problem mad. Often times (and this is a prome example) you keep trying to alter code when that will get you nowhere and shoot your morale to hell. You haven''t thought this through enough (niether have i, thats why i offer no help). Go through each possible step, think how your program should deal with it. DRAW DIAGRAMS! Transitive state and Class relationships diagrams are good here. Once you have a course of clear action take a break, sit down and mothodically write code.

The code is minor, deeply understanding the design is MAJOR.

RELIGION IS THE ROOT OF ALL EVIL
Ambassador: Mr. Bush are you stoned or just really, REALLY dumb?Pres. Bush - I assure you I am not stoned.
Im getting the picture that I am going about this problem all wrong!

I understand why I have to do this, so I put the code down, in fact, C++ hasn''t even been opened since I wrote my last reply, and I am THINKING this through.

For my game, I want spark to be able to jump off the ground, or jump off of any platform in the game that he can reach from a jump. spark also has the ability to run or walk. runing in the same direction for a while enables him to run, and vice versa.

Spark cannot jump while in midair.

Spark will eventually collect coins, and destroy baddies in a zelda-esque manner. Sword in hand, attacking like an adventure game.

Its quite a take on the side scroller, with action game battling, and platformer jumping.

The tiles i know, are 64x64. Spark has a big area to jump around on.

Now that I know what I want, how do I implement this?

Spark will need to detect which tile is in front and behind him. If to the side is something other than a fallthrough tile, Spark cannot move. Otherwise, jumping, moving, or any other action is permitted. This goes the same with the one below him. If it is a fallthrough he falls, otherwise, no restriction.

That is what I have written down, among other little arrows, squares, sparks, and other things. Now I feel more comfortable because I have more of an objective. I have a goal to work towards.

Implementing all this is something entirely different.

This topic is closed to new replies.

Advertisement