Grabbing sprites

Advanced game related topics
dger
New User
New User
Posts: 7
Joined: Sun Aug 27, 2017 12:38 pm

Grabbing sprites

Post by dger »

Hello to all,
I noticed that grabbing many sprites (about 300), even if used only a part, the screen refresh slows down. How is it possible?

I have a medium power computer (core i7, HD4000) so I do not understand how it is possible ...

I used sprite as tile to draw the screen, is this approach correct?

Many thank's.
User avatar
Fig
Enthusiast
Enthusiast
Posts: 348
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: Grabbing sprites

Post by Fig »

It has nothing to do with your hardware, grabbing 300 sprites is probably the wrong way to go.

If you use these grabbings to create tiles, you probably should do it before the main loop of your game.
But it's hard to say without any code to know for sure what you are doing wrong...
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
dger
New User
New User
Posts: 7
Joined: Sun Aug 27, 2017 12:38 pm

Re: Grabbing sprites

Post by dger »

Fig wrote:It has nothing to do with your hardware, grabbing 300 sprites is probably the wrong way to go.

If you use these grabbings to create tiles, you probably should do it before the main loop of your game.
But it's hard to say without any code to know for sure what you are doing wrong...
Hello,
thank you very much for your reply.
Actually the grab is done outside the main loop, which is why I'm a bit confused.

My game is 3000 lines so it is a bit difficult to extract a piece of code to show the problem, but I will try asap ...
User avatar
IceSoft
Addict
Addict
Posts: 1508
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: Grabbing sprites

Post by IceSoft »

Small hint:
Don't call this" outside procedure" in the game loop ;-)
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
dger
New User
New User
Posts: 7
Joined: Sun Aug 27, 2017 12:38 pm

Re: Grabbing sprites

Post by dger »

IceSoft wrote:Small hint:
Don't call this" outside procedure" in the game loop ;-)
No, I do not call that procedure from within the main loop, it's one of the first things I've checked.

However, I write a very basic example of my loop, grabbing 1000000 (one million) sprite and I have a rock solid 60fps. So, I'm doing something really wrong, that I can not find.

I think I have to start from scratch.
User avatar
Fig
Enthusiast
Enthusiast
Posts: 348
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: Grabbing sprites

Post by Fig »

At less you can conclude: grabbing sprites outside main loop is not the issue you are looking for...
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
dger
New User
New User
Posts: 7
Joined: Sun Aug 27, 2017 12:38 pm

Re: Grabbing sprites

Post by dger »

Fig wrote:At less you can conclude: grabbing sprites outside main loop is not the issue you are looking for...
The strange things is that more sprite I grab more slower is the refresh, then is somethings sprite related. Main loop is 500 lines, so I I have to work a lot to figure out the bug...... :)

Thanks guys
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 105
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: Grabbing sprites

Post by bfernhout »

Hey.

I think that your problem is not the program or the way you program. I think its more the memory you have. How big is it. If you have e.g. 4 GB With a 64 bits system. Then you program wil slow down at a point of amounts of sprite you use.

I have a example from Jamie who made 39000 cubes in a 3D world. And let it rotate. Building the cubes takes on his system like 25 seconds. and then every rotation move takes 1 sec. On my system the startup time takes 5 sec and the rotation of the cubes take a good 60 FPS. But his sytem is win 10 64 bits but 8 gb. My system is win 10 64 bits I.7 and 32 GB Actual using 28 GB the rest is in reserve????.

Anyway A second idea can be how big are the sprites. The bigger the sprite the more internal memery you need. Unles you make child sprites than the amount of memory is less.

An idea is, try turn of some parts of the program. And try to find the time the loop takes. Exclude differend parts en see what happend with the cycle time. A large main loop must not make the differend. Maybe there is a piece of the program that do something that takes up to many time.


Bart.
From my first self made computer till now I stil like computers.
Post Reply