Page 1 of 1

need help!! Beginner mistake. but can't find it.

Posted: October 28th, 2017, 2:10 pm
by kHimanshu
I just started beginner game development series.
i made one reticle big and it changes shape to a small one after releasing shape key.
i made it so that it won't crash when they reach edge of framework.
But whenever i release my shape changing key(Shift key) at the edges of framework my program crashes.
HELP PLEASE.
i have attached my files.

Re: need help!! Beginner mistake. but can't find it.

Posted: October 28th, 2017, 4:23 pm
by Yumtard
Your problem is your placement of this line

ShapeKeyIsPressed = (wnd.kbd.KeyIsPressed(VK_SHIFT));

Remember that the code in the update function will be read from the top down. Go over your Update function and see if you can figure out why the placement of that line causes an issue and why moving it to some other place will solve the issue ;)

Re: need help!! Beginner mistake. but can't find it.

Posted: October 28th, 2017, 4:29 pm
by kHimanshu
Yumtard wrote:Your problem is your placement of this line

ShapeKeyIsPressed = (wnd.kbd.KeyIsPressed(VK_SHIFT));

Remember that the code in the update function will be read from the top down. Go over your Update function and see if you can figure out why the placement of that line causes an issue and why moving it to some other place will solve the issue ;)
Thank you very much!!! it worked.
but why it caused the issue?

Re: need help!! Beginner mistake. but can't find it.

Posted: October 28th, 2017, 5:02 pm
by Yumtard
1. the code that makes sure the reticle isnt outside of the screen gets executed
2. the code changing the shape of the reticle gets executed. (going from a small reticle at the edge of the screen to a big one means that it will now be outside of the screen.
3. your reticle is drawn

can you see how flipping the order of 1 and 2 would solve the issue?

Re: need help!! Beginner mistake. but can't find it.

Posted: October 28th, 2017, 5:46 pm
by kHimanshu
Yumtard wrote:1. the code that makes sure the reticle isnt outside of the screen gets executed
2. the code changing the shape of the reticle gets executed. (going from a small reticle at the edge of the screen to a big one means that it will now be outside of the screen.
3. your reticle is drawn

can you see how flipping the order of 1 and 2 would solve the issue?
thank you very much i understood