コード例 #1
0
ファイル: Renderer.cpp プロジェクト: Ralph-sa/libbehavior
bool Renderer::Render()
{
	const GameObjectList* backgrounds = ws->getBackgroundObjects();
	const GameObjectList* objects = ws->getAllGameObjects();
	gc->clear();

	ConstGameObjectIter itr;
	for (itr = backgrounds->begin(); itr!=backgrounds->end();itr++)
	{
		GameObject* obj = *itr;
		CL_Sprite* sprite = obj->sprite;
		sprite->set_angle(obj->displayHeading);
		sprite->draw(*gc,obj->location.x,obj->location.y);
	}

	for (itr = objects->begin(); itr!=objects->end();itr++)
	{
		GameObject* obj = *itr;
		CL_Sprite* sprite = obj->sprite;
		sprite->set_angle(obj->displayHeading);
		sprite->draw(*gc,obj->location.x,obj->location.y);
		/*
		if (obj->usesPhysics)
			obj->collisionOutline->draw(0,0,CL_Colorf::azure,*gc);*/
			
	}
	
	return true;

}
コード例 #2
0
ファイル: Character.cpp プロジェクト: sp-alex-osou/PacMan
// verkleinertes Sprite an Ziel-Position zeichnen
void Character::drawTarget(CL_Sprite& sprite)
{
	CL_Pointf position = world->getLevel().getCoordinates(targetField);

	sprite.set_scale(0.5f, 0.5f);
	sprite.draw(world->get_gc(), position.x - sprite.get_width() / 4, position.y - sprite.get_height() / 4);
	sprite.set_scale(1.0f, 1.0f);
}
コード例 #3
0
void
TileMapPaintToolImpl::draw()
{
  TilemapLayer tilemap = TilemapLayer::current();

  if (tilemap.is_null())
    return;

  switch(mode)
  {
    case TileMapPaintToolImpl::SELECTING:
      if (CL_Keyboard::get_keycode(CL_KEY_LSHIFT))
        selection.draw(CL_Color(255,  128, 128, 100));
      else 
        selection.draw();
      break;
      
    default:
      int tile_size = tilemap.get_tileset().get_tile_size();

      // Draw the brush:
      for(int y = 0; y < brush.get_height(); ++y)
        for(int x = 0; x < brush.get_width(); ++x)
        {
          Tile* tile = tilemap.get_tileset().create(brush.at(x, y));
                
          if (tile)
          {
            CL_Sprite sprite = tile->get_sprite();
            sprite.set_alpha(0.5f);
            sprite.draw((current_tile.x + x) * tile_size, 
                        (current_tile.y + y) * tile_size);

            CL_Display::fill_rect(CL_Rect(CL_Point((current_tile.x + x) * tile_size, 
                                                   (current_tile.y + y) * tile_size),
                                          CL_Size(tile_size, tile_size)),
                                  CL_Color(255, 255, 255, 100));
          }
          else if (brush.is_opaque())
          {
            CL_Display::fill_rect(CL_Rect(CL_Point((current_tile.x + x) * tile_size, 
                                                   (current_tile.y + y) * tile_size),
                                          CL_Size(tile_size, tile_size)),
                                  CL_Color(255, 255, 255, 100));
          }
          else
          {
            CL_Display::fill_rect(CL_Rect(CL_Point((current_tile.x + x) * tile_size, 
                                                   (current_tile.y + y) * tile_size),
                                          CL_Size(tile_size, tile_size)),
                                  CL_Color(255, 255, 255, 50));
          }
        }
      break;
  }
}
コード例 #4
0
ファイル: test_cl09.cpp プロジェクト: PaulFSherwood/cplusplus
void App::draw_equal_tex_equal_sprites(CL_GraphicContext &gc, int sprite_count, float time_elapsed)
{
	int count = 0;
	for(int x=0; x<100; ++x)
	{
		for(int y=0; y<100; ++y)
		{
			explosion1.draw(gc, x * 10.0f, y * 10.0f);
			explosion1.update(time_elapsed);

			count++;
			if(count == sprite_count)
				return;
		}
	}
}
コード例 #5
0
ファイル: icon.cpp プロジェクト: Flexlay/flexlay
void
IconImpl::draw()
{
  CL_Display::push_translate(parent->get_screen_x(), parent->get_screen_y());
  CL_Rect rect(CL_Point(0, 0), CL_Size(parent->get_width()-4, parent->get_height()-4));

  sprite.set_alignment(origin_center);

  if (is_enabled)
  {
    if (is_down)
    {
      Box::draw_button_down(rect);
    }
    else
    {
      if (parent->has_mouse_over())
      {
        if (down)
          Box::draw_button_down(rect);
        else
          Box::draw_button_up(rect);
      }
      else
        Box::draw_button_neutral(rect);
    }
    sprite.set_alpha(1.0f);
  }
  else
  {
    Box::draw_button_neutral(rect);
    sprite.set_alpha(0.3f);
  }
  sprite.draw((rect.get_width()+1)/2, (rect.get_height()+1)/2);
  CL_Display::pop_modelview();
}
コード例 #6
0
void CL_ListViewIcon::draw(CL_GraphicContext &gc, const CL_Rect &rect, CL_ListViewDisplayMode mode, const CL_Colorf &color)
{
	CL_Sprite sp = get_sprite(mode);
	if (!sp.is_null())
	{
		float scale = 1.0;

		sp.set_color(color);
		//		if (mode == listview_mode_thumbnails && sp.get_frame_size(0) != rect.get_size())
		if (impl->scalable && (sp.get_frame_size(0) != rect.get_size()))
		{
			// Scale to max vertically or horizontally.
			float sx, sy;
			sx = rect.get_width()/float(sp.get_width());
			sy = rect.get_height()/(float)sp.get_height();
			if (sx <= 0 || sy <= 0)
			{
				return;
			}
			scale = cl_min(sx, sy);
			sp.set_scale(scale,scale);
		}

		CL_Rect R = rect;
		CL_Point offset = get_offset(mode);

		R.translate(offset);

		if (!impl->scalable && offset == CL_Point(0,0))
		{
			// center in cell rect.
			int center_offset_x = int((float)rect.get_center().x - (float)rect.left - scale*(float)sp.get_width()/2.0); 
			int center_offset_y = int((float)rect.get_center().y - (float)rect.top - scale*(float)sp.get_height()/2.0); 
			R.left += center_offset_x;
			R.top += center_offset_y;
		}

		if (!impl->scalable)
			sp.draw(gc, (float)R.left, (float)R.top);
		else
			sp.draw(gc, R);

		return;
	}

	CL_PixelBuffer pb = get_pixel_buffer(mode);
	if (!pb.is_null())
	{
		float scale = 1.0;
		float center_offset_x = 0, center_offset_y = 0;

//		if (mode == listview_mode_thumbnails && pb.get_size() != rect.get_size())
		if (impl->scalable && (pb.get_size() != rect.get_size()))
		{
			float sx = 1.0, sy = 1.0;

			// Scale to max vertically or horizontally.
			sx = rect.get_width()/float(pb.get_width());
			sy = rect.get_height()/(float)pb.get_height();
			if (sx <= 0 || sy <= 0)
			{
				return;
			}

			scale = cl_min(sx, sy);

			// center in the rect.
			center_offset_x = (float)rect.get_center().x - (float)rect.left - scale*(float)pb.get_width()/2.0f; 
			center_offset_y = (float)rect.get_center().y - (float)rect.top - scale*(float)pb.get_height()/2.0f; 
		}

		CL_Point offset = get_offset(mode);

		gc.draw_pixels(rect.left + center_offset_x + offset.x, rect.top + center_offset_y + offset.y, scale, scale, pb, pb.get_size(), color);
	}
}
コード例 #7
0
 void draw(CL_GraphicContext* gc) {
   sprite.draw(static_cast<int>(pos.x), static_cast<int>(pos.y), gc);
 }
コード例 #8
0
ファイル: Character.cpp プロジェクト: sp-alex-osou/PacMan
// Sprite an aktueller Position zeichnen
void Character::drawSprite(CL_Sprite& sprite)
{
	sprite.draw(world->get_gc(), position.x - sprite.get_width() / 2, position.y - sprite.get_height() / 2);
}
コード例 #9
0
void
ObjMapSpriteObjectImpl::draw(CL_GraphicContext* gc)
{
  sprite.draw(pos.x, pos.y, gc);
}