void drawSprite(Sprite &spr, RenderTarget &target) { RectangleShape shape; Texture &sftexture = const_cast<Texture&>(*spr.getTexture()); FloatRect r = spr.getLocalBounds(); shape.setSize(Vector2f(r.width, r.height)); shape.setOrigin(spr.getOrigin()); shape.setRotation(spr.getRotation()); shape.setPosition(spr.getPosition()); shape.setScale(spr.getScale()); shape.setTexture(spr.getTexture()); shape.setFillColor(spr.getColor()); sftexture.setRepeated(false); target.draw(shape); sftexture.setRepeated(true); }
void update(float time, int number_block) { if (step == MOVE_DOWN) step_one(rectangle, time, pos.y, step); else if (step == MOVE_RIGHT_AND_UP) step_two(rectangle, time, pos.x, pos.y, step, number_block, rotation); else if (step == MOVE_RIGHT_AND_TURN) step_three(rectangle, time, number_block, pos.x, pos.y, step); else if (step == MOVE_DOWN_AND_CHANGE_SCALE) step_four(rectangle, time, number_block, pos.x, pos.y, step, size_y); else if (step == MOVE_LEFT) step_five(rectangle, time, number_block, pos.x, pos.y, step, size_y); rectangle.setScale(size_x, size_y); rectangle.setRotation(rotation); rectangle.setPosition(pos.x, pos.y); };
// draws health bars, buff icons, main background void drawGameWindow(RenderWindow& window, Player& human, Player& computer) { Sprite background; background.setTexture(backgroundTexture); window.draw(background); RectangleShape humanHealth; // used to cover up buffs RectangleShape computerHealth; // that aren't in effect RectangleShape humanResources; RectangleShape computerResources; RectangleShape iconCovers[8]; for (int i = 0; i < 8; i++) { iconCovers[i].setFillColor(Color(0, 0, 0, 191)); iconCovers[i].setSize(Vector2f(91, 27)); } iconCovers[0].setPosition(Vector2f(3, 328)); iconCovers[1].setPosition(Vector2f(3, 372)); iconCovers[2].setPosition(Vector2f(3, 416)); iconCovers[3].setPosition(Vector2f(3, 460)); iconCovers[4].setPosition(Vector2f(705, 328)); iconCovers[5].setPosition(Vector2f(705, 372)); iconCovers[6].setPosition(Vector2f(705, 416)); iconCovers[7].setPosition(Vector2f(705, 460)); humanHealth.setSize(Vector2f(386, 45)); humanHealth.setPosition(Vector2f(13, 13)); humanHealth.setFillColor(Color::Black); humanHealth.setScale(Vector2f(1 - float(human.currentHealth) / human.totalHealth, 1)); computerHealth.setOrigin(Vector2f(386, 0)); computerHealth.setSize(Vector2f(386, 45)); computerHealth.setPosition(Vector2f(787, 13)); computerHealth.setFillColor(Color::Black); computerHealth.setScale(Vector2f(1 - float(computer.currentHealth) / computer.totalHealth, 1)); humanResources.setSize(Vector2f(199, 32)); humanResources.setPosition(Vector2f(200, 86)); humanResources.setFillColor(Color::Black); humanResources.setScale(Vector2f(1 - float(human.currentResources) / human.totalResources, 1)); computerResources.setOrigin(Vector2f(199, 0)); computerResources.setSize(Vector2f(199, 32)); computerResources.setPosition(Vector2f(600, 86)); computerResources.setFillColor(Color::Black); computerResources.setScale(Vector2f(1 - float(computer.currentResources) / computer.totalResources, 1)); if (human.shield.empty()) window.draw(iconCovers[0]); if (human.stun.empty()) window.draw(iconCovers[1]); if (human.damageBuff.empty()) window.draw(iconCovers[2]); if (human.damageDebuff.empty()) window.draw(iconCovers[3]); if (computer.shield.empty()) window.draw(iconCovers[4]); if (computer.stun.empty()) window.draw(iconCovers[5]); if (computer.damageBuff.empty()) window.draw(iconCovers[6]); if (computer.damageDebuff.empty()) window.draw(iconCovers[7]); window.draw(humanResources); window.draw(computerResources); window.draw(humanHealth); window.draw(computerHealth); }