Esempio n. 1
0
static int
update_unit_approx (int in, unsigned mult)
{
    if (in / mult > 0)
	return 0;
    else
	return update_unit (in, mult);
}
Esempio n. 2
0
static void update_time(struct tm *tick_time, TimeUnits units_changed) {
  if (units_changed >= HOUR_UNIT) {
    if (clock_is_24h_style() == true) {
      update_unit(s_hour_layer, s_hour_bar_layer, tick_time, s_hour_buffer, "%H");
    } else {
      update_unit(s_hour_layer, s_hour_bar_layer, tick_time, s_hour_buffer, "%I");
    }
    s_hour_value = tick_time->tm_hour;
  }
  
  if (units_changed >= MINUTE_UNIT) {
    s_minute_value = tick_time->tm_min;
    update_unit(s_minute_layer, s_minute_bar_layer, tick_time, s_minute_buffer, "%M");
  }
  
  if (units_changed >= SECOND_UNIT) {
    s_second_value = tick_time->tm_sec;
    update_unit(s_second_layer, s_minute_bar_layer, tick_time, s_second_buffer, "%S");
  }
}
Esempio n. 3
0
void game_update(camera *camera, PLAYERS *players) {
  if(paused) {
    paused_state.update(camera, players);
    return;
  }

  for(int i = 0; i < players->num; i++) {
    player *player = players->players[i];
    for(int j = 0; j < player->num_divisions; j++) {
      division *div = player->divisions[j];
      for(int k = 0; k < div->size; k++) {
        update_unit(div->units[k], camera, players);
      }
    }
  }
}
Esempio n. 4
0
MapHud::MapHud(int x, int y, float width, float height, Game * game, Layer * layer): HudItem(x,y,CCSprite::create(),HudItem::mapButtonType,game,layer) {
	int width_map = getGame()->get_display_layer()->get_map_width();
	int height_map = getGame()->get_display_layer()->get_map_height();
	int bytes = width_map * height_map * 4;
	void* textureData = malloc(bytes);
	memset(textureData, INT32_MAX, bytes);

	_texture = new CCTexture2DMutable();
	_texture->initWithData(textureData, kCCTexture2DPixelFormat_RGBA8888, width_map, height_map, CCSize(width_map,height_map));

	std::string id;
	for(x=0;x<width_map;x++) {
		for(y=0;y<height_map;y++) {
			_texture->setPixelAt(CCPointMake(x,height_map-y-1),ccc4(0,0,0,255));
		}
	}
	_texture->apply();
	_texture->setAliasTexParameters();
	getSprite()->initWithTexture(_texture);
	_texture->autorelease();

	float scale = fminf( width/getSprite()->getTextureRect().size.width,height/getSprite()->getTextureRect().size.height )*1.1;
	getSprite()->setScale(scale);

	textureData = malloc(bytes);
	memset(textureData, INT32_MAX, bytes);
	_texture_screen_edge = new CCTexture2DMutable();
	_texture_screen_edge->initWithData(textureData, kCCTexture2DPixelFormat_RGBA8888, width_map, height_map, CCSize(width_map,height_map));

	for(x=0;x<width_map;x++) {
		for(y=0;y<height_map;y++) {
			_texture_screen_edge->setPixelAt(CCPointMake(x,height_map-y-1),ccc4(0,0,0,0));
		}
	}
	_texture_screen_edge->apply();
	_texture_screen_edge->setAliasTexParameters();
	_sprite_screen_edge = CCSprite::createWithTexture(_texture_screen_edge);
	getSprite()->addChild(_sprite_screen_edge);
	_sprite_screen_edge->setPositionX(getSprite()->getTextureRect().size.width/2.0);
	_sprite_screen_edge->setPositionY(getSprite()->getTextureRect().size.height/2.0);
	_texture_screen_edge->autorelease();

	update_screen_edge();

	textureData = malloc(bytes);
	memset(textureData, INT32_MAX, bytes);
	_texture_unit = new CCTexture2DMutable();
	_texture_unit->initWithData(textureData, kCCTexture2DPixelFormat_RGBA8888, width_map, height_map, CCSize(width_map,height_map));

	for(x=0;x<width_map;x++) {
		for(y=0;y<height_map;y++) {
			_texture_unit->setPixelAt(CCPointMake(x,height_map-y-1),ccc4(0,0,0,0));
		}
	}
	_texture_unit->apply();
	_texture_unit->setAliasTexParameters();
	_sprite_unit = CCSprite::createWithTexture(_texture_unit);
	getSprite()->addChild(_sprite_unit);
	_sprite_unit->setPositionX(getSprite()->getTextureRect().size.width/2.0);
	_sprite_unit->setPositionY(getSprite()->getTextureRect().size.height/2.0);
	_texture_unit->autorelease();

	update_unit();
}
Esempio n. 5
0
void MapHud::on_moveable_change_map_tile(int x, int y, Moveable * moveable) {
	update_unit();
}
Esempio n. 6
0
void MapHud::on_unit_destroyed(Unit * unit) {
	update_unit();
}