void animation_test_deff (void) { U8 n; animation_begin (AN_MONO+AN_CLEAN); animation_set_speed (TIME_66MS); animation_add_static (animation_test1); animation_add_static (animation_test2); animation_add_static (animation_test3); for (n=0; n < 100; n++) animation_step (); animation_end (); deff_exit (); }
// worker functions void Bullet::geometry_init() { float ratio = float(this->image.rect().width()) / float(this->image.rect().height());//need to make sure that our randomly generated image size does not distort the image // generate the random height int _height = utilities::random_integer(this->game_state->get_height() * min_height, this->game_state->get_height() * max_height), _width = _height / ratio;//create a new width based on the ratio of the image // set the image to the proper geometry this->image = this->image.scaled(_height, _width);//scale the image with the above calculated coordinates -- should still be in scale this->rect = this->image.rect(); // connec the animation group connect(this->animation_group, SIGNAL(finished()), this, SLOT(animation_end())); }
/** * Updates animations * * Used to draw animations. This component determines which stage the animation * is at and updates the render player component accordingly so no special system * is needed for animations vs. static images. * * The animation can also be triggered at a random time, and can also trigger a sound effect. * * @param world Pointer to the world structure (contains "world" info, entities / components) * * @designer Jordan Marling * @designer Mat Siwoski * @designer Robin Hsieh * * @author Jordan Marling * @author Mat Siwoski * @author Robin Hsieh */ void animation_system(World *world) { unsigned int entity; AnimationComponent *animationComponent; RenderPlayerComponent *renderPlayer; Animation *animation; for(entity = 0; entity < MAX_ENTITIES; entity++){ if (IN_THIS_COMPONENT(world->mask[entity], SYSTEM_MASK)){ animationComponent = &(world->animation[entity]); renderPlayer = &(world->renderPlayer[entity]); if (animationComponent->current_animation > -1) { animation = &(animationComponent->animations[animationComponent->current_animation]); if (SDL_GetTicks() - animation->ms_last > animation->ms_to_skip) { animation->ms_last = SDL_GetTicks(); animation->index++; if (animation->index >= animation->surface_count) { animation->index = 1; if (animation->loop == -1) { animationComponent->current_animation = -1; renderPlayer->playerSurface = animation->surfaces[0]; //stop_effect(animation->sound_effect); animation_end(world, entity); continue; } } if (animation->index >= animation->surface_count) { animation->index = animation->surface_count - 1; } renderPlayer->playerSurface = animation->surfaces[animation->index]; } } else { //check if random trigger has triggered if (animationComponent->rand_animation < 0) { continue; } if (SDL_GetTicks() > animationComponent->next_random_occurance) { animationComponent->current_animation = animationComponent->rand_animation; animationComponent->last_random_occurance = SDL_GetTicks(); animationComponent->next_random_occurance = (rand() % (animationComponent->rand_occurance_max - animationComponent->rand_occurance_min)) + animationComponent->rand_occurance_min + SDL_GetTicks(); if (animationComponent->animations[animationComponent->rand_animation].sound_effect != MAX_EFFECTS && animationComponent->animations[animationComponent->rand_animation].sound_enabled == true) { play_effect(animationComponent->animations[animationComponent->rand_animation].sound_effect); } } } } } }