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

GameMaker What am I doing wrong ?

B

Bilbo

Guest
Hello guys,
so basically im using this code:
if (keyboard_check(vk_right))

x = x + 4;

if (keyboard_check(vk_left))

x = x - 4;
but my problem is, that when I move the object it draws itself there. I basically have my sprite all over my room. Could anyone help ?
Thanks in advance
 
P

PhenomenalDev

Guest
What's the complaint with it drawing? It's meant to. Btw your codes a bit unoptimised it should be:

if (keyboard_check(vk_right))
{x += 4}

if (keyboard_check(vk_left))
{x -= 4}
 

dphsw

Member
Do you mean you're ending up with lots of copies of your sprite drawn all over the room?

If so, then the problem is somewhere else other than this code. The first thing I'd suggest is to make sure that 'Clear Display Buffer' is ticked in your room settings.
 
B

Bilbo

Guest
What's the complaint with it drawing? It's meant to. Btw your codes a bit unoptimised it should be:

if (keyboard_check(vk_right))
{x += 4}

if (keyboard_check(vk_left))
{x -= 4}
But what can I do if I dont want it to draw ?
 

Xer0botXer0

Senpai
Disable the objects sprite, enable it's mask if required.
Draw the sprite using the draw event at specified location therefore even if your object moves your sprite will remain in it's position, according to what you want.

If that's not right, then you need to be more clear on what you're looking for, perhaps an explanation of what you're trying to achieve.
 
B

Bilbo

Guest
Disable the objects sprite, enable it's mask if required.
Draw the sprite using the draw event at specified location therefore even if your object moves your sprite will remain in it's position, according to what you want.

If that's not right, then you need to be more clear on what you're looking for, perhaps an explanation of what you're trying to achieve.
Im trying to move an object left and right but it " copys " itself on its position
 
Top