T
TheJJGamer
Guest
Heya!
I'm so pissed at this because I can't figure out what's causing it! I've been working on a Super Mario Bros. 3 clone and I'm trying to have the player slow down to a stop instead of just instantly stopping (like in the game), but something's keeping the player slowly walking to the right once he reaches the speed limit! I know it's got something to do with the slowing down when the left/right keys are released. Any help?
I'm so pissed at this because I can't figure out what's causing it! I've been working on a Super Mario Bros. 3 clone and I'm trying to have the player slow down to a stop instead of just instantly stopping (like in the game), but something's keeping the player slowly walking to the right once he reaches the speed limit! I know it's got something to do with the slowing down when the left/right keys are released. Any help?
Code:
// Speed limit //
if (hspeed > speedCap) {hspeed = speedCap;}
if (hspeed < -speedCap) {hspeed = -speedCap;}
// Left/right movement //
//Keys pressed
if (keyboard_check(key_Right)) {hspeed += 0.22;}
if (keyboard_check(key_Left)) {hspeed -= 0.22;}
//Keys release
if (!keyboard_check(key_Left)) and (!keyboard_check(key_Right)) {
{if (hspeed > 0) {hspeed -= 0.22;}}
{if (hspeed < 0) {hspeed += 0.22;}}
}