Forum > Games

Simple ball bounce

<< < (2/6) > >>

440bx:

--- Quote from: speter on February 01, 2022, 08:30:56 am ---In case anyone is interested, here is a GUI version of BobDog's code.

cheers
S.

--- End quote ---
Nice, thank you.

There are a couple of things that you might be interested in knowing. 

Attempting to enlarge the window while the balls are bouncing fails and, after the attempt, for some reason, it seems impossible to switch to another app. the only way I found to switch to another app is to use Alt-Tab (on Windows)

The other thing is, the app won't close after clicking on the "X" or selecting close from the system menu.  Looks like processing some events isn't happening.  I suspect this is likely caused by having the GUI thread be responsible for painting the balls in addition to processing events.

Last thing, the larger the window is, the slower the balls move. It would be nice if the speed was related to the size of the window.

I'm sorry but, when I watch paint dry I insist on good paint... if I'm going to watch balls bouncing, they have to bouncing right... otherwise might as well watch TV. ;)


speter:

--- Quote from: 440bx on February 01, 2022, 11:00:15 am ---Attempting to enlarge the window while the balls are bouncing fails and, after the attempt, for some reason, it seems impossible to switch to another app. the only way I found to switch to another app is to use Alt-Tab (on Windows)
--- End quote ---
I didn't have either of these problems (win11; Laz 2.2).


--- Quote ---The other thing is, the app won't close after clicking on the "X" or selecting close from the system menu.  Looks like processing some events isn't happening.  I suspect this is likely caused by having the GUI thread be responsible for painting the balls in addition to processing events.
--- End quote ---
I did notice this problem. I've added an event handler for form-close, which fixes it for me...


--- Quote ---Last thing, the larger the window is, the slower the balls move. It would be nice if the speed was related to the size of the window.

--- End quote ---
I am not totally sure what you mean here! BUT, I did notice the balls were quite slow moving!
I've tweaked the code, which makes it "much" faster - though the balls still bounce at a leisurely pace  :P on my laptop.

Another problem I saw (and fixed) was the program seemed tio be drawing the old circle in black to remove it (I was referring to Paintbox1.canvas.color when I should have used Paintbox1.color).


--- Quote ---I'm sorry but, when I watch paint dry I insist on good paint... if I'm going to watch balls bouncing, they have to bouncing right... otherwise might as well watch TV. ;)

--- End quote ---
I am using the very best pixels available. :o  :D

cheers
S.
PS: I've attached an updated project.

440bx:
There is a definite improvement in the new version.

I still experience the first problem I mentioned.  If I attempt to enlarge the window while the balls are bouncing around then, the only thing that gets the interface back to normal is to Alt-tab.


--- Quote from: speter on February 01, 2022, 12:36:03 pm ---I am not totally sure what you mean here! BUT, I did notice the balls were quite slow moving!
I've tweaked the code, which makes it "much" faster - though the balls still bounce at a leisurely pace  :P on my laptop.

--- End quote ---
you can see the difference in speed by doing these two steps.  First step, start the application just as you posted it and notice the speed at which the balls move.  Second step, make the window/form about twice as large in both directions, horizontal and vertical, recompile and run again.  You'll notice that in the larger window the balls  move at a fraction of the speed they did in the smaller (original size) window/form.



--- Quote from: speter on February 01, 2022, 12:36:03 pm ---PS: I've attached an updated project.

--- End quote ---
I attached the updated project to my CPU :)

Josh:
Hi

Had a play and made some little changes,
draws on timage, using buffered bmp for speed,
increased to 50 balls, altered so balls move at a quicker pace, attempt to get 50fps inside loop by calculating time to draw and adjusting params, this stops the cpu high load hopoefully, fixed close issue.

Josh:
Added background color change

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version