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 / Game Over, go back to menu.

Author
Message
20Glyphs
9
Years of Service
User Offline
Joined: 7th Mar 2015
Location:
Posted: 1st Dec 2015 20:01
I have set the function for the main menu and it works at the start, but whenever I want the game loop to go back to the menu function after the player loses, it just doesnt work. Any help? Here's my code:

LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 2nd Dec 2015 05:50
Hi,

First off, I would not use Disable Escapekey unless you have coded another way to get out of the game. As it is, if you highlight EXIT, and press Enter, it just sits there and keeps running.

I think the reason you are not seeing it go back to the main menu is that you have gosub setanim in a do - loop. Take out that do-loop (and sync) and simply put in a return after gosub setanim line and it should work. You have two returns at the end of the code as if these were nested or something; only one is needed.

You might also give clarity to the user as to how to make selections in the main menu. I figured out I needed to use the W and S keys to go up and down, but a user may not.
So many games to code.....so little time.
20Glyphs
9
Years of Service
User Offline
Joined: 7th Mar 2015
Location:
Posted: 3rd Dec 2015 16:26
Thank you so much for the reply.

Unfortunately, your suggestion did not work. I removed the do-loop from the function statement and when I run the game, it just freezes, the animation does not play and the menu choices are on the screen with nothing else to do.

Any further help would be appreciated.
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 3rd Dec 2015 23:13
Okay, I said


You responded that you removed the do - loop, but did not say that you put the RETURN in after the gosub setanim line.

Your gameloop subroutine should look like this:



If it does look like that, then there is something else wrong, as this runs okay on my computer.
So many games to code.....so little time.
20Glyphs
9
Years of Service
User Offline
Joined: 7th Mar 2015
Location:
Posted: 4th Dec 2015 00:59 Edited at: 4th Dec 2015 01:01
Apologies for not mentioning, but I did add the return command after the subroutine line. It just does what I explained. It's probably because you don't have access to the videos, so it works for you. The problem must be related to the videos, but I'll just go back to how it was before.

Thank you so much, though for your help. If it's not much trouble, could you help with another dilemma? This is a Russian Roulette game so I decided to make a randomizer that shuffles between 2 animations (Shooting animation and empty barrel shot) and the randomizer starts when I press either 1, 2, 3, 4 or 5. What I want is for the game loop to act as if this is a real revolver with a real value of bullets in, so the empty barrels animation do not occur more than 5 times. Here's my randomizer in the game loop:



I tried adding a variable with a number calling it "Bullets" and every time I clicked any of the buttons, the Bullets variable decrements by 1 until it reaches 1 and then the shooting animation plays when that happens, but it's not working.
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th Dec 2015 06:18 Edited at: 4th Dec 2015 06:20
Ya, it can be difficult to figure out the problem when you don't have the media involved. I looked at your code and I think this will work, but am not 100% sure, since I can't run it with your animations.
Check it out and let me know if this helps.



EDIT: I just noticed that you set Bullets = 5 at the start of the setanim subroutine. You should set this variable to this value earlier in the code.
So many games to code.....so little time.

Login to post a reply

Server time is: 2024-03-29 08:15:24
Your offset time is: 2024-03-29 08:15:24