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

Author
Message
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 17th Jun 2004 03:48
I'm working on a little game in 2d. Its nothing much, but when I create one of the sprites I need it slows the game down from 60 fps to 10 fps. The game is you move your character around and try to get stuff without getting caught by the ghosts. I made a bitmap of the board like the things that you can't go into like paths and stuff that lead to items. I put a background image behind it. When I make the board as a sprite it completey slows down the game. I need it as a sprite so I can use sprite collision to test if the ghosts or the player are hitting the barriers.

So why when I make the big sprite (640 by 480) the game slows down andhow do I fix it?

Please help!
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 17th Jun 2004 05:14
DBC's sprite commands are not ideal for creating 2d games. DBC actually writes the pictures on screen pixel by pixel with a different rendering routine, whereas the sprites in Pro are actually just textured plains positioned at the right angle. You could either
(a)Use the IMAGE commands, which will unfortunately take some extra coding to simulate sprite features, but if you write a nice sprite engine then you can keep it safe for later use.

(b)Do it like Pro, just use MAKE OBJECT PLAIN or even go inside a 3d modeller and create the plains yourself. This will get you the most FPS.

(c)Upgrade to DbPro. Not worth it for such a small, easily-avoided problem.

Crazy Donut Productions, Current Project: KillZone
Web Site Button Does Not Work, Visit Here: http://www.geocities.com/crazydonutproductions/index.html
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 17th Jun 2004 09:10 Edited at: 17th Jun 2004 09:16
underworld 1020,

I would suggest that you use a different implementation for your collision detection for barriers. Of course the method you use depends on the board image. Here is an example of an alternative(I would need to be able to see your board before offering other suggestions).

You could just display the board as an image or bitmap. Then create a 'logical grid'(A 2D array that breaks the bitmap into a grid). The size of the grid is dependent on how intricate your barriers are. I'll assume here that a 16*16 grid will sufffice (Of course if you needed to you could raise/lower it to 32*32 or 8*8). So following is a (poor) Pac-man'esque level. So the 'logical grid' for the board may look like this.
1=barrier 0=walkable: screen size 640*480

1111111111111111111111111111111111111111
1000000010000000100000000100000000000001
1011111010111110101111110101111101111101
1000000000000000000000000000000000000001
1111101111111101111101111110111111011111
1000001111111100011101110000111111000001
etc...
This would be stored in an array
dim level(39,29)
Now have variablse keep track of the player's x,y grid coordinates. And when they move, check the position in the array that corresponds to the grid they are moving to. If it's a 1, then it's a barier and so they can't move that way.


If this isn't accurate enough even with a smaller grid size. I would guess that if the barrier's outlines are a specific color, that's different then walkable areas, you could check for the pixel color. I haven't tested this method for speed in DBC though.


pizzaman
21
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 17th Jun 2004 17:45
hey underworld 1020

its much better to do the game as zenassem said however if you want to do it the way you said then you can as long as turn off the backsave flag in the set sprite command.

if you want more info check this post out (where it says sprites in the edited bit of the first post)

http://darkbasic.thegamecreators.com/?m=forum_view&t=32948&b=10

anyways good luck which everway you do it
pizzaman

Login to post a reply

Server time is: 2025-05-26 02:59:56
Your offset time is: 2025-05-26 02:59:56