DEV Community

Cover image for Dev log for Wonder Wanderer 2: Day 11 #LOWREZJAM ๐Ÿ˜
Michael Primo
Michael Primo

Posted on

Dev log for Wonder Wanderer 2: Day 11 #LOWREZJAM ๐Ÿ˜

What did I do today?

This is one of the days which I made nothing and everything at the same time. I prepared the sprite for the main character's animations, 10 main levels with two variants and...a playable level 1! I tried to do a palette swap, but tomorrow I'll remove it.
Alt Text

First level of the game with a different palette.

Top comments (2)

Collapse
 
mxglt profile image
Maxime Guilbert

How did you manage the gravity?
I really like how it looks!

Collapse
 
michaelprimo profile image
Michael Primo

Howdy!

There are three types of gravity:

1) Normal one. For that, you need to create a speed variable and then a indipendent speed for both X and Y of the character which you can manipulate by pressing the buttons (so, pressing D will add speed to the X variable, A will reduce that and so on). On the update loop you have, you need to have a gravity and friction variables. Friction: will gradually stop your character from moving (you need to do something like player.friction = 0.8; speedX *= player.friction; ) and the same with gravity (player.gravity = 0.3; speedY -= player.gravity; ). You can learn more here: somethinghitme.com/2013/01/09/crea... ;
2) When you press X, you reduce the gravity to 0 and put a boolean for stopping the speedY to decrease over time, so you can move freely in a top-down fashion (after mapping the W and S buttons to do that like you did for A and D). When you press X again, you return to your normal gravity and change again the boolean (I did something like maxGravity, so you can remember the initial gravity what it was);
3) For adding the gravity effects, I did a maxGravity and gravity editing every time you enter to a door, so it could be 0.035 one time and 0.002 later, or maybe 0.07 or simply 0 or -0.035.

Hope it helps :)