Skip to content

Commit

Permalink
Menu settings are saved in-between matches
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Vanderstuyft committed Aug 22, 2014
1 parent 3732067 commit 880abdb
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 39 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Some small tasks to improve usability and gameplay:
---------------------------------------------------

- [x] During menus, ESC key can be used to go back to the previous menu.
- [ ] Menu settings are saved in-between matches to allow quickly restarting a match with the same settings.
- [x] Menu settings are saved in-between matches to allow quickly restarting a match with the same settings.
- [ ] Turbo remains activated until the 'turbo-fuel' is empty, also while you pick another type of powerup (e.g. 'Missile').
- [ ] Powerups spawn at a certain distance from the player.

Expand Down
2 changes: 1 addition & 1 deletion machineball-src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mbdata_c_h : mbdata.dat
dat2c mbdata.dat -o mbdata.c -h mbdata.h -p mb -g

mbdata.dat :
/usr/bin/dat mbdata.dat -f -c2 -a data/*
dat mbdata.dat -f -c2 -a data/*


# 'make clean' will clean up the build-directory
Expand Down
Binary file modified machineball-src/machineball
Binary file not shown.
35 changes: 25 additions & 10 deletions machineball-src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,26 @@ int main(int argc, char **argv)
showIntro();

int menuChoice;
int courtSize;
int ballChoice;
int courtSize = 1;
int ballChoice = 0;
int responce = 0;
int escpress = 0;

gameoptions o;
gameoptions p;

p = o;
int timegoallimit=0;
int timegoals=2;
int powerupsenabled=1;
int powerupfrequency=1;
int preventstuck=1;

int turbo=200;
int shield=200;
int mine=200;
int missle=200;
int meshatek=200;

do
{
int setup=0;
Expand All @@ -230,27 +241,31 @@ int main(int argc, char **argv)
{
while(setup == 1)
{

courtSize = courtMenu();
int cs = courtSize;
courtSize = courtMenu(courtSize);
setup++;
if(courtSize==4){setup = 0;}
if(courtSize==4){setup = 0; courtSize = cs;}

This comment has been minimized.

Copy link
@Eliasvan

Eliasvan Aug 29, 2014

Owner

Je mag gerust een nieuwe lijn beginnen, hoor ;)

while(setup == 2)
{

if(setup == 2 && escpress == 0)
{
rest(100);
ballChoice = ballMenu();
int bc = ballChoice;
ballChoice = ballMenu(ballChoice);
setup++;
if(ballChoice==6){setup = 1;}
if(ballChoice==6){setup = 1;ballChoice = bc;}
}
if(setup == 3 && escpress == 0)
{
p=o;

responce = gameoptionsMenu(&o);
responce = gameoptionsMenu(&o,timegoallimit,timegoals,powerupsenabled,powerupfrequency,preventstuck,turbo,shield,mine,missle,meshatek);

This comment has been minimized.

Copy link
@Eliasvan

Eliasvan Aug 29, 2014

Owner

Het zou properder zijn als je hiervoor een 'struct' gebruikt die dan al deze variabelen bevat.

setup++;
timegoallimit = o.timegoallimit; timegoals = o.timegoals; powerupsenabled = o.powerupsenabled; powerupfrequency = o.powerupfrequency;
preventstuck = o.preventstuck; turbo = o.turbo; shield = o.shield; mine = o.mine; missle = o.missle; meshatek = o.meshatek;

This comment has been minimized.

Copy link
@Eliasvan

Eliasvan Aug 29, 2014

Owner

Hier ook, het zou properder zijn als je hiervoor een 'struct' gebruikt, dan hoef je maar 1 toewijzing te doen.

if(responce == 1){o = p;setup = 2;escpress = 1;}


}
if(!key[KEY_ESC]){escpress = 0;}
}
Expand Down
52 changes: 28 additions & 24 deletions machineball-src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ int mainMenu(void)
int choice=0;
int upkey=0, downkey=0;
int esc=0;
while(!(key[KEY_ENTER] || (key[KEY_ESC] && esc > 6) || key[KEY_SPACE] || controls[0].keydown(KEYFIRE) || controls[0].keydown(KEYSPECIAL)))
int esc2=0;
while(!(key[KEY_ENTER] || (key[KEY_ESC] && esc == 1) || key[KEY_SPACE] || controls[0].keydown(KEYFIRE) || controls[0].keydown(KEYSPECIAL)))
{
rest(1);
if(key[KEY_ESC]){esc++;}
if(key[KEY_ESC]){esc2=1;}
if(!key[KEY_ESC] && esc2 == 1){esc = 1;}
i+=timer.seconds()/2.0;
timer.reset();

Expand Down Expand Up @@ -213,7 +215,7 @@ int mainMenu(void)
allegro_gl_end();
}
play_sample(&mb_menusel_wav, 255, 128, 1000, 0);
while(key[KEY_ENTER] || (key[KEY_ESC] && esc > 6) || key[KEY_SPACE] || controls[0].keydown(KEYFIRE) || controls[0].keydown(KEYSPECIAL))
while(key[KEY_ENTER] || (key[KEY_ESC] && esc ==1) || key[KEY_SPACE] || controls[0].keydown(KEYFIRE) || controls[0].keydown(KEYSPECIAL))
{
if(key[KEY_ESC]){choice = 3;}
poll_joystick();
Expand All @@ -227,7 +229,7 @@ int mainMenu(void)
return choice;
}

int ballMenu(void)
int ballMenu(int ballchoice)
{
allegro_gl_begin();
glMatrixMode(GL_PROJECTION);
Expand Down Expand Up @@ -292,7 +294,7 @@ int ballMenu(void)

timer.install();
double i=0;
int choice=0;
int choice=ballchoice;
int leftkey=0, rightkey=0;
while(!(key[KEY_ENTER] || key[KEY_SPACE] || controls[0].keydown(KEYFIRE) || controls[0].keydown(KEYSPECIAL)))
{
Expand Down Expand Up @@ -451,7 +453,7 @@ int ballMenu(void)
return choice;
}

int courtMenu(void)
int courtMenu(int cs1)

This comment has been minimized.

Copy link
@Eliasvan

Eliasvan Aug 29, 2014

Owner

Probeer je benamingen consistent te houden met de andere menu's zoals bij ballMenu().

{
allegro_gl_begin();
glMatrixMode(GL_PROJECTION);
Expand Down Expand Up @@ -495,7 +497,7 @@ int courtMenu(void)

timer.install();
double i=0;
int cs=1;
int cs=cs1;
int leftkey=0, rightkey=0;
while(!(key[KEY_ENTER] || key[KEY_SPACE] || controls[0].keydown(KEYFIRE) || controls[0].keydown(KEYSPECIAL)))
{
Expand Down Expand Up @@ -777,19 +779,19 @@ int courtMenu(void)
return cs;
}

int gameoptionsMenu(gameoptions *op)
int gameoptionsMenu(gameoptions *op,int o1,int o2,int o3,int o4,int o5,int o6,int o7,int o8,int o9,int o10)
{
op->timegoallimit=0;
op->timegoals=2;
op->powerupsenabled=1;
op->powerupfrequency=1;
op->preventstuck=1;
op->timegoallimit=o1;
op->timegoals=o2;
op->powerupsenabled=o3;
op->powerupfrequency=o4;
op->preventstuck=o5;

op->turbo=200;
op->shield=200;
op->mine=200;
op->missle=200;
op->meshatek=200;
op->turbo=o6;
op->shield=o7;
op->mine=o8;
op->missle=o9;
op->meshatek=o10;

allegro_gl_begin();
glMatrixMode(GL_PROJECTION);
Expand Down Expand Up @@ -1162,21 +1164,22 @@ int gameoptionsMenu(gameoptions *op)
allegro_gl_end();
}
play_sample(&mb_menusel_wav, 255, 128, 1000, 0);
int output = 0;
while(key[KEY_ENTER] || key[KEY_ESC] || key[KEY_SPACE] || controls[0].keydown(KEYFIRE) || controls[0].keydown(KEYSPECIAL))
{
if(key[KEY_ESC]){return 1;}
else{return 0;}
if(key[KEY_ESC]){output = 1;}
poll_joystick();
al_poll_duh(dp);
}
allegro_gl_begin();
glDeleteTextures(1, &pat01tex);
glDeleteTextures(1, &pat02tex);
allegro_gl_end();

al_stop_duh(dp);
menumusicisplaying=0;

if(output == 0)
{
al_stop_duh(dp);
menumusicisplaying=0;
}
if(op->timegoals==0)
op->timegoals=1;
else if(op->timegoals==1)
Expand All @@ -1198,6 +1201,7 @@ int gameoptionsMenu(gameoptions *op)
op->powerupfrequency=10;
else if(op->powerupfrequency==3)
op->powerupfrequency=30;
return(output);

This comment has been minimized.

Copy link
@Eliasvan

Eliasvan Aug 29, 2014

Owner

Haakjes zijn niet echt verplicht bij return-statements.

}

void humancompmessage(void)
Expand Down
6 changes: 3 additions & 3 deletions machineball-src/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include "game.h"

int mainMenu(void);
int ballMenu(void);
int courtMenu(void);
int gameoptionsMenu(gameoptions *op);
int ballMenu(int ballchoice);
int courtMenu(int cs1);
int gameoptionsMenu(gameoptions *op,int o1,int o2,int o3,int o4,int o5,int o6,int o7,int o8,int o9,int o10);

int optionsMenu(void);
void audioMenu(void);
Expand Down

0 comments on commit 880abdb

Please sign in to comment.