Page 1 of 1

need help please

Posted: June 24th, 2017, 5:47 pm
by EX_JEDEYE
hey just started coding and i'm following Chilis tutorial on youtube just need a little help i'm wondering why my crosshair isn't moving dynamically when i set int x and y into the game.h file when i build the crosshair moves into different directions but it just sits there any suggestions? cheers.

Re: need help please

Posted: June 24th, 2017, 5:55 pm
by ceofil
Hi!
Can you paste your code in here or post a screenshot?

Re: need help please

Posted: June 24th, 2017, 5:55 pm
by Zedtho
"when i build the crosshair moves into different directions but it just sits there any suggestions?"
So, when you build, your crosshair moves into a different direction and it just sits there?

If you want us to help, sending the code in an attachment would be very much appreciated for further analysis! At the moment it is slightly hard to find out what the bug is.

Re: need help please

Posted: June 24th, 2017, 6:08 pm
by EX_JEDEYE
oh sorry guys didn't know i could do that but it's ok now i just had to change my wnd.kbd.KeyIsPressed() x and y it looked like this

if (wnd.kbd.KeyIsPressed(VK_UP))
{
y = 100;
}

but changed it around

if (wnd.kbd.KeyIsPressed(VK_UP))
{
y = y + 5;
}

something like that. its ok now though cheers for the support.

Re: need help please

Posted: June 24th, 2017, 6:51 pm
by Zedtho
Yep, that looks like the right answer.

Good luck on your journey! Feel free to ask stuff! It might look like a lot of work to find such a bug yourself, but for people that already have encountered that bug it's pretty easy :D

Re: need help please

Posted: June 24th, 2017, 6:55 pm
by Yumtard
EX_JEDEYE wrote:oh sorry guys didn't know i could do that but it's ok now i just had to change my wnd.kbd.KeyIsPressed() x and y it looked like this

if (wnd.kbd.KeyIsPressed(VK_UP))
{
y = 100;
}

but changed it around

if (wnd.kbd.KeyIsPressed(VK_UP))
{
y = y + 5;
}

something like that. its ok now though cheers for the support.

Yep that looks correct.
In your first example you're simply setting the y position to 100. So in the next frame the y position will be 100. In the second example you're adding 5 to the value of y. So whenever you're pressing the key, 5 will be added each frame to the value of y

say y = 100

y = y + 5;
now y = 105
//next frame
y = y + 5;
now y = 110 and so on.