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 / Level Load Question

Author
Message
Cheezermega
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: U.S.A
Posted: 16th Jan 2008 23:08
I'm making a game for game design class and i'm having a little trouble with level switching, it shows the the title screen like its going to load the next level but then it loads the first one again any suggestions?


"We Have Desided to let you run free, But at a price we have taken your legs."
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Jan 2008 23:52 Edited at: 16th Jan 2008 23:53
It looks like you need to pass the variable 'LevelNumber' to the LoadLevelMap function.

While there is a fair amount of debate about it, I'm surprised you are using GOTOS in your code for a game design class. I would take them out completely and rework them as procedures or functions. Also, why not just use the wait key command instead of checking the scancode?

LB
Cheezermega
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: U.S.A
Posted: 17th Jan 2008 00:29
How do I go about doing that, were as about as far has you see in coding skills in DB I wish they would have used torque for this class then I would have nailed it.

"We Have Desided to let you run free, But at a price we have taken your legs."
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Jan 2008 04:01
It's easy to do, just change your function call to:
LoadLevelMap(LevelNumber)

As to getting rid of GOTO, take, for example, your 'intro' code, and make a subroutine like this:



then you call it from your main code, right after your START SYSTEM SETUP SECTION like this:
gosub START_INTRO
wait key

Do the same thing with your options, start level intro, etc. sections that you have already outlined. I would recommend that your 'main' routine consist of a do-loop that mainly has calls to functions and procedures (subroutines). Your code will be much easier to debug and read.

Hope this helps,

LB
Cheezermega
19
Years of Service
User Offline
Joined: 22nd Aug 2005
Location: U.S.A
Posted: 17th Jan 2008 05:00 Edited at: 17th Jan 2008 05:10
Ok I changed everything arround but the same level loads each time, the levels right now are set only to change texture but im going to change other stuff later.


"We Have Desided to let you run free, But at a price we have taken your legs."
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Jan 2008 14:39
Oh my......this is not what I was expecting you to do at all. All subroutines must be ended with a 'return' command. You should put all of your subroutines after your main code like you did the functions. Then your main code calls the subroutines and functions as they are needed. You should straighten this out before you do anything else. To show you what I'm talking about, look at this:


I did not optimize your main loop, but you should be able to pull out subroutines or functions that you can simply call from it. Some of your names for the subroutines may be a little different than what I named them, so you'll have to double-check that. Once you get it up and running like you want, let me know if you still have the problem or not. I don't know if it will make a difference or not, but your call to 'function LoadLevelMap(LevelNumber)' did not have a closing parenthesis at the end, but a 'close box' character. I changed it in the code above.

LB
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Jan 2008 16:53
It might help considerably if you spend a few minutes reading tutorial 2 and 12 here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Tutorial 12 covers game logic and includes a handy empty program template which gives you a solid layout on which to base any DB program.

TDK_Man

Login to post a reply

Server time is: 2025-06-06 16:15:00
Your offset time is: 2025-06-06 16:15:00