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 Professional Discussion / [HELP] 2D Game Development

Author
Message
summerfed
15
Years of Service
User Offline
Joined: 14th Jun 2011
Location:
Posted: 16th Aug 2011 16:22
My 2d game loads very slow, and runs very slow, I think there is something wrong with my code, please help me to fix it. Thank you in advance, I attached the code in notepad
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 16th Aug 2011 18:33
Can you supply us with the media so we can compile the code without having to create all the images. And maybe it is a problem with the images, being way too high res.
Alien002
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 16th Aug 2011 18:34
I hade a quick look at the code. That's a lot of code.

To help with the loading speed only load images that you will be need for that level.
summerfed
15
Years of Service
User Offline
Joined: 14th Jun 2011
Location:
Posted: 16th Aug 2011 22:40
Thanks for the reply, here is the complete folder of the game, feel free to look at it. Thank you
summerfed
15
Years of Service
User Offline
Joined: 14th Jun 2011
Location:
Posted: 16th Aug 2011 23:04
Thanks for the reply, here is the link: http://www.mediafire.com/?eknqr8ie0y44aug complete folder of the game, feel free to look at it. Thank you for all the help. And another question, how can I add save and load feature of the game?
summerfed
15
Years of Service
User Offline
Joined: 14th Jun 2011
Location:
Posted: 17th Aug 2011 00:11
How to compile the code loading only the image needed for each level?
Mugen Wizardry
User Banned
Posted: 17th Aug 2011 01:02 Edited at: 17th Aug 2011 01:03
put all your level code into a function, then loop through the correct needed images.

You best name your image something you can link to your loop, for instance:

1.png, 2.png, 3.png, etc..

so you can do

for x = 1 to 3
if x = 1 then load image x, "levels/"+str$(x)+".png" `load level 1
if x = 2 then load image x, "levels/"+str$(x)+".png" `load level 2
if x = 3 then load image x, "levels/"+str$(x)+".png" `load level 3
next x

etc...

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
summerfed
15
Years of Service
User Offline
Joined: 14th Jun 2011
Location:
Posted: 17th Aug 2011 01:13
Thank you, It helps, Another question, how to add save and load feature? Thank you
Mugen Wizardry
User Banned
Posted: 17th Aug 2011 01:27
That's a little harder.

You'll need to save your info to a file, for instance, here's how I do it in 3D:



Hope that helps

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 17th Aug 2011 03:12
Quote: "for x = 1 to 3
if x = 1 then load image x, "levels/"+str$(x)+".png" `load level 1
if x = 2 then load image x, "levels/"+str$(x)+".png" `load level 2
if x = 3 then load image x, "levels/"+str$(x)+".png" `load level 3
next x"


Why on earth would you do that? That loops through and loads all three levels.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 17th Aug 2011 12:09
Quote: "and runs very slow"

It runs at a nice 60 fps here, but I will see what I can do to increase this.
For the loading... the main slowdown is probaly the maps, wich are verry large images.
To increase the loading time you can load only the images you need.
To increase the game speed.. Well you are looping through a lot of sprites in the array, when there aren't that many in the level.
Couldn't really see wich ones you loop and wich ones you don't in all the code, but I suggest you take a look on which items in the array you need to update.
You can also increase the loading time by converting your map images to memblocks and save them to a file.
You can use these functions for that:


btw, you menu isn't working here. It doesn't run when you press the start key.
It just clears the menu background (not the buttons) while you press the key.
When you release it, the menu looks just the same and the game isn't starting.
It also doesn't delete the buttons when the game starts, however that might be something I missed when making a fast workaround for the broken menu.

I can make a template for loading the needed images and looping though the needed sprites. However you will need to rewrite your whole code to fit the template.
So just say if you want the template or not
Mugen Wizardry
User Banned
Posted: 17th Aug 2011 16:03 Edited at: 17th Aug 2011 16:11
I hate to say it, but he's right.

Try this, I coded that last night at 11 PM



CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !

Login to post a reply

Server time is: 2026-07-10 20:58:43
Your offset time is: 2026-07-10 20:58:43