void RemoteServerProxy::init_game() { Logger::info("RemoteServerProxy::init_game"); MessageReader reader(socket_); GameInitMessage message = reader.read_game_init(); message.read(); update_lives(message.info().remaining_lives()); for (std::vector<GameObjectMessage *>::const_iterator i = message.objects().begin(); i != message.objects().end(); i++) { create_object_renderer((*i)->object_id(), (*i)->object_type(), (*i)->position(), (*i)->points()); } }
// Updates all nescessary sprites, images, buttons etc. void update(void) { static _Bool called = false; GDATAPTR game = get_game_data(); update_background(); if(game->gamestarted && game->paused) { paused(score, survival_time, lives); } else if(lives == 0) { gameover(score, survival_time); } else if(game->gamestarted) { if(!called) { //cpSpaceResizeStaticHash(get_global_cpSpace(), 700.0, 4*10); cpSpaceAddCollisionHandler(get_global_cpSpace(), 1, 2, collision_begin, NULL, NULL, NULL, NULL); cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 2, collision_static_begin, NULL, NULL, NULL, NULL); cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 1, collision_static_begin, NULL, NULL, NULL, NULL); called = false; } logic(); update_clouds(); cpSpaceStep(get_global_cpSpace(), 1.0f/60.0f); cpSpaceEachBody(get_global_cpSpace(), &update_sprites, NULL); update_ground(); update_lives(); add_element_to_render_queue(NULL, 0, 0, 0, RCOLOR(0, 0, 0, 255), update_score); add_element_to_render_queue(NULL, 290, 0, 0, RCOLOR(0, 0, 0, 255), update_survivaltime); } else if(game->options) { options(); } else if(game->howtoplay) { howtoplay(); } else if(game->highscores) { highscores(); } }