Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Sprite menu syncing

Author
Message
thechew
20
Years of Service
User Offline
Joined: 20th Feb 2006
Location: under there
Posted: 25th Jan 2013 22:53
I have written a game that has a menu system that uses sprites. With the game I have made a program to help edit data for the game. There can be many menus open at one time, but I kinda need to not sync through all the menus because it creates a massive lag. Is there a way to refresh certain sprites and still display all of them?

My sprite painting method:


no not that thechew guy again
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 26th Jan 2013 19:50
What do you mean by 'refresh certain sprites'?
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Jan 2013 22:50
It sounds like he wants to paste a sprite once then not have to update or clear that portion of the screen. And I think in QB that would be possible, but not in DB.

You should be able to paste hundreds of sprites without speed issues. I think the issue lies somewhere else in your code logic and not in the drawing operations.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Nytus Sermus
13
Years of Service
User Offline
Joined: 17th Jan 2013
Location:
Posted: 28th Jan 2013 05:51
what thechew is talking about is the fact that he has alot of interfaces and they are all checking for mouse-over, mouse click functions and that is where the lag is, not in the sprites.
I had started a project this way using sprites, but the mouse codes just wouldnt work right for me with sprites, i ended up just using images and image commands and doing away with sprites as menu buttons.
@ TheChew: if you want to speed your program up and still use all of your graphics then i suggest you split your program up differently, call one function first that checks for the mouse moving over the buttons, once the mouse is found to be over any one certain button, the routine should end; obviously your not going to be over 2 buttons at the same time.

The second function should then check the state of an array that is linked to your buttons (telling which on is off or on (0, 1)), that way only one button has to be detected, and you can simply set the state of the onscreen images according to this array, which is much faster because only the button that is over or on will actually execute any instructions,.... just saying..
use an array like:

dim buttonstates(300) `for the number of buttons you need

Hope this helps.

You could be done already.....stop trying to re-invent the wheel.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Jan 2013 13:55
There's no need to have an array that stores states. Just add a state variable to your button type. It sounds like thechew is trying to lock out sprites that don't need checking/updating. This is simply a bounds check on the parent of it's children, meaning whatever buttons extra are attached to. You first check if you are within the bounds of say a window, if you are then you only check/update the buttons extra of that window, this again being another bounds check.

But more to the point is that code you've got there, I can see many things that will slow you down incredibly, the main one being Set Text Font. That alone will kill FPS. The second one being that you keep loading the same images over and over and lastly constantly creating and deleting sprites will slow you down also.

Login to post a reply

Server time is: 2026-07-07 09:51:53
Your offset time is: 2026-07-07 09:51:53