2014-11-27 05:54:13

Prompt please, do road in the game, how to make the field x 20 say?
And so you can go right to the left arrow.
Here's an example of my code that does not work:
#include "dynamic_menu.bgt"

const int board = 20;
int player_position = 1;
sound music1;
sound music;
sound shag;

void main()
{
music.load("music.wav");
music.volume = -30;
music1.load("music1.wav");
music1.volume = -10;
shag.load("shag.wav");
shag.volume = -10;
tts_voice voice;
dynamic_menu menu;
menu.allow_escape = true;
menu.wrap = true;
menu.add_item_tts("Start game");
menu.add_item_tts("Test speaks");
menu.add_item_tts("Exit game");
show_game_window("Enemy");
voice.speak_wait("Welcome to Enemy");
music.play_looped();
int choice;
do
{
choice = menu.run("Please choose a menu item with the arrow keys, then hit enter to activate it.", true);
if(choice==1)
{
music.stop();
game_play();
}
else if(choice==2)
{
music.stop();
alert("Game", "unfinished game");
music.play_looped();
}
}
while(choice!=0 and choice!=3);
music.stop();
voice.speak_wait("Thanks for playing.");
}

void game_play()
{
while(true)
{
music1.play_looped();
if(key_pressed(KEY_LEFT) and player_position>0) {
player_position--;
}
if(key_pressed(KEY_RIGHT) and player_position<20) {
player_position++;
}
if(player_position<0)
{
player_position++;
}
if(player_position>20)
{
player_position--;
}
}
}

2014-11-27 19:50:59

Why it doesn't work?
The code is right I think.