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 / end section not working

Author
Message
Jon wu
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 24th Mar 2014 16:31
so I tried doing it when the player presses the wrong key then it will go to the endsection but when i go to my endsection the options wont work like playing again or exiting





Hasty
tiffer
19
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 24th Mar 2014 16:35
You're in a bit of a spaghetti code affair. Wouldn't be able to help you without seeing more of your code.

Cwatson
Jon wu
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 24th Mar 2014 16:38


Hasty
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Mar 2014 16:39
Quote: "but when i go to my endsection the options wont work like playing again or exiting"


Perhaps you'd like to show us the endsection code.



Powered by Free Banners
tiffer
19
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 24th Mar 2014 18:24
I thought scancode 0 was for keyboard errors?

Can you verify GG?

Cwatson
tiffer
19
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 24th Mar 2014 18:29
Try changing


to:


Cwatson
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Mar 2014 19:12
That would be my guess too - I suspect he's got the condition the wrong way round. Strangely, I made a similar error yesterday.

@Jon wu

You obviously just beat me to it.



Powered by Free Banners
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Mar 2014 20:56
Quote: "if scancode()>0 then exit"


That still wouldn't be a good idea. To trigger the jump to endsection he presses a key. 99.9999% chance it will jump through that section of code and into the loop before his finger is able to release the key, thus triggering the statement to exit before he even realizes it. You would need an additional flag

And looking at it, I can't even see a reason to have that do-loop in there at all since it's the next loop that checks for a response to continue playing or not.

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Mar 2014 00:51
You're right. In fact the Y/N prompt should be inside the second loop in endsection.



Powered by Free Banners
Jon wu
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 25th Mar 2014 16:13
alright so i changed the code from = to > but when i hit the y key to start over it says object already exsists at line 97 which is confusing since the object doesnt have anything to do with the endsection.

Hasty
tiffer
19
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 25th Mar 2014 16:19
That's because of the code in 'optionsection' That makes the objects. You're repeating the make object commands.

Cwatson
Jon wu
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location:
Posted: 7th Apr 2014 18:01
alright i got the endsection to function but when i play again my first level is glitchy and flashing and every other level is fine except the first.
EndSection:

REM DECLARE VARIABLES
REM SCREEN DISPLAY
cls 0
REM SOUND EFFECTS
REM SPECIAL EFFECTS
REM REFRESH SCREEN
sync

REM *** END SECTION LOOP
if scancode()>0 then exit
do
center text 320,240,"GAME OVER NOOB! Play Again [Y/N]?"
REM CONTROL INPUT
if Inkey$()="y"
gosub MoonSection
endif

if Inkey$()="n"
cls : end
endif
REM REFRESH SCREEN
sync
loop

end
REM *** STOP END SECTION
REM *****************************************


Hasty

Login to post a reply

Server time is: 2025-05-14 06:20:05
Your offset time is: 2025-05-14 06:20:05