From 34ba0961469cb8ab3f3d0ae43981116ce9e73b74 Mon Sep 17 00:00:00 2001 From: zenoamaro Date: Sun, 30 Jun 2019 18:14:17 +0200 Subject: [PATCH] Tank damage indication, fall damage tweaks --- src/constants.js | 4 ++-- src/main.js | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/constants.js b/src/constants.js index 300bff8..f3785fe 100644 --- a/src/constants.js +++ b/src/constants.js @@ -71,8 +71,8 @@ export const DEFAULT_KEYPRESS_DELAY = 150; export const PLAYER_MAX_ENERGY = 100; export const PLAYER_ENERGY_POWER_MULTIPLIER = 10; export const PLAYER_INITIAL_POWER = 300; -export const PLAYER_FALL_DAMAGE_HEIGHT = 50; -export const PLAYER_FALL_DAMAGE_FACTOR = 3; +export const PLAYER_FALL_DAMAGE_HEIGHT = 25; +export const PLAYER_FALL_DAMAGE_FACTOR = 2; export const PLAYER_EXPLOSION_PARTICLE_POWER = 500; export const PLAYER_TANK_BOUNDING_RADIUS = 4; export const PLAYER_TANK_Y_FOOTPRINT = -2; diff --git a/src/main.js b/src/main.js index a02fa6e..7e82d4d 100644 --- a/src/main.js +++ b/src/main.js @@ -370,7 +370,7 @@ function draw() { function drawPlayers() { for (let player of players) { - const {x, y, a, c, cb, dead} = player; + const {x, y, a, c, cb, energy, dead} = player; if (dead) continue; const [px, py] = vec(x, y-3, a+180, 3); drawLine(foreground, x-1, y-3, px-1, py, cb); @@ -383,6 +383,13 @@ function drawPlayers() { drawLine(foreground, x, y-3, px, py, c); drawRect(foreground, x-4, y-2, 8, 2, c); drawRect(foreground, x-3, y-0, 6, 1, c); + + const damage = clamp(0, 1 - energy/PLAYER_MAX_ENERGY, 1); + foreground.globalAlpha = damage * 0.7; + drawRect(foreground, x-4, y-2, 8, 2, cb); + foreground.globalAlpha = damage; + drawRect(foreground, x-3, y-0, 6, 1, cb); + foreground.globalAlpha = 1; } }