bool Scene::run() { Graphics* ptr_graphics = Graphics::instance(); Audio* ptr_audio = Audio::instance(); TextureCache* ptr_texture_cache = TextureCache::instance(); InputManager* ptr_inputManager = new InputManager(); m_frame_timer.start(m_millis_per_frame); on_setup(); setup_sprites(); on_begin(); while (!m_scene_is_ended) { ptr_inputManager->update(); on_check_input(ptr_inputManager); if (!m_is_paused) { handle_messages(); on_detect_collisions(); on_update(); update_sprites(); ptr_graphics->begin_render(); on_render(ptr_graphics); ptr_graphics->end_render(); } while (!m_frame_timer.has_elapsed()); } cleanup_sprites(); on_cleanup(); return !m_game_is_ended; }
/** * @brief Calls the on_update() method of a Lua game. * @param game A game. */ void LuaContext::game_on_update(Game& game) { push_game(l, game.get_savegame()); on_update(); menus_on_update(-1); lua_pop(l, 1); }
/** * \brief Calls sol.main.on_update() if it exists. * * This function is called at each cycle by the main loop. */ void LuaContext::main_on_update() { push_main(l); on_update(); menus_on_update(-1); lua_pop(l, 1); }
/** * \brief Calls the on_update() method of a Lua menu. * \param menu_ref A reference to the menu object. */ void LuaContext::menu_on_update(const ScopedLuaRef& menu_ref) { push_ref(l, menu_ref); on_update(); menus_on_update(-1); // Update children menus if any. lua_pop(l, 1); }
void update(float timestep) { now += timestep; for (auto it = begin(tweens); it != end(tweens);) { if (now < it->t1) { it->on_update(static_cast<float>((now - it->t0) / (it->t1 - it->t0))); ++it; } else { it->on_update(1.0f); it = tweens.erase(it); } } }
int checkpoints::add(checkpoint_t const& checkpoint, checkpoint_event_t const& on_enter, checkpoint_event_t const& on_leave) { int id = checkpoint_streamer.item_add(checkpoint); if (static_cast<std::size_t>(id) >= checkpoints_data.size()) { checkpoints_data.resize(id + 1); } checkpoints_data[id] = checkpoint_data_t(on_enter, on_leave); on_update(); return id; }
void application::perform_idle() { on_update(); if (m_ready) { begin_render(); on_render(); end_render(); } }
void device::update() { if (state()) { on_update(); for(sensor::shared_ptr s : sensors_) { s->update(); } } }
void update() { on_update(); if (m_current_scene) m_current_scene->update(); if (m_next_scene) { m_current_scene.swap(m_next_scene); m_next_scene.reset(); } glfwPollEvents(); Keyboard::update(); }
void update() { on_update(); for (auto&& obj : m_objects) obj->update(); // retain auto it = std::remove_if( std::begin(m_objects), std::end(m_objects), [](std::unique_ptr<Object> const& obj) { return !obj->is_alive(); }); m_objects.erase(it, std::end(m_objects)); }
/** * \brief Calls the on_update() method of a Lua equipment item. * * Does nothing if the method is not defined. * * \param item An equipment item. */ void LuaContext::item_on_update(EquipmentItem& item) { // This particular method is tried so often that we want to save optimize // the std::string construction. static const std::string method_name = "on_update"; if (!userdata_has_field(item, method_name)) { return; } push_item(l, item); on_update(); lua_pop(l, 1); }
void DistributedObject::updated() { BlockWriteLock lock(*this); /* Handle the update for this object */ on_update(lock); /* Recursively update all children */ BOOST_FOREACH(DistributedObjectPtr p, children_) { if (p) p->updated(); } }
/** * \brief Calls the on_update() method of a Lua game if it is defined. * * Also calls the method on its menus. * * \param game A game. */ void LuaContext::game_on_update(Game& game) { if (!game.get_savegame().is_known_to_lua()) { return; } push_game(l, game.get_savegame()); // This particular method is tried so often that we want to save optimize // the std::string construction. static const std::string method_name = "on_update"; if (userdata_has_field(game.get_savegame(), method_name)) { on_update(); } menus_on_update(-1); lua_pop(l, 1); }
void scene::update() { if (state == state_enter) { on_enter(); state = state_update; return; } if (state == state_exit) { on_exit(); return; } on_update(); }
void msg_server::update() { if(_is_stop) { return; } static boost::system_time start_time; start_time = boost::get_system_time(); while(1) { // lock lock lock boost::mutex::scoped_lock lock(_queue_mutex); if(!_msg_queue.empty()) { na::msg::msg_json::ptr p = _msg_queue.front(); _msg_queue.pop(); // unlock lock.unlock(); std::string logstr = "[NID:"; logstr += boost::lexical_cast<string,int>(p->_net_id); logstr += "] [PID:"; logstr += boost::lexical_cast<string,int>(p->_player_id); logstr += "] [TYPE:"; logstr += boost::lexical_cast<string,short>(p->_type); logstr += "]"; time_logger l(logstr.c_str()); on_recv_msg(p); } else break; boost::system_time end_time = boost::get_system_time(); if((end_time - start_time).total_milliseconds() >= 100) { break; } } on_update(); na::time_helper::sleep(100); net_core.get_logic_io_service().post(boost::bind(&msg_server::update,this)); }
void hook_on_event(const Level *level, Event *ev) { switch (ev->base.type) { case EVENT_TYPE_UPDATE: on_update(level, &ev->update_event); break; case EVENT_TYPE_FLOW: on_flow(level, &ev->flow_event); break; case EVENT_TYPE_GROW: on_grow(level, &ev->grow_event); break; default: break; } }
void output_impl::update(bool & p_ready) { on_update(); if (m_incoming_spec != m_active_spec && m_incoming_ptr < m_incoming.get_size()) { if (get_latency_samples() == 0) { open(m_incoming_spec); m_active_spec = m_incoming_spec; } else { force_play(); } } if (m_incoming_spec == m_active_spec && m_incoming_ptr < m_incoming.get_size()) { t_size cw = can_write_samples() * m_incoming_spec.m_channels; t_size delta = pfc::min_t(m_incoming.get_size() - m_incoming_ptr,cw); if (delta > 0) { write(audio_chunk_temp_impl(m_incoming.get_ptr()+m_incoming_ptr,delta / m_incoming_spec.m_channels,m_incoming_spec.m_sample_rate,m_incoming_spec.m_channels,m_incoming_spec.m_channel_config)); m_incoming_ptr += delta; } } p_ready = (m_incoming_ptr == m_incoming.get_size()); }
/* Thread to sample the input and use the update callback on_update when sensor values change. on_update will run the limits test and set the notification event trigger accordingly. Also checks for the event trigger and sends a notification packet in this thread. This allows the notification trigger to be set in a hardware timer ISR without blocking the ISR with a network operation. */ static void LWM2M_notification_thread(void const *args) { while (true){ wait(.1); current_sample = LWM2M_Sensor.read() * (float) 100; // if this csample is different from last sample, then call the resource on_update if((current_sample != last_sample) && LWM2M_observing){ //pc.printf("LWM2M resource update: %3.1f => %3.1f\r\n", last_sample, current_sample); last_sample = current_sample; on_update(current_sample); // callback to process notification attributes } // if triggered and in observing mode, build and send the notification packet if (notification_trigger && LWM2M_observing){ if (pmax_exceeded){ pc.printf("pmax exceeded\r\n"); pmax_exceeded = false; } if (pmin_trigger){pc.printf("pmin trigger\r\n"); pmin_trigger = false; } sprintf(LWM2M_value_string, "%3.1f", notify_sample); pc.printf("Sending: %s\r\n", LWM2M_value_string); LWM2M_obs_number++; if(sn_nsdl_send_observation_notification (LWM2M_obs_token_ptr, LWM2M_obs_token_len, (uint8_t*)LWM2M_value_string, strlen(LWM2M_value_string), &LWM2M_obs_number, sizeof(LWM2M_obs_number), COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0){ pc.printf("LWM2M notification failed\r\n"); } else{ pc.printf("LWM2M notification\r\n"); notification_trigger = false; } } } }
void checkpoints::remove(int id) { checkpoint_streamer.item_delete(id); on_update(); }
/** * @brief Calls the on_update() method of a Lua menu. * @param menu_ref A reference to the menu object. */ void LuaContext::menu_on_update(int menu_ref) { push_ref(l, menu_ref); on_update(); lua_pop(l, 1); }
void ScriptComponent::update() { on_update(); }
/** * OnUpdateDevice * callback handler to receive device updates from InsteonDevice objects. * updates are then routed to out owner, autohub. * @param json */ void InsteonNetwork::onUpdateDevice(Json::Value json) { if (on_update) io_service_.post([ = ]{on_update(json);}); }