ide
This commit is contained in:
		
							parent
							
								
									7464cedbed
								
							
						
					
					
						commit
						b0199eed16
					
				
							
								
								
									
										40
									
								
								du8/game.c
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								du8/game.c
									
									
									
									
									
								
							@ -12,19 +12,39 @@ void init_game(GameState *state) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void draw_game(const GameState *state) {
 | 
					void draw_game(const GameState *state) {
 | 
				
			||||||
    world_clear();
 | 
					    world_clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Vykresli mriežku a symboly
 | 
				
			||||||
    for (int y = 0; y < BOARD_SIZE; y++) {
 | 
					    for (int y = 0; y < BOARD_SIZE; y++) {
 | 
				
			||||||
        for (int x = 0; x < BOARD_SIZE; x++) {
 | 
					        for (int x = 0; x < BOARD_SIZE; x++) {
 | 
				
			||||||
            int wx = 5 + x * 4;
 | 
					            char symbol = state->board[y][x];
 | 
				
			||||||
            int wy = 3 + y * 2;
 | 
					            if (symbol == '\0') symbol = ' ';
 | 
				
			||||||
            if (x == state->cursor_x && y == state->cursor_y)
 | 
					            world_draw_char(x * 4 + 2, y * 2 + 1, symbol);
 | 
				
			||||||
                world_draw_char(wx, wy, state->board[y][x], COLOR_RED);
 | 
					
 | 
				
			||||||
            else
 | 
					            // Nakresli mriežku
 | 
				
			||||||
                world_draw_char(wx, wy, state->board[y][x], COLOR_WHITE);
 | 
					            if (x < BOARD_SIZE - 1) {
 | 
				
			||||||
 | 
					                world_draw_char(x * 4 + 3, y * 2 + 1, '|');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (y < BOARD_SIZE - 1) {
 | 
				
			||||||
 | 
					            for (int i = 0; i < BOARD_SIZE * 4 - 1; i++) {
 | 
				
			||||||
 | 
					                world_draw_char(i + 1, y * 2 + 2, '-');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    world_draw_text(0, 0, "Hráč: %c", state->current_player ? 'O' : 'X');
 | 
					
 | 
				
			||||||
    if (state->game_over)
 | 
					    // Zvýrazni kurzor
 | 
				
			||||||
        world_draw_text(0, 1, "Koniec hry! Stlač Q na ukončenie.");
 | 
					    world_draw_char(state->cursor_x * 4 + 2, state->cursor_y * 2 + 1,
 | 
				
			||||||
 | 
					        state->current_player == 0 ? 'X' : 'O');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Zobraz aktuálneho hráča
 | 
				
			||||||
 | 
					    world_draw_text(0, BOARD_SIZE * 2 + 2,
 | 
				
			||||||
 | 
					        state->current_player == 0 ? "Hrac: X" : "Hrac: O");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Zobraz info, ak hra skoncila
 | 
				
			||||||
 | 
					    if (state->game_over) {
 | 
				
			||||||
 | 
					        world_draw_text(0, BOARD_SIZE * 2 + 3, "Koniec hry! Stlac Q pre ukoncenie.");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    world_display();
 | 
					    world_display();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -62,4 +82,4 @@ void handle_key(GameState *state, int key) {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user