From 43394c8a8908442982e3a7e25975c31b3c952923 Mon Sep 17 00:00:00 2001 From: Nikolas Date: Sun, 27 Oct 2024 12:52:55 +0200 Subject: root --- src/kamikaze.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/kamikaze.cpp (limited to 'src/kamikaze.cpp') diff --git a/src/kamikaze.cpp b/src/kamikaze.cpp new file mode 100644 index 0000000..ea07baf --- /dev/null +++ b/src/kamikaze.cpp @@ -0,0 +1,47 @@ +#include "kamikaze.h" +#include "config.h" +#include "graphics.h" +#include +#include +using namespace std; + +Kamikaze::Kamikaze(float pos_x, float pos_y, float size_x, float size_y, float orientation, string texture, float speed) : MovingGameObject(pos_x, pos_y, size_x, size_y, orientation, texture, speed){ + srand((unsigned int)time(NULL)); +} + +Kamikaze::~Kamikaze(){ + +} + +void Kamikaze::update(){ + + MovingGameObject::update(); + + + float pos_x = this -> getPosX(); + float speed = this -> getSpeed(); + + pos_x += speed * graphics::getDeltaTime(); + this -> setPosX(pos_x); + +} + +void Kamikaze::draw(){ + + MovingGameObject::draw(); + + float pos_y = this -> getPosY(); + float pos_x = this -> getPosX(); + float orientation = this -> getOrientation(); + + graphics::Brush br; + br.outline_opacity = 0.0f; + int exhaust_number = (int)(graphics::getGlobalTime()/100) % 4 + 1; + br.texture = string(ASSET_PATH) + this -> getTexture() +"_exhaust" + to_string(exhaust_number) + ".png"; + + graphics::setOrientation(orientation); + if (orientation > 0 ) graphics::drawRect(pos_x-45, pos_y+1, 35, 35, br); + else graphics::drawRect(pos_x+45, pos_y+1, 35, 35, br); + graphics::resetPose(); + +} \ No newline at end of file -- cgit v1.2.3