I have a rectangle which is bouncing on the screen. I want it to occur in 8 steps instead of being continuous

Please help me with this question!!!

I don’t fully understand

its like rectangle is touches the bottom end of the screen and bounce back to the top and vice versa.
I want this process to occur in 8 steps instead of being continuous. Like the rectangle should take 8 equal steps from top to botton!!!

You could add -100 to y and instead of 1

And lower the frameRate()

without using framerate

With a timer then?

Chrisir

@bellievr, Not seeing any code or attempt at solution.
Please read the guidelines regarding asking for help with homework:

https://discourse.processing.org/faq#homework

1 Like

i am not aiming at answer.Its just a help to complete my work…They are not providing me the code.The are just giving instruction

However you are not showing any code to help people understand your level of understanding. You are only outlining the problem you have been asked to solve. Please share your thought process if you want help.

I wish i could but i m not allowed to share my code!!!

I see.
Well, since you can’t share your code, perhaps someone can give you some general advice…
Or you could outline things you have tried, without the code…

yes i could outline the things !!
i have made a rectangle on the top right edge of the screen .
It moves down and reverses it direction when hits the bottom of the screen
just like https://www.youtube.com/watch?v=YIKRXl3wH8Y&feature=emb_logo
but in this video it moves left to right but in my code it moves top to bottom .
i just want that it should move in 8 steps from top to bottom instead of being continous…
Also my rectangle stops when space bar is pressed.

And what have you tried in order to solve the problem?
You only state what you want the final result to be.

i tried using
DownCounter=DownCounter%8;
DownCounter++;
but doesnt work!!

When you have tried something then show your entire code

What’s the y value variable for your rectangle?

say y=y + (height-20)/8;

OR with - here

I think I understand your question and your problem. The DownCounter variable you are using right now looks like it should work. With an if statement that checks when it is 0, you could move it by one step. The %8 you have there doesn’t mean how many steps, but after how many frames to go up one step. To get the 8 desired steps, maybe use a step variable that you set to height/8 so that it will divide the entire height into steps of 8. If you then just multiply the step variable by -1 when the Y value reaches the top or bottom of the screen, it should work.
I hope this helps, if not, please put the code that isn’t working in your reply, so we can see what you are missing.

2 Likes

Hello,

I encourage you to review the resources available here:

To get you started:
https://processing.org/examples/ Check out the section on motion.

:)