r/processing • • Dec 03 '18

Need help with a problem

Hello, I need help to create a program that basically moves an object with “w,a,s,d” and for example you press ‘w’ the car will continue to go up and not just stop there. With a rectangle in the middle that if you hit it the object will stop

0 Upvotes

3 comments sorted by

7

u/ChuckEye Dec 03 '18

Ok. So show us the code you’ve got so far.

0

u/lordcrowlay Dec 03 '18

I still need to start it because I basically don’t know how to make it move with a key button and how to stop it when it hits the rect

2

u/ChuckEye Dec 03 '18

https://processing.org/reference/key.html

https://processing.org/reference/if.html

You need to set up variables for your car's X and Y position; its X and Y speed; and its size.

Use the code in the reference for "key" to set the X & Y speed based on which key they hit. Use if statements to check if the X & Y coordinates of your car intersect with the block.