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.

Newcomers DBPro Corner / dbc: how to make my game run smoother

Author
Message
raar
20
Years of Service
User Offline
Joined: 9th Jul 2004
Location:
Posted: 12th Sep 2004 02:08
well i made a little breakout clone with sprites, well its not quite finished yet but i have the ball, collisions and all allready.
But the game runs shoppy, i used the screenfps to see how many fps it gets and it goes from 20-30. Thats not quite enough for a smooth picture so i was wondering what i can do about it, even if i let the collision detection off it still isn't smooth.
I can post the code if you need to see it (its only 130 lines orso so it doesn't have to do complicated calculations that effect the fps i think). its only 10 sprites this far (8 blocks, 1 ball and 1 paddle)

So you got any ideas how to smooth things up?

tia
Dodo
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: eating lunch
Posted: 12th Sep 2004 02:29 Edited at: 12th Sep 2004 02:29
you could try either of these things:

1. use sync rate to set the sync rate to 60+
2. use FastSync.

if these don't work then posting code would be helpful

hope this helps
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 12th Sep 2004 02:53
Hey Dodo, there is no fastsync in DB Classic.

Yeah, we kind of need to see some code. That way we can point out the inefficient parts of your code for you to fix.

Xander Moser - Bolt Software - Firewall
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 12th Sep 2004 04:47
Also when you post some code ... please post your system specs. It may help as well.

raar
20
Years of Service
User Offline
Joined: 9th Jul 2004
Location:
Posted: 12th Sep 2004 04:53
k i ll put the code here:

still some bugs too like sprites appearing where they shouldn't :s, and the ball getting stuck in the top part of the screen, so if you have any idea what can be wrong
btw variables are in dutch srry for that if needed i ll change them
and with the new sync rate its better, though some drops in frames occur sometimes
DK_
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 12th Sep 2004 12:17 Edited at: 12th Sep 2004 12:18
A good idea to make your game run smoother is to not 'sync' every frame. Only do it about every three frames.
Example:



This works for me very well. However, after doing this, depending on how many frames you wait before using 'sync' you may want to try more than three, it may work so well that it goes even faster than you want and you may have to change certain things such as the speed of the ball so that it's slower.
Not using 'sync' every frame is different from changing the sync rate because lowering the sync rate makes the FPS go slower, this wont work for what you need. not using 'sync' every frame still uses math and does what you want and updating the screen is a very costing thing so if you make your program run normally and just don't sync as much it really helps.

By the way. I got this idea from Quake III. This is the same method that Quake III uses.

Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 12th Sep 2004 13:01
I can't beleive noone mentioned my speed tips!

I have compiled a massive list of things to do to get more speed out of your DBC apps, browse over to:
http://forum.thegamecreators.com/?m=forum_view&t=32948&b=10
to see them

Hope this helps.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
raar
20
Years of Service
User Offline
Joined: 9th Jul 2004
Location:
Posted: 13th Sep 2004 01:17 Edited at: 13th Sep 2004 01:27
nvm i found this, prolly other questions comming though
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 13th Sep 2004 02:56
Well, one little speed tip for your program:
You can check to see if the ball is withing a certain distance from the paddle before checking for collision between the sprites. Something like this:



You can replace the collision part of your code with this. I used 30 for the distance check, you can make it larger if it is not big enough.

There is one huge thing you could do to make your program much much faster...change it to 3D. 3D is much faster than 2D in Dark Basic. Just make 3D boxes for the paddle and blocks, and a sphere for the ball. It wouldn't be that difficult. Just ignore the z value of 3D, set it at 0 for everything. Then just get the camera in the correct spot and there you go.

Xander Moser - Bolt Software - Firewall
raar
20
Years of Service
User Offline
Joined: 9th Jul 2004
Location:
Posted: 13th Sep 2004 03:17
yeah i made a 3d pong version
But those the 3d of dbc have build in collision detection like with sprites.
I still got one problem, i make a detection with the sides of the screens but sometimes the ball gets stuck in the sides, i think it has something to do with how many pixles the ball moves every turn and the size of my border sprites
raar
20
Years of Service
User Offline
Joined: 9th Jul 2004
Location:
Posted: 13th Sep 2004 05:48
k i updated the code somewhat it runs smooth enough, only not in the beginning dunno why but i got still got 2 probs, maybe someone can take a look at it and help me sort them out
first the code:


So my two problems are:
1)Sometimes when the ball hits the left, top or right sprite it gets stuck, it just keeps changing the angle but it keeps stuck in that sprite, for example when i hit the left border it just keeps on hitting it and going out and hitting it and so on. It just trembles against that sprite. (it ll be a lot clearer when you play it :p)
2)I think i did something wrong with my angles caus when the ball hits the paddles it sometimes does unpredictable things (it makes a wrong angle with it)

So if anyone know how to improve this/fix it i would be very happy

tia
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 14th Sep 2004 23:15
[EDIT] put in Sync On at the very first line, and see how much that imporoves the "choppyness" [/EDIT]

A few things:

1st. I really do suggest you read my speed tips, as most of what I'm about to say is covered in there ( link above ).

2nd. Only ever use "Sync" ONCE per loop, never more unless for a specific reason ( and I can't think of any case where this is necessary except if you are trying to acheive a certain effect ), and it's best to keep it at the end of the loop, so that you can program more linearly.

3rd. You are using the Sprite command in a loop, you don't have to do this. Once you use the Sprite command once, it should stay on the screen premanently, so you only have to do it once before the loop.
And for the sprites that are moving, use the Paste Sprite command instead of the Sprite command.

4th. At the very start of your code, you should always have all the things such as Sync Rate xx and Set Text xxxx and Set Display Mode xxxx etc, instead of later on in the code, just bunce it all up the top in a "setup" type block

5th. Try setting the sync rate to 0 ( this will set the screen to refresh as fast as possible, thus making it more smooth )

6th. The Ink command is slow when changing what the background colour is aswell as the foreground colour, that could by why it's a bit slow.

Hopefully all that helped

Jess.


Team EOD :: Programmer/All-Round Nice Guy
Aust. Convention!
raar
20
Years of Service
User Offline
Joined: 9th Jul 2004
Location:
Posted: 15th Sep 2004 00:19 Edited at: 16th Sep 2004 00:49
thank i ll try that
i got the sprite command from a pong like game in the codebase and it uses it in the loop too so i thought it had to be done that way :p, i ll try the tips asap

I don't really get the paste sprite thingie, when i do it it pastes the sprite over the excisting one, how do i delete the old sprite, i tried the delete sprite command but then i just get an empty screen :s
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 19th Sep 2004 07:24
Oh yeah, sync on. Duh. I should have thought of that. When I made my first game in DB, I didn't understand the sync stuff. It sure did help the speed when I put sync on at the beginning and synced once per loop.

Xander Moser - Bolt Software - Firewall
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 22nd Sep 2004 05:53
yeah, 'cuz by default sync is off, which means the screen 'sync's by itself, ignoring any sync commands you use.

good, for first program showing how to make a cube,
bad for actual game

[img src=http://blanky.pt-web.net/ddd.gif] >::p

Login to post a reply

Server time is: 2024-11-27 10:27:30
Your offset time is: 2024-11-27 10:27:30