void Tournament::player_dies(Player *p, const std::string& die_message) { player_died(p); p->state.server_state.health = 0; p->state.server_state.flags |= PlayerServerFlagDead; p->state.server_state.kills++; if (die_message.length()) { add_msg_response(die_message.c_str()); } try { Animation *tempani = resources.get_animation(properties.get_value("die_animation")); GAnimation *ani = new GAnimation; memset(ani, 0, sizeof(GAnimation)); strncpy(ani->animation_name, tempani->get_name().c_str(), NameLength - 1); strncpy(ani->sound_name, properties.get_value("die_sound").c_str(), NameLength - 1); TileGraphic *tg = p->get_characterset()->get_tile(DirectionLeft, CharacterAnimationStanding)->get_tilegraphic(); TileGraphic *tga = tempani->get_tile()->get_tilegraphic(); int x = static_cast<int>(p->state.client_server_state.x) + tg->get_width() / 2 - tga->get_width() / 2; int y = static_cast<int>(p->state.client_server_state.y) - tg->get_height() / 2 - tga->get_height() / 2; ani->id = ++animation_id; ani->x = x; ani->y = y; ani->to_net(); add_state_response(GPCAddAnimation, sizeof(GAnimation), ani); } catch (const Exception& e) { subsystem << e.what() << std::endl; } }
void game_main(void) { int i; int sum; if (game_init() < 0) { printk("game_init() failed"); return; } while(player[0].lifes > 0) { rt_task_wait_period(NULL); if(player[0].enable == 0) { //printk("player died\n"); player_died(); //printk("player lifes: %d\n", player[0].lifes); } sum = 0; for(i = 0; i < nbEnnemis; i++) { sum += ennemi[i].enable; } if(sum == 0) { level_up(); } } tri_score(); if (end_game() < 0) { printk("end_game() failed"); return; } }
int main() { printf_s("\n\n\n\n\n\n\n\n"); while(player_status){ enemys_alive(); enemys_movement(); draw_game(); events(); Sleep(100); time++; printf_s(" Score:%d", score); printf_s("\r"); } player_died(); getchar(); return 0; }