• 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!

Help Me With A Bug[SOLVED]

P

Paulo Henrique

Guest
I've made the code for make the player move and the colision, but when I pute the sprites and made a code for change them bugged my game, the player flickers for a opposite side for the button pressed, like I press the D for move right them the sprite flicker for the left and right and don't move, this Is the code:
if (!place_meeting(x,y+1,obj_wall))
{
sprite_index = spr_player_JumpRuning;
if (sign(vspd) > 0.5){ sprite_index = spr_player_JumpFall;} else{ sprite_index = spr_player_JumpRuning;}
}
else
{
if (hspd != 0)
{
sprite_index = spr_player_walking;
}
}

if hspd = 0{
if place_meeting(x,y+1,obj_wall) {
sprite_index = spr_player_idle;
}
}

if hspd != 0 {
if place_meeting(x,y+1,obj_wall)
{
sprite_index = spr_player_walking;
}
}
 

sinigrimi

Member
if (!place_meeting(x,y+1,obj_wall))
in this place of the code you should add "and keyboard_check (ord (" D ")). Instead of" D ", any one of your choice. Otherwise, if there is no wall at y + 1 (at the bottom), your sprite will be spr_player_JumpRuning, also in others code variations you change the sprites but your scripts are not a substitute for each other "if it is, then this" they act simultaneously. Also, if the sprites are the same size but they jump to the right when the probability is high that you pointed them different centers.
 
P

Paulo Henrique

Guest
Hey man ty for awnser but not solve my problem, i think i discovered the problem but i don't know how to solve, when my player isn't walking him "stuck" in the ground, but when i jump and start moving isn't stuck, i think the problem is the idle sprite(My player sprite when him is not walking).
 

sinigrimi

Member
Hey man ty for awnser but not solve my problem, i think i discovered the problem but i don't know how to solve, when my player isn't walking him "stuck" in the ground, but when i jump and start moving isn't stuck, i think the problem is the idle sprite(My player sprite when him is not walking).
check your sprites centres
 

TheouAegis

Member
If this is a side-scroller, put all your origins at the bottom-center. What sinigrimi was getting at is the relationship between the origin of each sprite and the bbox_bottom of each sprite needs to be the same across all sprites. If you change to a sprite where the origin is higher or lower from the bbox_bottom than the previous sprite, you'll get stuck.
 

sinigrimi

Member
all the sprites is in middle center
Maybe I don’t understand everything (not a native speaker) when you have problems? during a collision or movement? and what does flicker mean? sprites change fast? In the code, I see that you have duplicates of “if hspeed! = 0 ". Also, “if vspeed> 0.5” does not contradict and does not replace “if hspeed = 0”, it turns out that two events can work simultaneously.
 
P

Paulo Henrique

Guest
Ty you two to awnser and help me, TheouAegis i put all the sprites in botton center them "solve" a little bit now they not flickler anymore but when i move the char and stop the char stuck whem i jump solve the problem until i stop them stuck again, sinigrimi i think in the collision is the problem but i explain is in the moviment and the collision to the theou flicker in that case is my char is changing fast the sprite for right and left but this is solved i remove the "if vspeed> 0.5" but not solve and try to recode and nothing my problem now is the char(player) stuck in the ground when i move them i jump to "solve" this until i stop my char stuck in the ground again.
 

sinigrimi

Member
Ty you two to awnser and help me, TheouAegis i put all the sprites in botton center them "solve" a little bit now they not flickler anymore but when i move the char and stop the char stuck whem i jump solve the problem until i stop them stuck again, sinigrimi i think in the collision is the problem but i explain is in the moviment and the collision to the theou flicker in that case is my char is changing fast the sprite for right and left but this is solved i remove the "if vspeed> 0.5" but not solve and try to recode and nothing my problem now is the char(player) stuck in the ground when i move them i jump to "solve" this until i stop my char stuck in the ground again.
if you have sprites of the same size and the same center everywhere but you are stuck in objects, then your collision code is not written correctly. Attach screenshots before and after getting stuck, and if there is a collision code, attach it too.

upd: and sprites have the same collision mask
 
Last edited:
P

Paulo Henrique

Guest
the second image is the char stuck and the first image is the char not stuck, you can see the feet is entering in the ground
 

Attachments

Last edited by a moderator:
P

Paulo Henrique

Guest
Holy man MANY THANSK to you two, I realize the problem is the sprite them i change and to botton center all and them worked really thanks
 
Top