• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Accelerating/ Decelerating Top-Down character (problems).

K

Koopaul

Guest
Greeting everyone! Brand new to the game making scene. Let me first explain that I myself am not directly working with Game Maker myself, instead my partner (who lives somewhere else in the country) is. However I wish to help in anyway I can. See I'm the Graphic Designer and Co-Director of the project.

Anyway, let's get to the issue. In this game we have a character who flies around in a top-down view. I made different sprites for the character flying in 8 directions. Facing North, South, East, West, Northwest, Northeast, Southwest, Southeast (all while flapping her wings). We got our character to move around and I tested it. Now being the fussy fellow I am, I took note at how moving around didn't feel like flying but instead walking in a top-down RPG. I came to the conclusion that the character needs to accelerate while moving and decelerate to a stop (instead of stopping instantly). This would give the character a more fluid movement.

Now my partner is a beginner at Game Maker and I know nothing about coding.

So we tried this guy's advice:

And it seems to work for the most part. But the East animation is not appearing when it should.

Here is the code for returning her direction:
if (direction>335) and (direction<360) or (direction=360) or (direction=0) or (direction>0) and (direction<22) {
state = 'east'}
if (direction>21) and (direction<66) {
state = 'northeast'}
if (direction>65) and (direction<110) {
state = 'north'}
if (direction>109) and (direction<154) {
state = 'northwest'}
if (direction>153) and (direction<198) {
state = 'west'}
if (direction>197) and (direction<242) {
state = 'southwest'}
if (direction>241) and (direction<286) {
state = 'south'}
if (direction>285) and (direction<336) {
state = 'southeast'}


What do you suppose this issue is?

I was also wondering what other methods are there to have our character accelerate when the directional input is pressed and decelerate to a stop when it is let go? If that video posted above is our best bet then we will continue to do what we can.

Thank you in advance!
 
Last edited by a moderator:
B

Babuchi

Guest
I am the coder, and the east animation will work in many cases, but one exception: If she's going southeast, and then transitions to just going east, her southeast sprite remains. Going north will fix it, but that's awkward. This is almost certainly down to the finicky nature of Game Maker's using degrees to measure directions, instead of rotation (in practice, 0 degrees is what GameMaker considers straight right); since you can't have a single condition checking if a real number is simultaneously 20 degrees greater than 0, and 20 degrees less than 360 (amount not representative, but you get the idea) you need multiple "or" statements. The bug is probably in that code, but I'm not sure what it is.

Edit: I also want to correct something Koopaul made a mistake of in the title: Our character is not actually top-down, so please do not suggest switching to just rotating the character.
 
Last edited by a moderator:
K

Koopaul

Guest
Just so you guys get a better idea of what we're talking about here's our character's sprites:

 

Khao

Member
Try changing the first line to this:
if ((direction>335) and (direction<360)) or (((direction=360) or (direction=0)) or ((direction>0) and (direction<22))){

When I got a bunch of confusing conditionals, I always add a few parenthesis even if it looks redundant. Just to make sure it's read exactly the way I want it to.
 
B

Babuchi

Guest
Oh wow; it actually worked! Thank you so much, and my oh my; I salute you for being able to keep track of so many parentheses! Does the placement of "or" and "and" affect when you need to enclose expressions?
 
Top