Here is what is wrong in this code:
#include "dynamic_menu.bgt"
#include "sound_pool.bgt"
int player_position=1;
const int board = 30;
sound step;
sound_pool pool;
sound music;
sound start;
sound game;
void main()
{
// Load the music.
music.load("sounds/menu.wav");
music.volume = -10;
step.load("sounds/step.wav");
start.load("sounds/start.wav");
game.load("sounds/start1.wav");
// Set up voice.
tts_voice voice;
// Set up menu.
dynamic_menu menu;
menu.allow_escape = true;
menu.wrap = true;
menu.add_item_tts("Start game");
menu.add_item_tts("Exit game");
// Show game window and speak welcome message.
show_game_window("Battl cry");
voice.speak_wait("Welcome to Battl cry!");
// Loop the music in the background before running the menu.
music.play_looped();
int choice; // This stores the user's menu selections.
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();
play_round(); // We will define this function later.
}
}
while(choice!=0 and choice!=2);
// The user pressed escape or chose to exit.
voice.speak_wait("Thanks for playing.");
}
class enemy
{
int hp;
int position;
int speed;
timer time;
enemy()
{
hp = 100;
speed = 100;
position = 10;
}
void move() {
if(time.elapsed>=speed) {
if(position>player_position) position--;
else position++;
pool.play_1d("sounds/step.wav", player_position, position, false);
time.restart();
time.resume();
}
}
}
void play_round()
{
start.play_wait();
game.play_wait();
while(true)
{
enemy enem;
if(key_pressed(KEY_RIGHT))
{
player_position++;
step.play();
}
if(key_pressed(KEY_LEFT))
{
player_position--;
step.play();
}
if(player_position < board)
{
player_position++;
}
if(player_position > board)
{
player_position--;
}
enem.move();
}
}