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

Weird glitch (possibly?)

B

BladeGamez

Guest
So for some weird reason, my code was working a while ago and quit. So I toggled with it and managed to get something out of it. This time, however, instead of changing it to the correct sprite like it was supposed to, it flickered in between two other unrelated sprites. Now I toggled it again and it stopped working completely. What did I do wrong?

Code below
if keyboard_check (vk_shift) and keyboard_check (vk_right)
then
{
sprite_index = spritera;
}
else
{
sprite_index = sprite1;
}

if keyboard_check (vk_shift) and keyboard_check ("D")
then
{
sprite_index = spritera;
}
else
{
sprite_index = sprite1;
}
 

obscene

Member
Your second block overwrites your first. If you press right and 💩💩💩💩, it turns to spritera, but then immediately gets set back because you arent holding D.

Combine this all into one neat block...

if keyboard_check (vk_shift) && (keyboard_check (vk_right) || keyboard_check ("D"))
 
B

BladeGamez

Guest
Your second block overwrites your first. If you press right and ****, it turns to spritera, but then immediately gets set back because you arent holding D.

Combine this all into one neat block...

if keyboard_check (vk_shift) && (keyboard_check (vk_right) || keyboard_check ("D"))
This worked to an extent. The sprite will not change to spritera if I hold down D and shift now.
 
Code:
if keyboard_check (vk_shift) && (keyboard_check (vk_right) || keyboard_check ("D")) && keyboard_check (vk_shift)
Will fix that, though, that is such a trivial fix that you should be able to see it by yourself. When you get example code from the forums, make sure to actually read through the code and piece together what it is doing in your head instead of just copy+pasting.
 
B

BladeGamez

Guest
Code:
if keyboard_check (vk_shift) && (keyboard_check (vk_right) || keyboard_check ("D")) && keyboard_check (vk_shift)
Will fix that, though, that is such a trivial fix that you should be able to see it by yourself. When you get example code from the forums, make sure to actually read through the code and piece together what it is doing in your head instead of just copy+pasting.
Whoops, my bad. I've been up for hours working on this...
 

obscene

Member
I can't see the mistake no matter how hard I look. Two shift checks shouldn't be necessary if you say...

if shift && ( right || D )

If that's didn't work I'm missing why.
 
It's saying:

If Shift AND Right are pressed, I will execute the statement
OR if D is pressed, I will execute the statement

So you can see from that statement, it is not checking if Shift AND D are pressed.
 

obscene

Member
Nope... the parenthesis are right....

upload_2017-6-27_17-12-5.png

However I just realized I forgot to put ord("D") which I think might be the problem.

So in the end I'm still a loser :p
 
B

BladeGamez

Guest
Yeah, I noticed that mistake. I had to do a new method anyways because that algorithm did not work when I put a self-created variable in it.
 
Top