Изменил(а) на 'a3/game.c'
This commit is contained in:
parent
6c9e4da9e8
commit
8ca7a135e9
70
a3/game.c
70
a3/game.c
@ -21,52 +21,66 @@ int game_event(struct event* event,void* game){
|
||||
char msg[200];
|
||||
sprintf(msg,"%d",event->type);
|
||||
set_message(msg,10,0);
|
||||
int mouse_count = 0;
|
||||
if ( event->type == EVENT_ESC){
|
||||
return 1;
|
||||
}
|
||||
int count = 0;
|
||||
for(int i = 0; i < 5; i++) {
|
||||
for (int i = 0; i < 5;i++){
|
||||
if ((state->caty_position == state->mousey[i]) && (state->catx_position == state->mousex[i])) {
|
||||
count = 1;
|
||||
state->mousey[i] = 0;
|
||||
state->mouse_state[i] = 1;
|
||||
state->mousex[i] = 0;
|
||||
if (state->mousex[i] == 0 && state->mousey[i] == 0) {
|
||||
count++;
|
||||
if (count == 5) {
|
||||
set_message("HAM", 12, 13);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
state->mousey[i] = 0;
|
||||
}
|
||||
if(state->mouse_state[i] == 1){
|
||||
mouse_count++;
|
||||
if(mouse_count == 5){
|
||||
clear_screen();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count == 0){
|
||||
count = 2;
|
||||
if(event->type == EVENT_TIMEOUT) {
|
||||
int cx = state->catx_position + state->catx;
|
||||
int cy = state->caty_position + state->caty;
|
||||
if (cx < 12 || cy < 11 || cx > 38 || cy > 18){
|
||||
return 0;
|
||||
if (cx < 11 || cy < 11 || cx > 38 || cy > 18){
|
||||
|
||||
}
|
||||
else {
|
||||
state->catx_position = cx;
|
||||
state->caty_position = cy;
|
||||
}
|
||||
//for(int i = 0; i < 5; i++){
|
||||
/*int m = rand() % 6;
|
||||
if (m == 0){
|
||||
state->mousey[i] -= 1;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int m = rand() % 6;
|
||||
if(state->mouse_state[i] == 0){
|
||||
if (m == 0) {
|
||||
if (state->mousey[i] == 12) {
|
||||
state->mousey[i] = 13;
|
||||
}
|
||||
state->mousey[i] -= 1;
|
||||
} else if (m == 1) {
|
||||
if (state->mousey[i] == 18) {
|
||||
state->mousey[i] = 17;
|
||||
}
|
||||
state->mousey[i] += 1;
|
||||
} else if (m == 2) {
|
||||
if (state->mousex[i] == 12) {
|
||||
state->mousex[i] = 13;
|
||||
}
|
||||
state->mousex[i] -= 1;
|
||||
} else if (m == 3) {
|
||||
if (state->mousex[i] == 38) {
|
||||
state->mousex[i] = 37;
|
||||
}
|
||||
state->mousex[i] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m == 1){
|
||||
state->mousey[i] += 1;
|
||||
}
|
||||
else if (m == 2){
|
||||
state->mousex[i] -= 1;
|
||||
}
|
||||
else if (m == 3){
|
||||
state->mousex[i] += 1;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if(count == 2){
|
||||
if (event->type == EVENT_KEY){
|
||||
@ -106,8 +120,10 @@ refresh();
|
||||
//set_color_cell('-',state->catx_position-1,state->caty_position,COLOR_YELLOW,COLOR_GREEN);
|
||||
|
||||
for(int i = 0; i < 5; i++){
|
||||
if(state->mouse_state[i] == 0){
|
||||
set_cell('m',state->mousex[i],state->mousey[i]);
|
||||
}
|
||||
}
|
||||
set_message( state->message,1,0);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user