void handle_init(AppContextRef ctx) {
	Layer *rootLayer;
	int i;

	window_init(&window, "Squared");
	window_stack_push(&window, true /* Animated */);
	window_set_background_color(&window, GColorBlack);

	rootLayer = window_get_root_layer(&window);

	for (i=0; i<NUMSLOTS; i++) {
		initSlot(i, rootLayer);
	}

	animImpl.setup = NULL;
	animImpl.update = animateDigits;
	animImpl.teardown = NULL;

	animation_init(&anim);
	animation_set_delay(&anim, 0);
	animation_set_duration(&anim, DIGIT_CHANGE_ANIM_DURATION);
	animation_set_implementation(&anim, &animImpl);

	app_timer_send_event(ctx, STARTDELAY /* milliseconds */, 0);
}
예제 #2
0
/* -------------------------------------------------------------------------- */
static void loop(void)
{
  static u8 new_face;
  static u8 old_face;
  struct animation *a;


  new_face = position();	//Abfage aktueller Lage

  if (old_face != new_face) {
    display_clear();
    animation_clear();//Reset of LED's
    switch (new_face) {//Select actuell Arrow-animation.
    case FACE_A: a = animations_a; break;
    case FACE_B: a = animations_b; break;
    case FACE_C: a = animations_c; break;
    case FACE_D: a = animations_d; break;
    case FACE_E: a = animations_e; break;
    case FACE_F: a = animations_f; break;
    default:break; // a = NULL; /* SHOULD NOT BE REACHED */
    }
    animation_init(a);//Einlesen der Animation
  }
  old_face = new_face; //Backup-Aktuelle Lage
  animation_step();
  _delay_ms(100);			//delay
}
예제 #3
0
파일: main.c 프로젝트: alukichev/bannerd
static int init(int argc, char **argv, struct animation *banner)
{
	int i;
	struct string_list *filenames = NULL, *filenames_tail = NULL;
	int filenames_count = 0;

	init_log();

	i = get_options(argc, argv);
	if (i < 0)
		return usage(argv[0], NULL);

	for ( ; i < argc; ++i) {
		if (banner->interval == (unsigned int)-1)
			if (!parse_interval(argv[i], &banner->interval))
				continue;

		filenames_tail = string_list_add(&filenames, filenames_tail,
				argv[i]);
		if (!filenames_tail)
			return 1;
		else
			filenames_count++;
	}

	if (!filenames_count)
		return usage(argv[0], "No filenames specified");

	if (fb_init(&_Fb))
		return 1;
	if (init_proper_exit())
		return 1;
	if (animation_init(filenames, filenames_count, &_Fb, banner))
		return 1;
	string_list_destroy(filenames);

	if (banner->frame_count == 1 && RunCount == 1)
		banner->interval = 0; /* Single frame, exit after showing it */
	else if (banner->interval == (unsigned int)-1)
		banner->interval = 1000 / 24; /* 24fps */

	if (!Interactive && daemonify())
		ERR_RET(1, "could not create a daemon");

	return 0;
}
예제 #4
0
파일: item.c 프로젝트: odrevet/GE
interro_block* interro_block_new(item_type type, int number)
{
  interro_block* p_ib = malloc(sizeof(interro_block));
  p_ib->item = type;
  p_ib->number = number;
  p_ib->p_sprite = malloc(sizeof(anim_sprite));
  p_ib->p_sprite->p_image = gfx_item;
  anim_sprite_init(p_ib->p_sprite, 80, TILE_HEIGHT * 9 + 8, 3, 1, 0, 0, 1);

  p_ib->p_sprite->v_anim = malloc(p_ib->p_sprite->animation_nb * sizeof(animation));
  animation_init(p_ib->p_sprite->v_anim+0, 1, 3, 20, 0);
  p_ib->p_sprite->v_anim[0].v_frame = malloc( p_ib->p_sprite->v_anim[0].frame_nb * sizeof(SDL_Rect));
  p_ib->p_sprite->v_anim[0].v_frame[0] = set_rect(0, 0, 16, 16);
  p_ib->p_sprite->v_anim[0].v_frame[1] = set_rect(16, 0, 16, 16);
  p_ib->p_sprite->v_anim[0].v_frame[2] = set_rect(32, 0, 16, 16);

  return p_ib;
}
예제 #5
0
void personagem_init(personagem * p){
    p->x = 120-8;
    p->y = 60;

    ALLEGRO_BITMAP *sprite = al_load_bitmap("Imagens/zelda.png");

    animation_init(&p->parada_b, sprite, 0, 0, 24, 32, 1, 0);
    animation_init(&p->parada_e, sprite, 0, 32, 24, 32, 1, 0);
    animation_init(&p->parada_c, sprite, 0, 64, 24, 32, 1, 0);
    animation_init(&p->parada_d, sprite, 0, 96, 24, 32, 1, 0);

    animation_init(&p->anda_b, sprite, 24, 0, 24, 32, 4, 0.2f);
    animation_init(&p->anda_e, sprite, 24, 32, 24, 32, 4, 0.2f);
    animation_init(&p->anda_c, sprite, 24, 64, 24, 32, 4, 0.2f);
    animation_init(&p->anda_d, sprite, 24, 96, 24, 32, 4, 0.2f);

    p->animacao_atual = &p->parada_b;
    p->direcao = 'b';

    flecha_init_morta(&p->f);
    p->som_flecha = al_load_sample("Som/LTTP_Arrow_Shoot.wav");
}
예제 #6
0
파일: sprites.c 프로젝트: asqz/runner
int sprite_anim_setup(sprite_anim_t* anim, const struct sprites_t* sprites, const struct atlases_t* atlases, const char* name)
{
   anim->atlases = atlases;
   anim->sprite = sprites_get_sprite(sprites, name);

   if (anim->sprite != NULL)
   {
      animation_init(&anim->anim, &anim->sprite->animation);
      uint32_t image_index = animation_get_value(&anim->anim, TRACK_SPRITE_IMAGE)->uint32;
      anim->image = atlases_get_image(anim->atlases, anim->sprite->sprite_names[image_index].name);
   }
   else
   {
      anim->anim.data = NULL;
      anim->image = atlases_get_image(anim->atlases, name);
   }

   if (anim->image == NULL)
   {
      return -1;
   }

   return 0;
}
예제 #7
0
파일: main.c 프로젝트: odrevet/GE
int main(int argc, char** argv){
  SDL_Surface *screen=NULL;
  srand(time(NULL));

  sdl_init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);

  SDL_EnableKeyRepeat(200, 200);

  SDL_WM_SetCaption("Game Engine demo", NULL);

  atexit(SDL_Quit);
  SDL_ShowCursor(SDL_DISABLE);

  dstrect = set_rect(0,0,WINDOW_HEIGHT,WINDOW_WIDTH);
  srcrect = set_rect(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH);
  
  // create a new window
  int flags = SDL_HWSURFACE;
  screen = sdl_set_video(WINDOW_WIDTH, WINDOW_HEIGHT, 16, flags);
  backbuffer = SDL_DisplayFormat(screen);

  //create a new game
  game o_game;

  //create sprites
  int i;
  for(i=0;i<SPRITE_NUMBER;i++){    
    anim_sprite* p_sprite = malloc(sizeof(anim_sprite));
    p_sprite->p_image = image_load("./res/coin.png");
    image_set_transp_color(p_sprite->p_image, 0xFF, 0x00, 0xFF);

    //init sprite animation
    anim_sprite_init(p_sprite, 80, 16, 3, 1, 0, 0, 1);
    p_sprite->v_anim = malloc(p_sprite->animation_nb * sizeof(animation));
    animation_init(p_sprite->v_anim+0, 1, 3, 25, 0);   //one animation of three frames

    p_sprite->v_anim[0].v_frame = malloc(p_sprite->v_anim[0].frame_nb * sizeof(SDL_Rect));
    p_sprite->v_anim[0].v_frame[0] = set_rect(0, 0, 5, 8);
    p_sprite->v_anim[0].v_frame[1] = set_rect(5, 0, 5, 8);
    p_sprite->v_anim[0].v_frame[2] = set_rect(10, 0, 5, 8);

    //init sprite position and velocity
    int x = rand() % WINDOW_WIDTH;
    int y = rand() % WINDOW_HEIGHT;
    int vel_x = rand() % 2;
    int vel_y = rand() % 2;
    p_sprite->x = x;
    p_sprite->y = y;
    p_sprite->vel_x = vel_x;
    p_sprite->vel_y = vel_y;   

    
    o_game.p_sprite[i] = p_sprite;
  }
  
  //game stats
  game_status ret_code = IN_GAME;
  while(ret_code != QUIT){
    switch(ret_code){
    case IN_GAME:
      ret_code = state_in_game(screen, &o_game);
      break;
    default:
      break;
    }
  }

  SDL_Quit();
  return EXIT_SUCCESS;
}
예제 #8
0
void alien_list_init() {
	direction = 1;

	if ((invaders = (alien_list*) malloc(sizeof(alien_list))) == NULL)
		return;

	invaders->head = NULL;
	invaders->last = NULL;
	invaders->movement_frequency = INITIAL_MOV_FREQ;

	ufo = NULL;

	unsigned char row_pos;
	unsigned char line = 0;
	unsigned char counter;
	int x = INITIAL_X_POS;
	int y = INITIAL_Y_POS;
	enum alien_type type;

	for (counter = 0; counter < ALIENS_PER_ROW * ALIEN_ROWS; counter++) {

		if (counter % ALIENS_PER_ROW == 0) {
			y += ALIEN_HEIGHT + ALIEN_SPACEMENT;
			x = INITIAL_X_POS;
			line++;
		}
		else
			x += ALIEN_WIDTH + ALIEN_SPACEMENT;

		switch(line){
		case 1:
			type = SMALL;
			break;
		case 2: case 3:
			type = MEDIUM;
			break;
		case 4:	case 5:
			type = LARGE;
			break;
		}
		alien_add((alien_init(x, y, type)));
	}

	search_new_extreme(1);
	search_new_extreme(2);

	//initialize small aliens animation
	invaders->small_alien = animation_init();
	animation_add_by_filename(invaders->small_alien, "small_invader1.bmp");
	animation_add_by_filename(invaders->small_alien, "small_invader2.bmp");

	//initialize medium aliens animation
	invaders->medium_alien = animation_init();
	animation_add_by_filename(invaders->medium_alien, "medium_invader1.bmp");
	animation_add_by_filename(invaders->medium_alien, "medium_invader2.bmp");

	//initialize large aliens animation
	invaders->large_alien = animation_init();
	animation_add_by_filename(invaders->large_alien, "large_invader1.bmp");
	animation_add_by_filename(invaders->large_alien, "large_invader2.bmp");

	//initialize ufo image
	ufo_img = bitmap_load("ufo.bmp");

	invaders->destroy = animation_init();
	animation_add_by_filename(invaders->destroy, "explosion.bmp");
}
예제 #9
0
파일: skios.c 프로젝트: ryonagana/skios2
int game_loop(){


    unsigned redraw = 0;

    game_rect t;
    rect_Zero(&t);
    sprite_sheet = gamespr_create("ski1.bmp");

    animation_init();
    init_player();
    start_new_game(0);


    while(!mainloop){

        ALLEGRO_EVENT e;
        ALLEGRO_TIMEOUT timeout;
        int i;

        al_init_timeout(&timeout, 0.06);

        bool  late = al_wait_for_event_until(g_queue, &e, &timeout);





        if(late){
            switch(e.type){
                case ALLEGRO_EVENT_DISPLAY_CLOSE:
                    mainloop = 1;
                    break;

                 case ALLEGRO_EVENT_KEY_UP:
                        player_poll_kbd_up(&e);
                 break;

                 case ALLEGRO_EVENT_KEY_DOWN:
                        player_poll_kbd_dn(&e);
                 break;

                case ALLEGRO_EVENT_TIMER:

                /* main clock updates 1/60ms (60FPS LOCK) */
                    if(e.timer.source == g_timer){
                        particle_list = particles_clean(particle_list, 0);
                        particles_update(particle_list);
                        player_update_screen();
                        player_update(&ski_player, &playfield);



                        for(i = 1; i < MAX_SPRITES; i++){
                           update_enemy(i);
                        }

                        update_enemy_behavior(gobj_list, &playfield);

                        redraw =  1;
                    }

                     /* update for the chronomenter run every 100ms only) */
                    if( e.timer.source == timer_chrono){
                        HUD_UpdateChrono();
                        DMSG("%d", al_get_timer_count(timer_chrono));




                    }

                    break;
            }


            if( redraw == 1 && al_event_queue_is_empty(g_queue)){
                    redraw = 0;
                    al_clear_to_color(WHITE_COLOR);


                    particles_draw(NULL, particle_list);
                    player_draw(ski_player.object->position.x, ski_player.object->position.y );

                    for(i = 1; i < MAX_OBJECTS; i++){
                         int enemy_type = gobj_list[i].type;
                         draw_enemy(enemy_type, i, 0,0, gobj_list[i].position.x, gobj_list[i].position.y, 32,32);

                    }

                    HUD_create_stats_box();
                    al_flip_display();
            }
        }

    }

    HUD_destroy();
    unload_spritesheets();
    window_deinit();
    particle_list = particles_clean(particle_list, PARTICLES_ALL_CLEAN);
    return EXIT_SUCCESS;
}