// 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); }
void draw (View& view) { sprite.set_alpha ((life_time/max_life_time) * .3); sprite.set_scale (0.8f + ((1 - life_time/max_life_time)) * 4.0f, 0.8f + ((1 - life_time/max_life_time)) * 4.0f); sprite.set_angle(angle); view.get_sc().color().draw(sprite, pos.x, pos.y); }
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; } }
CL_Rectf ObjMapSpriteObjectImpl::get_bound_rect() const { CL_Point align = CL_Point(0, 0); CL_Origin origin_e; sprite.get_alignment(origin_e, align.x, align.y); CL_Point origin = calc_origin(origin_e, CL_Size(sprite.get_width(), sprite.get_height())); align.x = -align.x; // FIXME: This looks a bit hacky float scale_x, scale_y; sprite.get_scale(scale_x, scale_y); if (scale_x < 0) align.x += sprite.get_width(); if (scale_y < 0) align.y += sprite.get_height(); // if (scale_x > 1.0f && scale_y > 1.0f) // return CL_Rectf(pos - origin - align, // CL_Sizef(sprite.get_width() * scale_x, sprite.get_height() * scale_y)); // else return CL_Rectf(pos - origin - align, CL_Sizef(sprite.get_width(), sprite.get_height())); }
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; } } }
CL_Sprite NetPanzerData::get_tilegroup_sprite(int index) { for(TileGroups::iterator i = tilegroups.begin(); i != tilegroups.end(); ++i) { if (index == i->start) { CL_Sprite sprite; sprite.add_frame(i->get_surface(), CL_Rect(CL_Point(0, 0), CL_Size(i->get_surface().get_width(), i->get_surface().get_height()))); return sprite; } } std::cout << "NetPanzerData: Couldn't get tilegroup_sprite for '" << index << "'" << std::endl; return CL_Sprite(); }
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; }
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(); }
CL_Sprite get_sprite() const { if (sprite) { return sprite; } else { NetPanzerTileGroup& tilegroup = NetPanzerData::instance()->find_tilegroup(id); int dist = id - tilegroup.start; CL_Rect rect(CL_Point((dist % tilegroup.width) * 32, (dist / tilegroup.width) * 32), CL_Size(32, 32)); sprite.add_frame(tilegroup.get_surface(), rect); return sprite; } }
void CL_Sprite::set_image_data(const CL_Sprite &image_source) { impl->frames = image_source.impl->frames; impl->id = image_source.get_id(); impl->play_loop = image_source.is_play_loop(); impl->play_backward = image_source.is_play_backward(); impl->play_pingpong = image_source.is_play_pingpong(); impl->base_angle = image_source.get_base_angle(); impl->show_on_finish = image_source.get_show_on_finish(); restart(); }
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); } }
void draw(CL_GraphicContext* gc) { sprite.draw(static_cast<int>(pos.x), static_cast<int>(pos.y), gc); }
// 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); }
void ObjMapSpriteObjectImpl::draw(CL_GraphicContext* gc) { sprite.draw(pos.x, pos.y, gc); }