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! / TONS of moving pixels

Author
Message
GeeB
22
Years of Service
User Offline
Joined: 9th Jul 2003
Location:
Posted: 22nd Aug 2004 09:55
Im trying to make a little demo with a lot of pixels moving around and building up at the bottom of the screen. I'm not to sure if the way i'm doing it is the best way. The framerate drops way to quickly when there are alot of pixels falling. Can sombody please have a look at it and see if they can find a way to make it run faster. I know it's possible. I've included the source.
Thanks.
the_winch
23
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 23rd Aug 2004 02:46 Edited at: 23rd Aug 2004 03:01
Proberly won't make any noticable difference, but you are using rgb(0,0,0) a lot. Instead of calculating the colour each time you can store it in a variable and compare against that variabe.

global _black as integer
_black = rgb(0,0,0)

Then to compare
if memblock dword(1,(px*4)+(py*4*640)) <> _black
instead of
if memblock dword(1,(px*4)+(py*4*640)) <> rgb(0,0,0)

I can't remember if DOT commands are sped up by locking the pixels fist. You could try moving the UNLOCK PIXELS command to just above the text command in the main loop so the DOT command is done with the pixels locked.



Perhaps precalculate some of the often done calculations. You multiply by 640*4 a lot. You could either use 2560 or stick the result in a variable and mulitply by that instead of calculating 640*4 thousands of times a second.

Most of the slowdown is comming from copying all the memory to the screen each looop.
It might be faster to use a proper image memblock, do all manipulation on that memblock and paste it to the screen each loop but I don't know for sure.

shrink those dbpro exes
Create patches for your dbpro games
GeeB
22
Years of Service
User Offline
Joined: 9th Jul 2003
Location:
Posted: 23rd Aug 2004 03:18
Thanks for the help, i'll try some of that and see what happens. I don't know if any of you have ever played the game Jetmen Revival, but if you've seen it I think you'll get at the kind of effect i'm going for. I'm trying to figure out if somthing like this is even possible in DB. The game is just amazing, seeing 500+ pixels moving around and colliding with other objects. Have any of you achived something like this in DB or for that matter in any language? I'd really like to know how this is acomplished. I anybody has any ideas please post!
Thanks.
GeeB
22
Years of Service
User Offline
Joined: 9th Jul 2003
Location:
Posted: 23rd Aug 2004 05:07
WOW unlocking pixels after the dot command does give me a huge increase, thanks for that suggestion. Now i've increased the loop to 5000 and the fps get only as low as 130 with loads of pixels falling.
GeeB
22
Years of Service
User Offline
Joined: 9th Jul 2003
Location:
Posted: 23rd Aug 2004 07:37
Here is the code sofar... for those who wanna steal it
I get a solid 140fps which is relativly good for 5000 pixels flying around i guess.
Rknight
22
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 23rd Aug 2004 11:42
What an interesting effect.

Login to post a reply

Server time is: 2026-06-11 14:49:13
Your offset time is: 2026-06-11 14:49:13