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 Discussion / Sprites using planes?

Author
Message
Naisoft
21
Years of Service
User Offline
Joined: 24th Jan 2005
Location:
Posted: 7th Jul 2006 04:16
Hey everyone,
I have been working on a DBC version of the arcade game Stacker for the past few hours. I finally finished most of the code, and then I went to test it. Sadly, it only ran at 2 fps, and my laptop can handle much more than that. After reading the thread on how to speed up your games, I found out that the DBC sprite engine is slow, and that I could try using planes instead. Would anybody be able to give me an example of how to do this while still being able to use X/Y coordinates? I have attached the source.
Thanks

I'm pilotianh
Zelda Mario Yoshi and Samus ROCK!!
D Ogre
22
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 7th Jul 2006 04:54
For 2D sprites, make sure you set the backsave state to off and update
the screen manually with CLS. This will speed up your game.

To do this use:

Set Sprite sprite number,0,0
or

Set Sprite sprite number,0,1 for transparency
Naisoft
21
Years of Service
User Offline
Joined: 24th Jan 2005
Location:
Posted: 7th Jul 2006 05:32
Thanks for the fast reply. I tried both of those, but I only get a measly 5 fps now. Can someone explain another way to speed it up using sprites or 3d planes? The game pastes a picture in the background and draws 105 sprites every frame.
Krilik
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Arizona, USA
Posted: 7th Jul 2006 13:42
Your problem isn't that you need a faster way of drawing sprites. You're drawing too many sprites. Here is the code you need to revise:

What's happening is the program keeps creating an increasing amount of sprites. Eventually your program will crash because the sprite number will be out of range (1 to 65535). You need to either delete sprites you're not using somewhere in your loop, or reset the variable spritecount, so you reuse some of the sprites that aren't being used.

The above suggestion will also improve sprite drawing significantly.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Jul 2006 14:33 Edited at: 7th Jul 2006 14:34
Just an idea.

Try

ran on about 29 fps on my pc

I don't really get what the objective is of the game...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 7th Jul 2006 17:51
DB classics 2D performance isn't really not suited to such games. You could use planes but then the texture overhead will equally come into play. But certainly worth a try.

A better option would be to build such games in PlayBasic. The syntax is very similar so porting the code is quick and easy. For example, I did a port of the code you posted above and it runs at 115 fps on my Duron 800 mhz test machine.

NeX the Fairly Fast Ferret
21
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 7th Jul 2006 19:18
Shameless plugger. Darkbasic Pro is pretty fast though, and I can fill the screen with transparent PNG paste image sprites, and still keep 170 FPS. Nothing wrong with that at all.

<OMG></OMG>
NeX, you cant be serious - CattleRustler.
Naisoft
21
Years of Service
User Offline
Joined: 24th Jan 2005
Location:
Posted: 7th Jul 2006 19:47
Wow, thanks everyone. I can't believe I forgot to reset the spritecount. I get smooth gameplay now

Sig pic coming soon....

Login to post a reply

Server time is: 2026-07-06 18:36:05
Your offset time is: 2026-07-06 18:36:05