Best way to do lots of moving things on screen?

Discuss any general programming issues here
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Best way to do lots of moving things on screen?

Post 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?
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post by airsoftsoftwair »

For maximum performance you should use a plugin that offers hardware-accelerated drawing, e.g. RebelSDL or GL Galore.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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?
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post 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.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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?
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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?
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

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

Post by Bugala »

Just read that manual a bit. Never realised how much difference one single line can make. Very handy.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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?
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

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

Post 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.
Post Reply