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 / To the next Level?

Author
Message
gopherbro 94
17
Years of Service
User Offline
Joined: 21st Dec 2008
Location:
Posted: 29th Mar 2010 08:48
is there any way i can use this code and then goto the next level?

this is the only way ive found that will delete all the objects from the last level... but i dont know how to get to the next level now
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 29th Mar 2010 09:41
Well how you get to the first level?This code is good but not related to loading, it free resources for next level to be used.Show us how you load your levels.Then surely someone can help you.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
gopherbro 94
17
Years of Service
User Offline
Joined: 21st Dec 2008
Location:
Posted: 29th Mar 2010 09:53
i have them as

level 2 uses the same code as level 1, it just loads a different map
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 29th Mar 2010 11:11
From your other thread i see you rely too much on goto and gosub`s.Probably that`s the way you load your levels.Use functions, read other people`s code, make your own samples to learn from.The way you code is not effective.It`s hard to explain you how to load your levels when actually you allready know how to do it.Just the way you are doing it is not the most sufficient way.That confuse you.
But anyway you can load your next level the same way you did the first one, just need to make conditions in your game when this need to be done.When conditions are met then free your sounds, sprites and objects.Load level 2.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 30th Mar 2010 17:54
I would save each level as an array. Prior to running any level you would call a routine to set it up. Each time you complete a level you change the name of the array you will load on the next level set up.

So at the start or label you set up your variables, add in a level array.

dim level(10)

Then before you start your first level from your game start

level$="level1"

Then run your level set up

if file exist(level$)
load array level$,level(0)
endif

Then when you complete your level
level$="level2"

And so on.
level$="Level3"

You could use some code to inc a number and add it to the end of the file name instead of manually putting in level$="blah" all the time. That way you could hopefully have just one bit of code for all the levels.
To be honest you can do this with functions or gosubs just as easily. It's just these new programmers are used to functions these days, and they tend to blame the gosub command for all sorts of ills. As long as your code is correct gosubs are fine. I don't use goto though as it messes up the stack.
Anyway that's sort of the basics of how I would do it. I would try to get your game into one main loop rather than successive levels though.

http://s6.bitefight.org/c.php?uid=103081

Login to post a reply

Server time is: 2026-07-26 21:12:15
Your offset time is: 2026-07-26 21:12:15