make weak enemies faster
This commit is contained in:
parent
f58f3d0f86
commit
f8b61d6edd
@ -11,15 +11,17 @@ const friction = 0.99;
|
|||||||
const walkForce = 4000;
|
const walkForce = 4000;
|
||||||
const maxSpeed = 200;
|
const maxSpeed = 200;
|
||||||
const handDistance = 50;
|
const handDistance = 50;
|
||||||
const deathBallSize: f32 = 13;
|
const death_ball_size: f32 = 13;
|
||||||
const playerSize = 20;
|
const playerSize = 20;
|
||||||
const virtualWidth = 350;
|
const virtualWidth = 350;
|
||||||
const virtualHeight = 350;
|
const virtualHeight = 350;
|
||||||
|
|
||||||
const safeRadius = 500;
|
const safeRadius = 500;
|
||||||
const spawnAreaWidth = 400;
|
const spawnAreaWidth = 400;
|
||||||
|
|
||||||
const arenaRadius = safeRadius + spawnAreaWidth;
|
const arenaRadius = safeRadius + spawnAreaWidth;
|
||||||
|
|
||||||
|
const shadow_offset = rl.Vector2.one().scale(8);
|
||||||
|
|
||||||
const enemyFriction = friction;
|
const enemyFriction = friction;
|
||||||
|
|
||||||
const Enemy = struct {
|
const Enemy = struct {
|
||||||
@ -41,7 +43,7 @@ const Enemy = struct {
|
|||||||
.color = rl.YELLOW,
|
.color = rl.YELLOW,
|
||||||
.size = 10.0,
|
.size = 10.0,
|
||||||
.acceleration = 5000.0,
|
.acceleration = 5000.0,
|
||||||
.maxSpeed = 150,
|
.maxSpeed = 200,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,8 +297,11 @@ fn updateEnemies(self: *Self) !void {
|
|||||||
if (self.enemyTimer <= 0 and player.alive()) {
|
if (self.enemyTimer <= 0 and player.alive()) {
|
||||||
self.enemyTimer = 0.5 + rng.float(f32) * 2;
|
self.enemyTimer = 0.5 + rng.float(f32) * 2;
|
||||||
self.spawnedEnemiesCount += 1;
|
self.spawnedEnemiesCount += 1;
|
||||||
const enemyPosition = rl.Vector2.randomOnUnitCircle(rng).scale(400);
|
|
||||||
try enemies.append(Enemy.initStrong(enemyPosition));
|
const spawn_distance = rng.floatNorm(f32) * spawnAreaWidth/8 + spawnAreaWidth/2 + safeRadius;
|
||||||
|
const spawn_angle = rng.float(f32) * 2 * rl.PI;
|
||||||
|
const enemy_position = (rl.Vector2{ .x = spawn_distance, .y = 0 }).rotate(spawn_angle);
|
||||||
|
try enemies.append(Enemy.initStrong(enemy_position));
|
||||||
}
|
}
|
||||||
|
|
||||||
const deathBallPosition = rope.lastNodePosition();
|
const deathBallPosition = rope.lastNodePosition();
|
||||||
@ -307,7 +312,7 @@ fn updateEnemies(self: *Self) !void {
|
|||||||
self.damagePlayer();
|
self.damagePlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enemy.vulnerable() and player.alive() and rl.Vector2Distance(enemy.position, deathBallPosition) < enemy.size + deathBallSize) {
|
if (enemy.vulnerable() and player.alive() and rl.Vector2Distance(enemy.position, deathBallPosition) < enemy.size + death_ball_size) {
|
||||||
self.damageEnemy(enemy);
|
self.damageEnemy(enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,8 +380,8 @@ fn damageEnemy(self: *Self, enemy: *Enemy) void {
|
|||||||
enemy.health -= 1;
|
enemy.health -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enemy.invincibility = 0.5;
|
enemy.invincibility = 0.75;
|
||||||
enemy.stunned = 0.75;
|
enemy.stunned = 0.9;
|
||||||
enemy.velocity = deathBallVelocity.scale(20000);
|
enemy.velocity = deathBallVelocity.scale(20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,7 +570,7 @@ fn drawWorld(self: *Self) void {
|
|||||||
rl.rlSetLineWidth(1);
|
rl.rlSetLineWidth(1);
|
||||||
var enemies = &self.enemies;
|
var enemies = &self.enemies;
|
||||||
var rope = &self.rope;
|
var rope = &self.rope;
|
||||||
const deathBallPosition = rope.nodePositions.get(rope.nodePositions.len-1);
|
const death_ball_position = rope.lastNodePosition();
|
||||||
|
|
||||||
rl.ClearBackground(rl.BLACK);
|
rl.ClearBackground(rl.BLACK);
|
||||||
rl.DrawCircle(0, 0, arenaRadius, rl.BROWN);
|
rl.DrawCircle(0, 0, arenaRadius, rl.BROWN);
|
||||||
@ -574,7 +579,13 @@ fn drawWorld(self: *Self) void {
|
|||||||
rl.DrawCircleLines(0, 0, safeRadius, rl.WHITE);
|
rl.DrawCircleLines(0, 0, safeRadius, rl.WHITE);
|
||||||
rl.DrawCircleLines(0, 0, safeRadius + spawnAreaWidth, rl.WHITE);
|
rl.DrawCircleLines(0, 0, safeRadius + spawnAreaWidth, rl.WHITE);
|
||||||
|
|
||||||
self.drawPlayer();
|
for (enemies.items) |*enemy| {
|
||||||
|
rl.DrawCircleV(
|
||||||
|
enemy.position.add(shadow_offset),
|
||||||
|
enemy.size,
|
||||||
|
rgba(0, 0, 0, 100)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
for (enemies.items) |*enemy| {
|
for (enemies.items) |*enemy| {
|
||||||
var color = enemy.color;
|
var color = enemy.color;
|
||||||
@ -582,14 +593,15 @@ fn drawWorld(self: *Self) void {
|
|||||||
color = rl.LIGHTGRAY;
|
color = rl.LIGHTGRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.DrawCircle(
|
rl.DrawCircleV(
|
||||||
@intFromFloat(enemy.position.x),
|
enemy.position,
|
||||||
@intFromFloat(enemy.position.y),
|
|
||||||
enemy.size,
|
enemy.size,
|
||||||
color
|
color
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.drawPlayer();
|
||||||
|
|
||||||
rl.rlDrawRenderBatchActive();
|
rl.rlDrawRenderBatchActive();
|
||||||
rl.rlSetLineWidth(3);
|
rl.rlSetLineWidth(3);
|
||||||
for (0..(rope.nodePositions.len-1)) |i| {
|
for (0..(rope.nodePositions.len-1)) |i| {
|
||||||
@ -610,17 +622,26 @@ fn drawWorld(self: *Self) void {
|
|||||||
rl.DrawCircle(
|
rl.DrawCircle(
|
||||||
@intFromFloat(node.x),
|
@intFromFloat(node.x),
|
||||||
@intFromFloat(node.y),
|
@intFromFloat(node.y),
|
||||||
5,
|
6,
|
||||||
rgb(194, 12, 30)
|
rgb(110, 10, 20)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const death_ball_color = rgb(239, 48, 67);
|
||||||
rl.DrawCircle(
|
rl.DrawCircle(
|
||||||
@intFromFloat(deathBallPosition.x),
|
@intFromFloat(death_ball_position.x),
|
||||||
@intFromFloat(deathBallPosition.y),
|
@intFromFloat(death_ball_position.y),
|
||||||
deathBallSize,
|
death_ball_size,
|
||||||
rgb(239, 48, 67)
|
death_ball_color,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const spikes_count = 5;
|
||||||
|
const spike_size = 8;
|
||||||
|
for (0..spikes_count) |i| {
|
||||||
|
const percent = @as(f32, @floatFromInt(i)) / spikes_count;
|
||||||
|
const extent = rl.Vector2.fromAngle(percent * 2 * rl.PI).scale(death_ball_size + spike_size);
|
||||||
|
rl.DrawLineV(death_ball_position.add(extent), death_ball_position.sub(extent), death_ball_color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tick(self: *Self) !void {
|
pub fn tick(self: *Self) !void {
|
||||||
|
Loading…
Reference in New Issue
Block a user