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.

2D All the way! / Increase sprite paste speed?

Author
Message
JoeOh
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 5th Dec 2010 09:29
I was just testing out my current computers speed with sprites and I have this code running a simple sprite program and I'm only getting 30 fps.



What am I missing to speed up the sprites being pasted to the screen? If there is another thread addressing this please point me to it. I did a search before posting this and came up with squat.

Thanx

Home is where my souped-up computer is...
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 5th Dec 2010 22:05 Edited at: 5th Dec 2010 22:06
Are you using DBPro or DBC?

For DBPro if you want faster sprite output you can try the Advanced Sprites plugin, it speeds it up 3~4 times faster IF used properly. Find it under the A section, you cant miss it! http://forum.thegamecreators.com/?m=forum_view&t=92836&b=5

For DBC check out this: http://forum.thegamecreators.com/?m=forum_view&t=143735&b=10

JoeOh
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 6th Dec 2010 08:36
I do have DBPro and downloaded and installed the Advanced Sprites Plugin. There is a considerable speed increase when running the AdvancedSPRITES_versus program with a difference of 24fps vs 189fps using 3000+ sprites.

I am very please with the results, thanks for pointing me in the right direction. Now lets hope this plug-in is easy to use and super-stable (I'm sure it is, but I been fooled before ).

Home is where my souped-up computer is...
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 7th Dec 2010 03:39 Edited at: 7th Dec 2010 03:42
This plugin takes a bit more work to get to work. Depending on how you code, it can turn out with awesome results or end up worst than the DB sprites.

Here's a run down tutorial if you would care.

Create a green tile image and plot it 10x10 tiles on the screen:


Now take note that the DXS SPRITE RENDER statements are fairly slow so you want to call it as few times as possible and draw as many sprites as you can within it. So this example here will give you a worst fps rate:


If you have multiple sprites you cannot draw one sprite inside another sprite's render call:


But if you create a SpritePack you can draw as many different sprites in a single render call as you like, just make sure to add the sprite to the SpritePack:


Lastly here is a working example:


JoeOh
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 7th Dec 2010 10:28
I've been wondering on how to use the Sprite Packs to use more than just one sprite over and over. Your examples clears things up nicely. Thanks for the codes

Home is where my souped-up computer is...
JoeOh
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 9th Dec 2010 15:07 Edited at: 9th Dec 2010 15:14
One more thing...

How do I do make sprites with transparent spots (I don't mean alpha) work with Advanced Sprites?

[EDIT]:

Nevermind, I went ahead and added a transparency layer to my bitmaps and it worked just fine.

Home is where my souped-up computer is...
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 10th Dec 2010 00:48
That's good you figured it out. I'd normally just use a format with transparency like .png or a solid color then use SET COLORKEY r,g,b or edit the sprite pixels individually.

If you have any other questions regarding sprites or 2d in general I might be able to answer it.

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 10th Dec 2010 05:35
While we are on this subject there is a way to greatly increase your performance if you plan to use tile-based maps. The objective is to draw the tile map as few times as possible by drawing it once into a BITMAP(drawing surface, not the .BMP format) and copying it over to the screen. You may also save the drawn tile map into an image and paste that too but Bitmap copying is so much faster than image grabbing.


Here's another fast tutorial:
1. Lets make an example terrain tileset to use in this example:


2. Now we make an Advanced Sprite of the tileset 10x10 tiles and draw a single random frame to a random coordinate on the screen:


3. Next we make a terrain array and fill the screen with the map:
The last example still has a fast fps rate because it was only drawing 1 sprite each loop but notice when you are now drawing 40x30=1200 sprites per loop, the fps drops greatly!

4. To speed this up we create a bitmap, draw the terrain on it once and copy it over every loop instead of drawing all 1200 sprites:


JoeOh
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 12th Dec 2010 00:42
Got another question, why can't I seem to use the DSX SPRITE commands in functions? I hope I'm doing something wrong, but every time I run my program with a DSX SPRITE command in a function after the "end" of the program, the program just crashes out on me when it begins to run.

Whats the deal?

Home is where my souped-up computer is...
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 12th Dec 2010 03:00 Edited at: 12th Dec 2010 03:01
Are your variables global, or stored in structures that are globally addressable like an array/types ? - If not, then likely cause

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 12th Dec 2010 04:06 Edited at: 12th Dec 2010 04:08
Yes it's just as Kevin Picone says. When you are using a function it has it's own set of local variables so you can have a variable with the same name in and out of a function and it stores different values:
This will print 360 first then 0.

I sometime use globals but majority of the time I use #constant variables in conjunction with arrays.


JoeOh
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 12th Dec 2010 18:21
Ashingda's second example did the trick. I just assumed the sprite pointers were automatically global. I guess they all have to be manually globalized.

Perhaps a new command such as "GLOBALIZE ALL SPRITES" is in order?

Home is where my souped-up computer is...

Login to post a reply

Server time is: 2024-03-29 08:01:30
Your offset time is: 2024-03-29 08:01:30