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! / slow 2d game

Author
Message
grekster
20
Years of Service
User Offline
Joined: 23rd Oct 2003
Location:
Posted: 23rd Oct 2003 17:02
im trying to make a tetris game in darkbasic, ive just been trying different ways of drawing the game area out and ive decided on using an array to hold to posistions on blocks then just drawing the array using paste image, but its really slow, does any1 know y its so slow and if theres a way to make it faster?
Athas
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location:
Posted: 23rd Oct 2003 17:21
If your using DBC you may like to try pasting the image to a different bitmap than bitmap 0 (The screen) then swapping them back. I believe this is quite a lot faster then drawing directly to the screen.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 23rd Oct 2003 20:39
When you actually play the game you will not be drawing every column in the game. You'll just be drawing the shape falling down, then if it makes a line, you'll paste the background over the line as one long rectangle. Then move everything above it down as one huge image. It's mainly bitmap copying from one screen to another.

Pincho.
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 24th Oct 2003 07:51
for me this runs very fast, using 800x600 res with 32x32 blocks I get over 70fps, are you using DBP and what is you computer speed mine is a 1 gig, that I tested on.

CTP
grekster
20
Years of Service
User Offline
Joined: 23rd Oct 2003
Location:
Posted: 24th Oct 2003 13:20
im on an 800mhz athlon and im using normal darkbasic, not pro

to Athas: could you please explain a bit more about pasting to a different bitmap, im not sure how to do that:S
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Oct 2003 17:13 Edited at: 24th Oct 2003 17:14
Paste Images on Bitmap 1
Copy bitmap 1 to Bitmap 0

It's only going to be faster if you do it the way I said earlier.

Pincho.
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 25th Oct 2003 06:40
Replace Paste Image with Sprite and only call the routine when something changes.

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
elVee
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location:
Posted: 25th Oct 2003 08:35
Sprites are quite slow though, arent they?
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 25th Oct 2003 08:58 Edited at: 25th Oct 2003 09:00
exactly the opposite you can have hundreds of sprites on the screen at once with very little overhead. Here is an example of sprites but there are far more efficient ones in on the site




Click left mouse button to drag any sprite to new pos

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Oct 2003 14:35
But Surely images are faster, they have no overhead at all.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Oct 2003 22:23
But there is an overhead ... *your* code has to keep track of where they are and redraw them, instead of the DBPro library doing it - and the library is far more efficient about it than you can be.

Generally, if you are using sprites you should switch the backsave option off also (using SET SPRITE sp, 0, 1). This will make your updates faster too
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 26th Oct 2003 04:03
he has DBC not DBP and in dbc sprite are just images with DB keeping track of everything, they shouldn't be any faster.

In DBP sprite will be faster then an image because it's a 3d object and all new cards are 3d optimized, the last few generation of cards have shown little improvement in 2d because about the only modern apps using 2d are GUIs and they just arn't that demanding like games were.

CTP
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Oct 2003 13:03
Then what I've said still stands.

Because DBC does not produce machine code, managing the sprites yourself is far slower than having DBC manage them for you
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Oct 2003 14:11
That would need testing I think. Sprites have all sorts of things built into them. Things that you don't need for Tetris, like collision, coordinate checking, image change checking. Plus how do you merge all of the sprites into 1 big sprite the same way that images can be picked up as a whole block? I think that images would be faster.

Pincho.
grekster
20
Years of Service
User Offline
Joined: 23rd Oct 2003
Location:
Posted: 26th Oct 2003 17:44
im goin to try doin it by pasting into one bitmap and pasting it to the screen, the just chaging as nessery, if that dont work ill try sprites, thx for your help guys
grekster
20
Years of Service
User Offline
Joined: 23rd Oct 2003
Location:
Posted: 30th Oct 2003 00:09
another question, im doin quite well with the game so far, but i cant get 1 iamge pasted into another, how would you do this? ive looked in the help but i cant see how to do it. maybe its a case of not being able to see thw wood for the trees *shrugs*
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 30th Oct 2003 19:50
Again I believe sprites are the answer, I I understand you correctly you wish to paste one image over the other such as a bush in front of a player yet still see the player between the leaves.

Make bush image background in black rgb(0,0,0) then set sprite priority of bush higher than sprite priority of player image. using sprites the rest will be automatic

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 31st Oct 2003 20:39
Pseudo Code....

Make 2 bitmaps

Paste Image BlankLine

Copy Bitmap from bitmap 1 to Bitmap 0

Pincho.

Login to post a reply

Server time is: 2024-04-28 11:54:02
Your offset time is: 2024-04-28 11:54:02