summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-18 20:38:16 +0200
committerAki <please@ignore.pl>2022-04-18 20:39:44 +0200
commitadd251b4ea37b57cf926b07e5e04d9b065f82a2c (patch)
tree9cecb47f168c985017971a3373de59b35f85db1a
parentbbec07ab3de333649d14a64fa01f7e8ad6d56c58 (diff)
downloadbullethell2022-add251b4ea37b57cf926b07e5e04d9b065f82a2c.zip
bullethell2022-add251b4ea37b57cf926b07e5e04d9b065f82a2c.tar.gz
bullethell2022-add251b4ea37b57cf926b07e5e04d9b065f82a2c.tar.bz2
Playing around with enemies, added dumb pos manipulation
-rw-r--r--Enemy.cpp10
-rw-r--r--Enemy.h1
-rw-r--r--ExampleGenerator.cpp24
-rw-r--r--Player-inl.h2
-rw-r--r--Player.cpp2
-rw-r--r--TestStage.cpp18
-rw-r--r--TestStage.h4
7 files changed, 41 insertions, 20 deletions
diff --git a/Enemy.cpp b/Enemy.cpp
index 7caea31..b8329a2 100644
--- a/Enemy.cpp
+++ b/Enemy.cpp
@@ -9,7 +9,7 @@
Enemy::Enemy(std::unique_ptr<Generator> generator) :
- m_hold {2},
+ m_hold {0},
m_position {std::make_shared<Vector2>()},
m_generator {std::move(generator)}
{
@@ -38,3 +38,11 @@ Enemy::draw()
return;
DrawCircle(m_position->x, m_position->y, 6, DARKGRAY);
}
+
+
+void
+Enemy::set_position(const float x, const float y)
+{
+ m_position->x = x;
+ m_position->y = y;
+}
diff --git a/Enemy.h b/Enemy.h
index ad0c99d..0a8c429 100644
--- a/Enemy.h
+++ b/Enemy.h
@@ -13,6 +13,7 @@ public:
explicit Enemy(std::unique_ptr<Generator> generator = {});
void update(float dt);
void draw();
+ void set_position(float x, float y);
private:
float m_hold;
std::shared_ptr<Vector2> m_position;
diff --git a/ExampleGenerator.cpp b/ExampleGenerator.cpp
index 4c86d94..76c4cb7 100644
--- a/ExampleGenerator.cpp
+++ b/ExampleGenerator.cpp
@@ -11,12 +11,12 @@
ExampleGenerator::ExampleGenerator(ConstantVelocityBullet::Vector& bullets) :
m_bullets {bullets},
m_delay {0},
- m_interval {0.04f},
- m_cone {0.3f},
+ m_interval {0.05f},
+ m_cone {0.4f},
m_angle {0.3f},
- m_speed {100},
+ m_speed {70},
m_shift {10},
- m_segments {2},
+ m_segments {3},
m_color {240, 0, 0, 255}
{
}
@@ -42,13 +42,13 @@ ExampleGenerator::update(const float dt)
bullet.position.y = pos.y + sin * m_shift;
m_bullets.push_back(std::move(bullet));
}
- m_angle += dt * 1.1f;
- if (m_angle >= 0.7f) {
- m_angle -= 0.4f;
- if (m_color.g == 0)
- m_color.g = 150;
- else
- m_color.g = 0;
- }
+ }
+ m_angle += dt * 0.5f;
+ if (m_angle >= 0.7f) {
+ m_angle -= 0.4f;
+ if (m_color.g == 0)
+ m_color.g = 120;
+ else
+ m_color.g = 0;
}
}
diff --git a/Player-inl.h b/Player-inl.h
index 10c43d1..140bfad 100644
--- a/Player-inl.h
+++ b/Player-inl.h
@@ -10,7 +10,7 @@ bool
Player::collide(const std::vector<T>& bullets) const
{
for (const auto& bullet : bullets) {
- if (CheckCollisionCircles(m_position, 9, bullet.position, bullet.radius))
+ if (CheckCollisionCircles(m_position, 4, bullet.position, bullet.radius))
return true;
}
return false;
diff --git a/Player.cpp b/Player.cpp
index 9e4be4d..490b810 100644
--- a/Player.cpp
+++ b/Player.cpp
@@ -39,7 +39,7 @@ Player::update(const float dt)
void
Player::draw()
{
- DrawCircle(m_position.x, m_position.y, 10, LIGHTGRAY);
+ DrawCircle(m_position.x, m_position.y, 4, LIGHTGRAY);
}
diff --git a/TestStage.cpp b/TestStage.cpp
index cc90f19..653d3c2 100644
--- a/TestStage.cpp
+++ b/TestStage.cpp
@@ -1,13 +1,21 @@
#include "TestStage.h"
+#include <memory>
+#include <utility>
+
#include "ExampleGenerator.h"
TestStage::TestStage() :
m_player {},
- m_const {},
- m_enemy {std::make_unique<ExampleGenerator>(m_const.m_bullets)}
+ m_const {}
{
+ m_enemies.reserve(2);
+ for (const float x : {200.f, 600.f}) {
+ Enemy enemy(std::make_unique<ExampleGenerator>(m_const.m_bullets));
+ enemy.set_position(x, 20.f);
+ m_enemies.push_back(std::move(enemy));
+ }
}
@@ -15,7 +23,8 @@ void
TestStage::update(const float dt)
{
m_player.update(dt);
- m_enemy.update(dt);
+ for (auto& enemy : m_enemies)
+ enemy.update(dt);
m_const.update(dt);
bool collided = m_player.collide(m_const.m_bullets);
(void) collided;
@@ -26,7 +35,8 @@ void
TestStage::draw()
{
m_const.draw();
- m_enemy.draw();
+ for (auto& enemy : m_enemies)
+ enemy.draw();
m_player.draw();
}
diff --git a/TestStage.h b/TestStage.h
index c5287a5..0e90ab6 100644
--- a/TestStage.h
+++ b/TestStage.h
@@ -1,5 +1,7 @@
#pragma once
+#include <vector>
+
#include "ConstantVelocity.h"
#include "Enemy.h"
#include "Player.h"
@@ -16,5 +18,5 @@ public:
private:
Player m_player;
ConstantVelocitySystem m_const;
- Enemy m_enemy;
+ std::vector<Enemy> m_enemies;
};