void GameModeManager::updateHerisson(float dt, float obj, float herissonSpeed) { // default herisson behavior: move to TransformationComponent* tc = TRANSFORM(herisson); float newPos = tc->position.x; if (herissonSpeed == 0) { float targetPosX = position(obj); float distance = targetPosX - tc->position.x; if (distance != 0.f) { herissonSpeed = (distance > 0) ? 1.0f : -1.0f; if (distance < 0) { newPos = glm::max(targetPosX, tc->position.x + herissonSpeed*dt); } else { newPos = glm::min(targetPosX, tc->position.x + herissonSpeed*dt); } } } else { newPos = tc->position.x + herissonSpeed * dt; } //set animation speed float newSpeed = 2.5f; if (dt != 0) newSpeed = 15*(newPos - tc->position.x)/dt; if (newSpeed < 1.4f) newSpeed = 2.5f; if (newSpeed > 4.5f) newSpeed = 4.5f; ANIMATION(herisson)->playbackSpeed = newSpeed; tc->position.x = newPos; if (herissonSpeed <= 0) { ANIMATION(herisson)->playbackSpeed = 0; } }
void GameModeManager::LoadHerissonTexture(int type) { LOGW_IF(type > 8, "type > 8"); LOGW_IF(type < 1, "type < 1"); type = (type > 8 ? 8 : (type < 1 ? 1 : type)); char tmp[32]; snprintf(tmp, 32, "herisson_%d", type); ANIMATION(herisson)->name = Murmur::RuntimeHash(tmp); }
void CustomLogic::Start() { StaticModel* model = GetNode()->GetComponent<StaticModel>(); mat = model->GetMaterial(0); mat->SetScene(GetScene()); #define ANIMATION(V) SharedPtr<ValueAnimation> V = SharedPtr<ValueAnimation>(new ValueAnimation(context_)); //SharedPtr<ValueAnimation> animSize = SharedPtr<ValueAnimation>(new ValueAnimation(context_)); ANIMATION(animSize); animSize->SetKeyFrame(0.0f, Vector3::ONE * 0.1f); animSize->SetKeyFrame(1.0f, Vector3::ONE * 2.0f); animSize->SetKeyFrame(4.0f, Vector3::ONE * 3.0f); GetNode()->SetAttributeAnimation("Scale", animSize); GetNode()->SetScene(GetScene()); ANIMATION(animClipRange); animClipRange->SetKeyFrame(0.0f, 1.0f); animClipRange->SetKeyFrame(1.0f, 1.0f); animClipRange->SetKeyFrame(4.0f, 0.8f); mat->SetShaderParameterAnimation("ClipRange", animClipRange); ANIMATION(animRange); animRange->SetKeyFrame(0.0f, Vector2(0.0f, 1.3f)); animRange->SetKeyFrame(1.0f, Vector2(0.0f, 1.3f)); animRange->SetKeyFrame(4.0f, Vector2(1.0f, 1.3f)); mat->SetShaderParameterAnimation("Range", animRange); ANIMATION(animDisplace); animDisplace->SetKeyFrame(0.0f, -1.0f); animDisplace->SetKeyFrame(4.0f, 5.0f); mat->SetShaderParameterAnimation("Displacement", animDisplace); #undef ANIMATION }
Explorer* explorer_new(IterativeMap *map, Animation *animation) { Explorer *self = EXPLORER(g_object_new(explorer_get_type(), NULL)); GtkWidget *editor, *window, *scroll; GtkRequisition win_req; self->animation = ANIMATION(g_object_ref(animation)); self->map = ITERATIVE_MAP(g_object_ref(map)); /* Create the parameter editor */ editor = parameter_editor_new(PARAMETER_HOLDER(map)); gtk_box_pack_start(GTK_BOX(glade_xml_get_widget(self->xml, "parameter_editor_box")), editor, FALSE, FALSE, 0); gtk_widget_show_all(editor); /* Create the view */ self->view = histogram_view_new(HISTOGRAM_IMAGER(map)); gtk_container_add(GTK_CONTAINER(glade_xml_get_widget(self->xml, "drawing_area_viewport")), self->view); gtk_widget_show_all(self->view); /* Set the initial render time */ on_render_time_changed(glade_xml_get_widget(self->xml, "render_time"), self); explorer_init_history(self); explorer_init_animation(self); explorer_init_tools(self); explorer_init_cluster(self); explorer_init_about(self); /* Start the iterative map rendering in the background, and get a callback every time a block * of calculations finish so we can update the GUI. */ iterative_map_start_calculation(self->map); g_signal_connect(G_OBJECT(self->map), "calculation-finished", G_CALLBACK(on_calculation_finished), self); /* Set the window's default size to include our default image size. * The cleanest way I know of to do this is to set the scrolled window's scrollbar policies * to 'never' and get the window's size requests, set them back to automatic, then set the * default size to that size request. */ window = glade_xml_get_widget(self->xml, "explorer_window"); scroll = glade_xml_get_widget(self->xml, "main_scrolledwindow"); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_NEVER); gtk_widget_size_request(window, &win_req); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_window_set_default_size(GTK_WINDOW(window), win_req.width, win_req.height); gtk_widget_show(window); return self; }
static void cell_renderer_bifurcation_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { CellRendererBifurcation *self = CELL_RENDERER_BIFURCATION(object); switch (prop_id) { case PROP_ROW_ID: self->row_id = g_value_get_ulong(value); break; case PROP_ANIMATION: if (self->animation) g_object_unref(self->animation); self->animation = ANIMATION(g_object_ref(g_value_get_object(value))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
ScreenSaver* screensaver_new(IterativeMap *map, Animation *animation) { ScreenSaver *self = SCREENSAVER(g_object_new(screensaver_get_type(), NULL)); int i; AnimationIter iter; gchar* common_parameters; self->animation = ANIMATION(g_object_ref(animation)); self->map = ITERATIVE_MAP(g_object_ref(map)); self->view = g_object_ref(histogram_view_new(HISTOGRAM_IMAGER(self->map))); /* Allocate and interpolate all frames */ self->framerate = 10; self->num_frames = animation_get_length(self->animation) * self->framerate; self->frame_renders = g_new0(IterativeMap*, self->num_frames); self->frame_parameters = g_new0(ParameterHolderPair, self->num_frames); self->current_frame = 0; common_parameters = parameter_holder_save_string(PARAMETER_HOLDER(map)); animation_iter_seek(animation, &iter, 0); for (i=0; i<self->num_frames; i++) { self->frame_renders[i] = ITERATIVE_MAP(de_jong_new()); parameter_holder_load_string(PARAMETER_HOLDER(self->frame_renders[i]), common_parameters); self->frame_parameters[i].a = PARAMETER_HOLDER(de_jong_new()); animation_iter_load(animation, &iter, self->frame_parameters[i].a); animation_iter_seek_relative(animation, &iter, 1/self->framerate); } for (i=0; i<self->num_frames-1; i++) self->frame_parameters[i].b = self->frame_parameters[i+1].a; self->frame_parameters[self->num_frames-1].b = self->frame_parameters[self->num_frames-1].a; g_free(common_parameters); self->direction = 1; screensaver_start(self); return self; }
void PlatformerSystem::DoUpdate(float) { FOR_EACH_ENTITY_COMPONENT(Platformer, entity, pltf) PhysicsComponent* pc = PHYSICS(entity); TransformationComponent* tc = TRANSFORM(entity); glm::vec2 newPosition(tc->position + glm::rotate(pltf->offset, tc->rotation)); // if going down if (pc->linearVelocity.y < 0) { TransformationComponent* tc = TRANSFORM(entity); // did we intersect a platform ? for (std::map<Entity, bool>::const_iterator it=pltf->platforms.begin(); it != pltf->platforms.end(); ++it) { if (!it->second) continue; TransformationComponent* pltfTC = TRANSFORM(it->first); if (IntersectionUtil::lineLine( pltf->previousPosition, newPosition, pltfTC->position + glm::rotate(glm::vec2(pltfTC->size.x * 0.5, pltfTC->size.y * 0.5), pltfTC->rotation), pltfTC->position + glm::rotate(glm::vec2(-pltfTC->size.x * 0.5, pltfTC->size.y * 0.5), pltfTC->rotation), 0)) { // We did intersect... pc->gravity.y = 0; pc->linearVelocity = glm::vec2(0.0f); tc->position.y = pltfTC->position.y + tc->size.y * 0.5; ANIMATION(entity)->name = HASH("jumptorunL2R", 0x9bdaadc5); if (RUNNER(entity)->speed < 0) RENDERING(entity)->flags |= RenderingFlags::MirrorHorizontal; else RENDERING(entity)->flags &= ~(RenderingFlags::MirrorHorizontal); newPosition = tc->position + glm::rotate(pltf->offset, tc->rotation); pltf->onPlatform = it->first; break; } } } else if (pc->linearVelocity.y == 0) { if (pltf->onPlatform) { if (!onPlatform(newPosition, 0.5, pltf->onPlatform)) { bool foundNew = false; for (std::map<Entity, bool>::const_iterator it=pltf->platforms.begin(); it != pltf->platforms.end(); ++it) { if (it->first == pltf->onPlatform || !it->second) continue; if (onPlatform(newPosition, 0.5, it->first)) { pltf->onPlatform = it->first; foundNew = true; } } if (!foundNew) { pltf->onPlatform = 0; pc->gravity.y= -150; LOGV(1, "No on a platform anymore"); } } else if (!pltf->platforms[pltf->onPlatform]) { pltf->onPlatform = 0; pc->gravity.y = -150; } } } else { pltf->onPlatform = 0; } pltf->previousPosition = newPosition; }
static const u8 states_a_d[] = { // 87654321 0b00000010, 0b00010111, 0b10111010, 0b11010010, 0b10010010, 0b10010000, 0b10000000, 0b00000000, 0b00001000, }; static struct animation animations_a[] = { ANIMATION(FACE_F, states_a_f, 1, 3), ANIMATION(FACE_B, states_a_b, 2, 3), ANIMATION(FACE_E, states_a_e, 3, 3), ANIMATION(FACE_D, states_a_d, 0, 3), }; /* Seite B oben ------------------------------------------------------------- */ static const u8 states_b_afe[] = { // 87654321 0b00000010, 0b00010111, 0b10111010, 0b11010010, 0b10010010, 0b10010000,