In aum67 in the Plug and play section, there was a code about a "menu system", while checking the code I noticed that two functions were defined but they were never called either in main.c or menu.c although commenting these functions cause the menu system to behave differently is there any explanation for this. These two functions are

1- game_startup
2- mouse_startup

main.c
Click to reveal..

//////////////////////////////////////////////////////////////////////////

#include <acknex.h>
#include "menu.c"

//////////////////////////////////////////////////////////////////////////

STRING* dummy_wmb = "dummy.wmb"; // this level is loaded while the menu is visible
STRING* level1_wmb = "level1.wmb"; // this will be the first level of the "real" game

/////////////////////////////////////////////////////////////////////////

function mouse_over(); // this function runs when the mouse is placed over one of the menu buttons

/////////////////////////////////////////////////////////////////////////

function main()
{
video_mode = 8; // start the game at 1024x768 pixels
video_screen = 1; // start in full screen mode
mouse_spot.x = 1; // make the tip of the arrow pointer the hot spot area
mouse_spot.y = 1; // (1, 1 on the mouse pointer bitmap)
master_vol = 70; // default volume
on_esc = quit_game;
level_load (dummy_wmb); // dummy level
wait (2);
set (main_pan, VISIBLE); // show the main panel
soundtrack_handle = media_loop("splash.mp3", NULL, soundtrack_volume); // play this track while the menu is being displayed
vec_set (camera.x, nullvector); // move the camera to the origin
while (game_started == 0) // this loop runs until the player presses the "New game" button
{
camera.pan += 0.1 * time_step; // rotate the camera gently
camera.tilt += 0.02 * time_step; // on all the axis
camera.roll += 0.05 * time_step;
wait (1);
}
}

function start_game() // this function starts running when the player presses the "New game" button on the main panel
{
reset (main_pan, VISIBLE); // hide the main menu panel
game_started = 1;
mouse_mode = 0; // hide the cursor
var temp_volume = 0;
temp_volume = soundtrack_volume; // store the current volume of the soundtrack
while (soundtrack_volume > 0) // decrease the volume for the main menu soundtrack gently
{
media_tune(soundtrack_handle, soundtrack_volume, 100, 0);
soundtrack_volume -= 4 * time_step; // 4 gives the fading out speed
wait (1);
}
media_stop (soundtrack_handle); // the volume is zero here, so we can stop the main menu soundtrack now
soundtrack_volume = temp_volume; // restore the initial volume of the soundtrack - it will be used for the following soundtracks
level_load (level1_wmb); // now load the real level
wait (3); // wait until the level is loaded
// media_loop("track1.mp3", NULL, soundtrack_volume);
camera.z = 250; // set the camera up high
camera.tilt = -90; // and then make it look down
}


function mouse_over() // this function runs when we move the mouse over one of the buttons on the panel
{
snd_play (mouseover_wav, sound_vol, 0);
}

function mouse_startup() // displays the mouse pointer
{
mouse_mode = 2;
mouse_map = cursor_tga;
while (game_started == 0) // this loop runs until the game is started
{
vec_set(mouse_pos, mouse_cursor);
wait (1);
}
}

ENTITY* sky_cube = // this is our main menu sky cube with the stars and the planet
{
type = "skycube+6.tga";
flags2 = SKY | CUBE | VISIBLE;
}

//////////////////////////////////////////////////////////////////////////////////////////

function test_startup()
{
while (1)
{
// if (total_frames%200 == 1) beep();
wait (1);
}
}


PANEL* debug_pan =
{
// digits(30,30,4,*,1, test1);
// digits(30,60,4,*,1, test2);
// flags = VISIBLE;
}


menu.c
Click to reveal..

/////////////////////////////////////////////////////////////////////////////////////////////////

var game_started = 0; // will be set to 1 when the game is started
var video_value = 8; // default resolution at game start (1024 x 768)
var soundtrack_handle = 0;
var soundtrack_volume = 80; // volume for the soundtrack
var viewing_distance = 5; // this value is multiplied by 1000 and gives the clipping range
var difficulty = 2; // default difficulty = student

/////////////////////////////////////////////////////////////////////////////////////////////////

BMAP* main_tga = "main.tga"; // main panel
BMAP* load1_pcx = "load1.pcx";
BMAP* load2_pcx = "load2.pcx";
BMAP* save1_pcx = "save1.pcx";
BMAP* save2_pcx = "save2.pcx";
BMAP* new1_pcx = "new1.pcx";
BMAP* new2_pcx = "new2.pcx";
BMAP* options1_pcx = "options1.pcx";
BMAP* options2_pcx = "options2.pcx";
BMAP* quit1_pcx = "quit1.pcx";
BMAP* quit2_pcx = "quit2.pcx";

BMAP* options_tga = "options.tga"; // options panel
BMAP* sound1_pcx = "sound1.pcx";
BMAP* sound2_pcx = "sound2.pcx";
BMAP* video1_pcx = "video1.pcx";
BMAP* video2_pcx = "video2.pcx";
BMAP* difficulty1_pcx = "difficulty1.pcx";
BMAP* difficulty2_pcx = "difficulty2.pcx";
BMAP* controls1_pcx = "controls1.pcx";
BMAP* controls2_pcx = "controls2.pcx";
BMAP* backoptions1_pcx = "backoptions1.pcx"; // used by the button that goes back from options to main
BMAP* backoptions2_pcx = "backoptions2.pcx"; // used by the button that goes back from options to main

BMAP* difficulty_tga = "difficulty.tga"; // difficulty panel
BMAP* chicken1_pcx = "chicken1.pcx";
BMAP* chicken2_pcx = "chicken2.pcx";
BMAP* student1_pcx = "student1.pcx";
BMAP* student2_pcx = "student2.pcx";
BMAP* hero1_pcx = "hero1.pcx";
BMAP* hero2_pcx = "hero2.pcx";
BMAP* master1_pcx = "master1.pcx";
BMAP* master2_pcx = "master2.pcx";
BMAP* backdifficulty1_pcx = "backdifficulty1.pcx"; // used by the button that goes back from difficulty to options
BMAP* backdifficulty2_pcx = "backdifficulty2.pcx"; // used by the button that goes back from difficulty to options

BMAP* chicken3_pcx = "chicken3.pcx";
BMAP* student3_pcx = "student3.pcx";
BMAP* hero3_pcx = "hero3.pcx";
BMAP* master3_pcx = "master3.pcx";

BMAP* sound_tga = "sound.tga";
BMAP* backsound1_pcx = "backsound1.pcx"; // used by the button that goes back from sound to options
BMAP* backsound2_pcx = "backsound2.pcx"; // used by the button that goes back from sound to options

BMAP* video_tga = "video.tga";
BMAP* backvideo1_pcx = "backvideo1.pcx"; // used by the button that goes back from video to options
BMAP* backvideo2_pcx = "backvideo2.pcx"; // used by the button that goes back from video to options

BMAP* cursor_tga = "cursor.tga";
BMAP* slider_pcx = "slider.pcx";

/////////////////////////////////////////////////////////////////////////////////////////////////

SOUND* mouseover_wav = "mouseover.wav";

/////////////////////////////////////////////////////////////////////////////////////////////////

function start_game();
function quit_game();
function set_options();
function options_to_main();
function set_sound();
function sound_to_options();
function video_to_options();
function difficulty_to_options();
function game_difficulty(button_number);
function set_difficulty();

/////////////////////////////////////////////////////////////////////////////////////////////////

PANEL* main_pan = // main panel
{
bmap = main_tga;
layer = 20;
pos_x = 220; // for now
pos_y = 200; // for now
button = 52, 28, load1_pcx, load1_pcx, load2_pcx, NULL, NULL, mouse_over;
button = 45, 87, save1_pcx, save1_pcx, save2_pcx, NULL, NULL, mouse_over;
button = 34, 153, new1_pcx, new1_pcx, new2_pcx, start_game, NULL, mouse_over;
button = 46, 225, options1_pcx, options1_pcx, options2_pcx, set_options, NULL, mouse_over;
button = 53, 290, quit1_pcx, quit1_pcx, quit2_pcx, quit_game, NULL, mouse_over;
}

PANEL* options_pan = // "options" panel
{
bmap = options_tga;
layer = 30; // appears over main_pan
pos_x = 0;
pos_y = 0;
button = 52, 29, sound1_pcx, sound1_pcx, sound2_pcx, set_sound, NULL, mouse_over;
button = 45, 88, video1_pcx, video1_pcx, video2_pcx, set_video, NULL, mouse_over;
button = 36, 154, difficulty1_pcx, difficulty1_pcx, difficulty2_pcx, set_difficulty, NULL, mouse_over;
button = 45, 224, controls1_pcx, controls1_pcx, controls2_pcx, NULL, NULL, mouse_over;
button = 53, 289, backoptions1_pcx, backoptions1_pcx, backoptions2_pcx, options_to_main, NULL, mouse_over;
}

PANEL* sound_pan = // sound panel
{
bmap = sound_tga;
layer = 40;
pos_x = 0;
pos_y = 0;
button = 53, 269, backsound1_pcx, backsound1_pcx, backsound2_pcx, sound_to_options, NULL, mouse_over;
hslider = 75, 64, 213, slider_pcx, 0, 100, sound_vol;
hslider = 75, 114, 213, slider_pcx, 0, 100, midi_vol;
hslider = 75, 164, 213, slider_pcx, 0, 100, cdaudio_vol;
hslider = 75, 214, 213, slider_pcx, 0, 100, master_vol;
}

PANEL* video_pan = // video panel
{
bmap = video_tga;
layer = 40;
pos_x = 0;
pos_y = 0;
button = 53, 269, backvideo1_pcx, backvideo1_pcx, backvideo2_pcx, video_to_options, NULL, mouse_over;
hslider = 75, 64, 213, slider_pcx, 6, 9, video_value;
hslider = 75, 114, 213, slider_pcx, 0, 100, NULL;
hslider = 75, 164, 213, slider_pcx, 1, 50, viewing_distance;
hslider = 75, 214, 213, slider_pcx, 50, 150, video_gamma;
}

PANEL* difficulty_pan = // difficulty panel
{
bmap = difficulty_tga;
layer = 40; // appears over main_pan
pos_x = 0;
pos_y = 0;
button = 53, 28, chicken1_pcx, chicken1_pcx, chicken2_pcx, game_difficulty, NULL, mouse_over;
button = 45, 86, student1_pcx, student1_pcx, student2_pcx, game_difficulty, NULL, mouse_over;
button = 35, 152, hero1_pcx, hero1_pcx, hero2_pcx, game_difficulty, NULL, mouse_over;
button = 46, 224, master1_pcx, master1_pcx, master2_pcx, game_difficulty, NULL, mouse_over;
button = 53, 289, backdifficulty1_pcx, backdifficulty1_pcx, backdifficulty2_pcx, difficulty_to_options, NULL, mouse_over;
}

PANEL* chicken_pan = // the following panels create the "highlighted" versions of the bitmaps on the "difficulty" panel
{
bmap = chicken3_pcx;
layer = 50;
pos_x = 53;
pos_y = 28;
}

PANEL* student_pan =
{
bmap = student3_pcx;
layer = 50;
pos_x = 45;
pos_y = 86;
}

PANEL* hero_pan =
{
bmap = hero3_pcx;
layer = 50;
pos_x = 35;
pos_y = 152;
}

PANEL* master_pan =
{
bmap = master3_pcx;
layer = 50;
pos_x = 53;
pos_y = 289;
}

/////////////////////////////////////////////////////////////////////////////////////////////////

function set_options()
{
while (mouse_left) {wait (1);}
set (options_pan, VISIBLE);
reset (main_pan, VISIBLE);
}

function options_to_main()
{
while (mouse_left) {wait (1);}
set (main_pan, VISIBLE);
reset (options_pan, VISIBLE);
}

function set_sound()
{
while (mouse_left) {wait (1);}
set (sound_pan, VISIBLE);
reset (options_pan, VISIBLE);
}

function sound_to_options()
{
while (mouse_left) {wait (1);}
set (options_pan, VISIBLE);
reset (sound_pan, VISIBLE);
}

function video_to_options()
{
while (mouse_left) {wait (1);}
set (options_pan, VISIBLE);
reset (video_pan, VISIBLE);
if (integer(video_value + 0.5) != video_mode) // the resolution has changed?
{
if (video_switch(video_value, 0, 0) == 0) // can't switch to the new resolution?
{
video_switch(7, 0, 0); // then default to 800x600 pixels, which should work fine on any decent system
}
}
}

function difficulty_to_options()
{
while (mouse_left) {wait (1);}
set (options_pan, VISIBLE);
reset (difficulty_pan, VISIBLE);
reset (chicken_pan, VISIBLE);
reset (student_pan, VISIBLE);
reset (hero_pan, VISIBLE);
reset (master_pan, VISIBLE);
}

function set_video()
{
while (mouse_left) {wait (1);}
set (video_pan, VISIBLE);
reset (options_pan, VISIBLE);
}

function game_difficulty(button_number)
{
if (button_number == 1)
{
difficulty = 1;
set (chicken_pan, VISIBLE);
reset (student_pan, VISIBLE);
reset (hero_pan, VISIBLE);
reset (master_pan, VISIBLE);
}
if (button_number == 2)
{
difficulty = 2;
reset (chicken_pan, VISIBLE);
set (student_pan, VISIBLE);
reset (hero_pan, VISIBLE);
reset (master_pan, VISIBLE);
}
if (button_number == 3)
{
difficulty = 3;
reset (chicken_pan, VISIBLE);
reset (student_pan, VISIBLE);
set (hero_pan, VISIBLE);
reset (master_pan, VISIBLE);
}
if (button_number == 4)
{
difficulty = 4;
reset (chicken_pan, VISIBLE);
reset (student_pan, VISIBLE);
reset (hero_pan, VISIBLE);
set (master_pan, VISIBLE);
}
}

function set_difficulty()
{
while (mouse_left) {wait (1);}
set (difficulty_pan, VISIBLE);
reset (options_pan, VISIBLE);
if (difficulty == 1) {set (chicken_pan, VISIBLE);}
if (difficulty == 2) {set (student_pan, VISIBLE);}
if (difficulty == 3) {set (hero_pan, VISIBLE);}
if (difficulty == 4) {set (master_pan, VISIBLE);}
}

function quit_game()
{
sys_exit(NULL);
}

function game_startup()
{
while (1)
{
// first of all, calculate pos_x and pos_y for all the panels
// to make sure that they are centered at any resolution
main_pan.pos_x = (screen_size.x - bmap_width(main_tga)) / 2;
main_pan.pos_y = (screen_size.y - bmap_height(main_tga)) / 2;
options_pan.pos_x = (screen_size.x - bmap_width(options_tga)) / 2;
options_pan.pos_y = (screen_size.y - bmap_height(options_tga)) / 2;
sound_pan.pos_x = (screen_size.x - bmap_width(sound_tga)) / 2;
sound_pan.pos_y = (screen_size.y - bmap_height(sound_tga)) / 2;
video_pan.pos_x = (screen_size.x - bmap_width(video_tga)) / 2;
video_pan.pos_y = (screen_size.y - bmap_height(video_tga)) / 2;
difficulty_pan.pos_x = (screen_size.x - bmap_width(difficulty_tga)) / 2;
difficulty_pan.pos_y = (screen_size.y - bmap_height(difficulty_tga)) / 2;

chicken_pan.pos_x = difficulty_pan.pos_x + 53; // offset on the difficulty panel
chicken_pan.pos_y = difficulty_pan.pos_y + 28; // offset on the difficulty panel
student_pan.pos_x = difficulty_pan.pos_x + 45; // offset on the difficulty panel
student_pan.pos_y = difficulty_pan.pos_y + 86; // offset on the difficulty panel
hero_pan.pos_x = difficulty_pan.pos_x + 35; // offset on the difficulty panel
hero_pan.pos_y = difficulty_pan.pos_y + 152; // offset on the difficulty panel
master_pan.pos_x = difficulty_pan.pos_x + 46; // offset on the difficulty panel
master_pan.pos_y = difficulty_pan.pos_y + 224; // offset on the difficulty panel

camera.clip_far = viewing_distance * 1000; // set camera.clip_far according to the viewing_distance slider
wait (1);
}
}