2019-02-18 06:59:57

Hi! I again have the same problem in bgt. So when i launch the game and choose the start game, it exits. Here is the code. Please write me the right version:
#include "dynamic_menu.bgt"
void main()
{
show_game_window("Frissi");
tts_voice voice;
dynamic_menu menu;
menu.allow_escape=true;
menu.wrap=true;
menu.add_item_tts("Classic");
menu.add_item_tts("Exit");
int choice;
choice=menu.run("Choose",true);
if(choice==1)
{
start_game();
}
}
void start_game()
{
tts_voice voice;
while(key_down(KEY_ESCAPE))
{

int score=144;
if(key_pressed(KEY_RIGHT))
{
score=3;
voice.speak_wait("Oh troll");
}
}
}

Best regards: Marco

2019-02-18 10:44:30 (edited by Hijacker 2019-02-18 10:46:01)

In your current state, your while loop within start_game() will only run as long as you're holding down the escape key, which seems to be the exact opposite of you want to achieve, so simply negate your condition to keep the while loop alive:

while(!key_down(KEY_ESCAPE))

Also, i'm always using key_pressed() for this kind of code, but I guess it doesn't really matter. Also, add a small waiting period within your while loop to prevent cpu lockdowns, such as

while(!key_down(KEY_ESCAPE))
{
  wait(50);
}

Your code doesn't seem very advanced though and at least I won't answer all your questions as long as you're asking someone to do your work, so i'd recommend to read through the bgt help and especially through the tutorials to get yourself going rather than letting someone else work for you.
Best Regards.
Hijacker

2019-02-18 19:47:38

Hi there,
I'm impressed. post 2 gave a lot more help than I would have.
I read this post in my email, and was going to read through the code and say well look. If you want people on this forum to continually debug your code, then really what's the point in writing it.
I won't go over the same old same old thing about BGt being outdated, because lets be honest, if you're still using it, you're not listening.
But, if you can't debug your own code, why should we do it either?
I'm all for helping with questions like, "how do I do." "where should I look."
But posts like, here's my game fix it for me just really. really. wind me up.

thank you, rant over.

Nathan Smith
Managing Director of Nathan Tech
It's not disability
It's ability!