Изменил(а) на 'a3/game.c'
This commit is contained in:
parent
8ca7a135e9
commit
a9ac59407f
15
a3/game.c
15
a3/game.c
@ -3,6 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include <time.h>
|
||||||
void* init_game(){
|
void* init_game(){
|
||||||
struct game* st = calloc(1,(sizeof(struct game)));
|
struct game* st = calloc(1,(sizeof(struct game)));
|
||||||
for(int i = 0; i < 5; i++){
|
for(int i = 0; i < 5; i++){
|
||||||
@ -106,25 +107,33 @@ int game_event(struct event* event,void* game){
|
|||||||
// Draw world state
|
// Draw world state
|
||||||
clear_screen();
|
clear_screen();
|
||||||
initscr();
|
initscr();
|
||||||
|
start_color();
|
||||||
|
init_pair(1, COLOR_BLUE, COLOR_BLUE); // цветовая пара для стен - белый на голубом
|
||||||
|
init_pair(2, COLOR_BLACK, COLOR_BLACK); // цветовая пара для мышей - черный на белом
|
||||||
|
|
||||||
for (int y = 10; y < 20; y++) {
|
for (int y = 10; y < 20; y++) {
|
||||||
for (int x = 10; x < 40; x++) {
|
for (int x = 10; x < 40; x++) {
|
||||||
if (x == 10 || y == 10 || x == 39 || y == 19) {
|
if (x == 10 || y == 10 || x == 39 || y == 19) {
|
||||||
|
attron(COLOR_PAIR(1)); // включаем цветовую пару для стен
|
||||||
mvaddch(y, x, '#');
|
mvaddch(y, x, '#');
|
||||||
|
attroff(COLOR_PAIR(1)); // выключаем цветовую пару для стен
|
||||||
} else {
|
} else {
|
||||||
|
attron(COLOR_PAIR(2)); // включаем цветовую пару для мышей
|
||||||
mvaddch(y, x, ' ');
|
mvaddch(y, x, ' ');
|
||||||
|
attroff(COLOR_PAIR(2)); // выключаем цветовую пару для мышей
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refresh();
|
|
||||||
|
refresh();
|
||||||
set_color_cell('c',state->catx_position,state->caty_position,COLOR_YELLOW,COLOR_RED);
|
set_color_cell('c',state->catx_position,state->caty_position,COLOR_YELLOW,COLOR_RED);
|
||||||
//set_color_cell('-',state->catx_position-1,state->caty_position,COLOR_YELLOW,COLOR_GREEN);
|
//set_color_cell('-',state->catx_position-1,state->caty_position,COLOR_YELLOW,COLOR_GREEN);
|
||||||
|
|
||||||
for(int i = 0; i < 5; i++){
|
for(int i = 0; i < 5; i++){
|
||||||
if(state->mouse_state[i] == 0){
|
if(state->mouse_state[i] == 0){
|
||||||
set_cell('m',state->mousex[i],state->mousey[i]);
|
set_color_cell('m',state->mousex[i],state->mousey[i],COLOR_BLACK,COLOR_WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_message( state->message,1,0);
|
set_message( state->message,1,0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user