summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichal <michrydz@wp.pl>2022-04-24 19:26:25 +0200
committerMichal <michrydz@wp.pl>2022-04-24 19:26:25 +0200
commit4c3eca4427841730501b24b25cc4ff2a36f9f070 (patch)
tree1362df9458ffb966e21a2e1d701924ddc5a20e2b
parent6f6b09dcf2c5306471c3febfa658bbd984664884 (diff)
downloadbullethell2022-spiralbullet.zip
bullethell2022-spiralbullet.tar.gz
bullethell2022-spiralbullet.tar.bz2
Fix spiral movementspiralbullet
-rw-r--r--Spiral.cpp5
-rw-r--r--SpiralGenerator.cpp16
-rw-r--r--SpiralGenerator.h1
3 files changed, 11 insertions, 11 deletions
diff --git a/Spiral.cpp b/Spiral.cpp
index 636a6b2..cfa02c6 100644
--- a/Spiral.cpp
+++ b/Spiral.cpp
@@ -28,10 +28,11 @@ SpiralSystem::update(const float dt)
bullet.angle -= 2.0;
bullet.redirect *= bullet.redirect_decrease;
}
- float velovity_x = std::cos(angle * M_PI);
- float velovity_y = std::sin(angle * M_PI);
+ float velocity_x = bullet.velocity * std::cos(bullet.angle * M_PI);
+ float velocity_y = bullet.velocity * std::sin(bullet.angle * M_PI);
bullet.position.x += velocity_x * dt;
bullet.position.y += velocity_y * dt;
+ //bullet.position.x += 5*dt;
const bool y_exceeded = bullet.position.y < min_height || bullet.position.y > max_height;
const bool x_exceeded = bullet.position.x < min_width || bullet.position.x > max_width;
if (y_exceeded || x_exceeded)
diff --git a/SpiralGenerator.cpp b/SpiralGenerator.cpp
index ea3268f..5c39dfb 100644
--- a/SpiralGenerator.cpp
+++ b/SpiralGenerator.cpp
@@ -13,14 +13,12 @@ SpiralGenerator::SpiralGenerator(std::shared_ptr<Vector2> position, SpiralBullet
m_position {position},
m_bullets {bullets},
m_delay {0},
- m_interval {0.08f},
- m_cone {0.4f},
+ m_interval {0.80f},
m_angle {1.0f},
- m_redirect {0.1f},
- float timer {0f},
- float redirect_time {1f},
- float redirect_decrease {0.2f},
- m_direction {-1.f},
+ m_redirect {0.125f},
+ m_timer {0.0f},
+ m_redirect_time {0.05f},
+ m_redirect_decrease {0.99f},
m_speed {80},
m_shift {10},
m_segments {1},
@@ -43,8 +41,8 @@ SpiralGenerator::update(const float dt)
bullet.color = m_color;
bullet.radius = 3;
bullet.velocity = m_speed;
- bullet.position.x = m_position->x + cos * m_shift;
- bullet.position.y = m_position->y + sin * m_shift;
+ bullet.position.x = m_position->x;
+ bullet.position.y = m_position->y;
bullet.angle = m_angle;
bullet.redirect = m_redirect;
bullet.timer = m_timer;
diff --git a/SpiralGenerator.h b/SpiralGenerator.h
index 25fe9ba..0dda951 100644
--- a/SpiralGenerator.h
+++ b/SpiralGenerator.h
@@ -26,5 +26,6 @@ private:
float m_redirect_time;
float m_redirect_decrease;
int m_segments;
+ float m_shift;
Color m_color;
};