|
@@ -48,6 +48,10 @@ static Vector2 projectilePosition;
|
|
|
static Vector2 projectileVelocity;
|
|
|
static Vector2 projectileSize{20.0f, 20.0f};
|
|
|
|
|
|
+static float lastAngle;
|
|
|
+static float angle;
|
|
|
+static float angleVelocity = 5.0f;
|
|
|
+
|
|
|
static void addForce(const Vector2& force) {
|
|
|
acceleration += force / mass;
|
|
|
}
|
|
@@ -255,26 +259,7 @@ static void applyFriction() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void Game::tick() {
|
|
|
- windowSize = Vector2(static_cast<float>(Engine::getSize().width),
|
|
|
- static_cast<float>(Engine::getSize().height));
|
|
|
- lastPosition = position;
|
|
|
- acceleration = Vector2();
|
|
|
-
|
|
|
- applyGravity();
|
|
|
- addMovement();
|
|
|
- handleJump();
|
|
|
- applyFriction();
|
|
|
- applyDrag();
|
|
|
-
|
|
|
- if(steepness != 100.0f) {
|
|
|
- if(steepness < -1.0f) {
|
|
|
- acceleration[0] += 0.1f;
|
|
|
- } else if(steepness > 1.0f) {
|
|
|
- acceleration[0] -= 0.1f;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+static void addLines() {
|
|
|
lines.clear();
|
|
|
lines.add({{0.0f, 0.0f}, windowSize * Vector2(1.0f, 0.0f)});
|
|
|
lines.add({{0.0f, 0.0f}, windowSize * Vector2(0.0f, 1.0f)});
|
|
@@ -322,6 +307,29 @@ void Game::tick() {
|
|
|
0.8f});
|
|
|
|
|
|
lines.add({{600.0f, 380.0f}, {1000.0f, 580.0f}});
|
|
|
+}
|
|
|
+
|
|
|
+void Game::tick() {
|
|
|
+ windowSize = Vector2(static_cast<float>(Engine::getSize().width),
|
|
|
+ static_cast<float>(Engine::getSize().height));
|
|
|
+ lastPosition = position;
|
|
|
+ acceleration = Vector2();
|
|
|
+
|
|
|
+ applyGravity();
|
|
|
+ addMovement();
|
|
|
+ handleJump();
|
|
|
+ applyFriction();
|
|
|
+ applyDrag();
|
|
|
+
|
|
|
+ if(steepness != 100.0f) {
|
|
|
+ if(steepness < -1.0f) {
|
|
|
+ acceleration[0] += 0.1f;
|
|
|
+ } else if(steepness > 1.0f) {
|
|
|
+ acceleration[0] -= 0.1f;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ addLines();
|
|
|
|
|
|
velocity += acceleration;
|
|
|
|
|
@@ -371,6 +379,9 @@ void Game::tick() {
|
|
|
projectileVelocity -= Vector2(0.0f, GRAVITY);
|
|
|
projectilePosition += projectileVelocity;
|
|
|
relaunchProjectile();
|
|
|
+
|
|
|
+ lastAngle = angle;
|
|
|
+ angle += angleVelocity;
|
|
|
}
|
|
|
|
|
|
void Game::render(float lag, Renderer& r) {
|
|
@@ -380,11 +391,13 @@ void Game::render(float lag, Renderer& r) {
|
|
|
.update();
|
|
|
r.drawRectangle(waterPosition, waterSize, Color4(0x00, 0x00, 0xFF, 0xFF));
|
|
|
|
|
|
+ Vector2 pos = Utils::interpolate(lastPosition, position, lag);
|
|
|
+
|
|
|
r.push();
|
|
|
r.translateTo(0.0f, 0.0f)
|
|
|
.translate(-size * 0.5f)
|
|
|
.rotate(atanf(steepness) * 180.0f / M_PI)
|
|
|
- .translate(Utils::interpolate(lastPosition, position, lag))
|
|
|
+ .translate(pos)
|
|
|
.translate(size * 0.5f)
|
|
|
.scale(1.0f, -1.0f)
|
|
|
.translateY(Engine::getSize().height)
|
|
@@ -393,6 +406,21 @@ void Game::render(float lag, Renderer& r) {
|
|
|
r.pop();
|
|
|
r.update();
|
|
|
|
|
|
+ for(int i = 0; i < 360; i += 120) {
|
|
|
+ r.push();
|
|
|
+ r.translateTo(0.0f, 0.0f)
|
|
|
+ .translate(size * 0.75f)
|
|
|
+ .rotate(angle + i)
|
|
|
+ .translate(pos + size * 0.5f)
|
|
|
+ .scale(1.0f, -1.0f)
|
|
|
+ .translateY(Engine::getSize().height)
|
|
|
+ .update();
|
|
|
+ r.drawRectangle(Vector2(), size * 0.25f,
|
|
|
+ Color4(0xFF, 0x00, 0xFF, 0xFF));
|
|
|
+ r.pop();
|
|
|
+ r.update();
|
|
|
+ }
|
|
|
+
|
|
|
r.drawRectangle(
|
|
|
Utils::interpolate(projectileLastPosition, projectilePosition, lag),
|
|
|
projectileSize, Color4(0xFF, 0xFF, 0x00, 0xFF));
|