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! / Optimizations in a 2d vertical scroller

Author
Message
Imerion
20
Years of Service
User Offline
Joined: 13th Oct 2003
Location:
Posted: 14th Nov 2003 00:44
I have tried to create a vertical scroller for my first time, however, it is slow. Very slow. Any tips on how I can optimize this?

Thanks
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Nov 2003 02:46
It's slow and you dont even have a background on there yet? Is this DB Classic or DBPro? What computer do you have?

You don't need to load your images as bitmaps and then get them. You can just load images on their own.

Pincho.
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 14th Nov 2003 07:36
just a couple of quick things before I goto bed
1 don't use set sprite in your main loop
2 don't use set sprite x,1,x this is back save always use set sprite x,0,x
3 put a cls under DO in your main loop

that's it for now, got to go to bed, but the slowness is the backsave it's very slow. I'll look over your code later.

CTP
Imerion
20
Years of Service
User Offline
Joined: 13th Oct 2003
Location:
Posted: 14th Nov 2003 22:39
Quote: "It's slow and you dont even have a background on there yet? Is this DB Classic or DBPro? What computer do you have? "


Its DB-Classic and im using a Pentium 4: 2,5 Ghz so I guess it should work a little bit faster

Quote: "1 don't use set sprite in your main loop
2 don't use set sprite x,1,x this is back save always use set sprite x,0,x
3 put a cls under DO in your main loop"


Should I use only paste sprite in the main loop?

Quote: "that's it for now, got to go to bed, but the slowness is the backsave it's very slow. I'll look over your code later."


That would be great! Thanks. Ill try fixing these suggetsions in the meantime.
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 15th Nov 2003 03:10
OK, I'm working over your code abit and heres some issues just fyi
1) you don't need to LOAD BITMAP and GET IMAGE, just use LOAD IMAGE

2) don't use PASTE SPRITE as this only paste a image of the sprite not not the SPRITE, SPRITE COLLISION uses the real sprite position not the PASTE SPRITE image.

3) declare all of your SPRITEs before your loop like this for example
SPRITE 1,0,0,1
SET SPRITE 1,0,1
this is the only time you need to use SET SPRITE (unless you DELETE SPRITE and then make the SPRITE again)

4) don't DELETE SPRITE after a collision just send the SPRITE someplace else to be reused ex. SPRITE 2,1000,rnd(480),2
this way the SPRITE will come again 1000 pixels later at a random height on the screen
for the bullets send them off screen to 0,-50 like that. It would be nice to HIDE SPRITE but I belive that SPRITE COLLISION will still detect it.

5) SPRITE creates a SPRITE the first time it is called after the SPRITE command is used to position the SPRITE

6) your background is SPRITE 6 therefor you need to draw it first
you can have the background use SPRITE 1 as they are drawn in order from smallest to largest, or
you can set all the other SPRITE PIRORITY to 1 then they will be drawn last.

7) you use exp for you explosion varaible but, EXP is a key word, use expl or something, Why DBpro doesn't crash when doing this is beyond me.

OK, finished, see how you like it.
All I did was make it work, not that it's all right code wise.
I suggest looking at what I did and starting over, with the new things learned.

try using low sprite numbers for your background, high sprite numbers for your foreground and middle sprite number s for everything else. They don't have to be in order try something like 1-10 for background and 100-200 for game pieces and 500-600 for foreground.

I'll try to help again if you need it but I may be difficult to get ahold of.

CTP
Imerion
20
Years of Service
User Offline
Joined: 13th Oct 2003
Location:
Posted: 15th Nov 2003 23:12
Thanks man! Ive learned a great deal...
Imerion
20
Years of Service
User Offline
Joined: 13th Oct 2003
Location:
Posted: 15th Nov 2003 23:19
Seems like it won´t recognize the command SPRITE PRIORITY? Perhaps what wont work in DB classic.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th Nov 2003 23:21
Well he did give you two alternatives.
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 16th Nov 2003 04:58
SPRITE PRIORITY may be a DBP function, I don't have classic.
but I think you get the idea, you may just have to plan the sprite usage out in the order you wish to draw them.

CTP

Login to post a reply

Server time is: 2024-05-08 08:53:13
Your offset time is: 2024-05-08 08:53:13