Page 1 of 5

Best way to do lots of moving things on screen?

Posted: Wed Jun 12, 2019 10:07 pm
by Bugala
I am planning on participating on Speedgame 2019 again, and I have a game idea already, but I am bit worried of it currently, for I am worried how can i make it to run with good FPS rate.

Look at this video about Atom Zombie Smashers gameplay: https://www.youtube.com/watch?v=YL1p57PdkCU

As you can see, there are whole load of rectangles moving around at screen. I am basically thinking the same, although I have been thinking of using different sized and colored balls instead, but if necessary, can change it into same colored rectangulars as well.

My question is, how should I do those Rectangulars to keep the FPS best possible, or at least decent.


So far my thoughts are following. Using multiple BRUSHES is probably out of question, I suppose that would be slow, or?

However, what about I have one big brush, size of a screen, and then i draw all those rectangles to that big brush each frame, and then I am basically just drawing one big brush to the screen?

Or what about if I actually use the rectangle command to actually draw the rectangles to screen each time, and then clear the whole screen and draw all those rectangles again to their new locations? (using the map as background picture to not get rid of the background)


Or what would be best way to do it?

Re: Best way to do lots of moving things on screen?

Posted: Thu Jun 13, 2019 7:20 pm
by airsoftsoftwair
For maximum performance you should use a plugin that offers hardware-accelerated drawing, e.g. RebelSDL or GL Galore.

Re: Best way to do lots of moving things on screen?

Posted: Thu Jun 13, 2019 8:49 pm
by Bugala
Thought something like that. I guess it is time for me to take a try on that world.

But If i want say 100 moving balls and 100 moving rectangles, is this still doable with unplugged Hollywood features, or will it be too slow even for modern computers? Or lets say 1000 moving balls and 200 rectangles, what about then?

I think I will take a look at plug in, but asking just in case anyway.

Oh, and what about differences between GL Galore and RebelSDL, what are the main differences between these two?

@ALLANON, which one are you using and why?

Re: Best way to do lots of moving things on screen?

Posted: Fri Jun 14, 2019 7:29 pm
by airsoftsoftwair
Bugala wrote: Thu Jun 13, 2019 8:49 pm Oh, and what about differences between GL Galore and RebelSDL, what are the main differences between these two?
GL Galore offers direct access for OpenGL programming. For pure 2D RebelSDL is the best choice.

Re: Best way to do lots of moving things on screen?

Posted: Sat Jun 15, 2019 11:27 am
by Bugala
So in this case RebelSDL sounds like better option, but then, I have been wanting to give 3D a try too, so I wonder if I should try GL Galore after all to be familiar with it for future 3D project?

Is it better to just learn one, or should I learn both? Like Rebel for 2D and GL for 3D? Also, any difference with compatibility between machines, that both work fine on supported platforms or some difference somewhere?

Re: Best way to do lots of moving things on screen?

Posted: Sat Jun 15, 2019 11:30 am
by Bugala
Oh, and one more thing. Is one or other easier to use than other, especially when going for first time?

Basically I guess I will be using only very simple commands, so I guess might not make much difference there.

Re: Best way to do lots of moving things on screen?

Posted: Sat Jun 15, 2019 1:10 pm
by Bugala
I chose to go for RebelSDL based upon some small googling of SLD vs Open GL.

But a question rises now that I dont have time to check more at this point yet.

I checked this "BeastScroll" example from RebelSDL examples, and as far as I can see, only difference to regular Hollywood code is: "@REQUIRE "rebelsdl""

So does this mean that if I use hardware Brushes, then just by using RebelSDL plug in, it will already be enough? That I dont need any specific RebelSDL commands to do things?

Re: Best way to do lots of moving things on screen?

Posted: Sat Jun 15, 2019 9:23 pm
by Bugala
Just read that manual a bit. Never realised how much difference one single line can make. Very handy.

Re: Best way to do lots of moving things on screen?

Posted: Sat Jun 15, 2019 9:49 pm
by Bugala
There might be error in manual, on 3.1 at "ForceFullRefresh" it says "This is slower but guarantees that there will be visual artefacts because front and back buffers will always be completely in sync."

I guess it should say it guarantees that there WONT BE visual artefacts?


Then couple of questions regarding RebelSDL.

Can I use Layers and Buttons as usual with RebelSDL? That although I wont gain benefit from for example brushes unless using hardware brush=true setting, I suppose Layers and Buttons wont have any benefit either, but at least I can anyway use them?

That User Interface could use Buttons, while Brushes would all be hardware brushes, by other words, there be parts that RebelSDL can make the enhancements to, and other parts where it cant?

And I suppose if I have a game where you push buttons to do things, like lets say I have a space shooter that fully takes advantage of RebelSDL hardware brushes, but to move the ship, I would need to use layer buttons to push "left", "right", "shoot" as example, I suppose just those three buttons wouldnt really slow the game down too much, if all the rest is running in hardware brushes anyway?

Re: Best way to do lots of moving things on screen?

Posted: Sun Jun 16, 2019 11:42 am
by airsoftsoftwair
Bugala wrote: Sat Jun 15, 2019 1:10 pm So does this mean that if I use hardware Brushes, then just by using RebelSDL plug in, it will already be enough? That I dont need any specific RebelSDL commands to do things?
Yes, it's magic :) Putting that line @REQUIRE RebelSDL at the top of your script will automagically replace Hollywood's default display adapter by a one based on SDL, only Hollywood makes it possible :)
Bugala wrote: Sat Jun 15, 2019 9:49 pm There might be error in manual, on 3.1 at "ForceFullRefresh" it says "This is slower but guarantees that there will be visual artefacts because front and back buffers will always be completely in sync." I guess it should say it guarantees that there WONT BE visual artefacts?
That's right, fixed now.
Bugala wrote: Sat Jun 15, 2019 9:49 pm Can I use Layers and Buttons as usual with RebelSDL? That although I wont gain benefit from for example brushes unless using hardware brush=true setting, I suppose Layers and Buttons wont have any benefit either, but at least I can anyway use them?
Yes, you can use layers but it somehow defeats the use of RebelSDL. It might even be slower than without RebelSDL! If you want to use RebelSDL for maximum performance, you need to use a hardware double buffer and hardware brushes. Buttons don't impact the performance in any way.
Bugala wrote: Sat Jun 15, 2019 9:49 pm And I suppose if I have a game where you push buttons to do things, like lets say I have a space shooter that fully takes advantage of RebelSDL hardware brushes, but to move the ship, I would need to use layer buttons to push "left", "right", "shoot" as example, I suppose just those three buttons wouldnt really slow the game down too much, if all the rest is running in hardware brushes anyway?
That won't work because you can't combine hardware brushes and layers. Hardware brushes can only be used together with a hardware doublebuffer which cannot be combined with layers. The best idea is probably to implement button handling on your own, it's not that difficult after all.