@@ -26,6 +26,16 @@ ball_data balls[16];
2626enum gamestates {start , setup , animate , run };
2727int gamestate = setup ;
2828
29+ bool start_of_setup = false;
30+
31+ // player turns
32+ bool is_player_1_turn = true;
33+ bool extra_turn = false;
34+ gfx_sprite_t * player_1_type = NULL ;
35+
36+ int num_stripes = 7 ;
37+ int num_solids = 7 ;
38+
2939// frame for animation of cue
3040int frame = 0 ;
3141
@@ -89,13 +99,26 @@ bool step(void) {
8999
90100 if (gamestate == setup ) {
91101
92- // scratch
93- if (balls [15 ].pocketed ) {
94- balls [15 ].x = 67 ;
95- balls [15 ].y = 81 ;
96- balls [15 ].pocketed = false;
102+ if (start_of_setup ) {
103+
104+ if (balls [15 ].pocketed ) { // scratch
105+ balls [15 ].x = 67 ;
106+ balls [15 ].y = 81 ;
107+ balls [15 ].pocketed = false;
108+ extra_turn = false;
109+ }
110+
111+ // if player sunk own ball, dont switch
112+ if (!extra_turn )
113+ is_player_1_turn = !is_player_1_turn ;
114+ else
115+ extra_turn = false;
116+
117+ start_of_setup = false;
97118 }
98119
120+
121+
99122 // speed multiplier for power and angle
100123 if (kb_Data [1 ] & kb_2nd ) {
101124 speedmult = 4 ;
@@ -160,7 +183,7 @@ bool step(void) {
160183 balls [i ].y -= balls [i ].vy ;
161184 }
162185
163- check_pockets (& balls [i ]);
186+ check_pockets (& balls [i ], & extra_turn , & num_solids , & num_stripes , is_player_1_turn , & player_1_type );
164187
165188 collidewalls (& balls [i ]); // this jawn worked well enough without multiple per frame
166189
@@ -179,8 +202,10 @@ bool step(void) {
179202 }
180203
181204 // if the counter it equal to the number of balls, end the run state
182- if (num_stopped == 16 )
205+ if (num_stopped == 16 ) {
183206 gamestate = setup ;
207+ start_of_setup = true;
208+ }
184209
185210 }
186211
@@ -206,6 +231,10 @@ void draw(void) {
206231 // for (int i = 0; i < 6; i++) {
207232 // gfx_Circle(pocket_x[i], pocket_y[i], 8);
208233 // }
234+
235+
236+ // draw player stuff
237+ draw_players (player_1_type , is_player_1_turn );
209238
210239 // draw balls
211240 for (int i = 0 ; i < 16 ; i ++ ) {
0 commit comments