Skip to content

Commit

Permalink
Add vivid eye color for each creature stage
Browse files Browse the repository at this point in the history
This is inspired by Badland, Orbia, and Ordia
  • Loading branch information
lloydlobo committed Nov 7, 2024
1 parent 2c2eb51 commit 6b6e037
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
26 changes: 17 additions & 9 deletions src/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ local M = {}

local Config = require 'config'

--- @enum STATUS
--- @enum Status
M.STATUS = {
NOT_ACTIVE = 0,
ACTIVE = 1,
}

-- curr_state.creatures_is_spawn[] ???

--- @enum HEALTH_TRANSITIONS
--- @enum HealthTransitions
M.HEALTH_TRANSITIONS = {
NONE = -1,
HEALING = 0, --- Creature did spawn, and saved and now inactive but healing.
HEALTHY = 1,
}

--- @enum CONTROL_KEY
--- @enum ControlKey
M.CONTROL_KEY = {
BESERK = 'z',
BOOST = 'x', --- `x`─Boost player
Expand All @@ -31,7 +31,7 @@ M.CONTROL_KEY = {
TOGGLE_HUD = 'h',
}

--- @enum PLAYER_ACTION
--- @enum PlayerAction
M.PLAYER_ACTION = {
BESERK = 'BESERK',
BOOST = 'BOOST',
Expand All @@ -40,22 +40,30 @@ M.PLAYER_ACTION = {
IDLE = 'IDLE',
}

--- @enum PLAYER_DAMAGE_STATUS
--- @enum PlayerDamageStatus
M.PLAYER_DAMAGE_STATUS = {
DAMAGED = 'DAMAGED',
DEAD = 'DEAD',
INVULNERABLE = 'INVULNERABLE',
}

--- @enum SCREEN_FLASH_ALPHA_LEVEL
--- @enum ScreenFlashAlphaLevel
M.SCREEN_FLASH_ALPHA_LEVEL = {
HIGH = 0.25, --- note: high level needs a fade out timer
MEDIUM = 0.1,
LOW = 0.045,
}

--- @enum CREATURE_STAGE_COLORS
--- @enum CreatureStageEyeColors
--- Based on creature_evolution_stages `Stage[]` where the size decreases as stage progresses.
M.CREATURE_STAGE_EYE_COLORS = {
{ 0.92, 0.90, 0.50 },
{ 0.75, 0.70, 0.90 },
{ 0.50, 0.80, 0.30 },
{ 0.00, 0.00, 0.00 },
}

--- @enum CreatureStageColors
M.CREATURE_STAGE_COLORS = {
{ 0.75, 0.1, 0.3 },
{ 0.70, 0.2, 0.3 },
Expand Down Expand Up @@ -115,7 +123,7 @@ function M.desaturate(color)
}
end

--- @type table<PLAYER_ACTION, [number, number, number]>
--- @type table<PlayerAction, [number, number, number]>
M.PLAYER_ACTION_TO_COLOR = {
[M.PLAYER_ACTION.COMPANION] = M.COLOR.player_companion_modifier,
[M.PLAYER_ACTION.BESERK] = M.COLOR.player_beserker_modifier,
Expand All @@ -124,7 +132,7 @@ M.PLAYER_ACTION_TO_COLOR = {
[M.PLAYER_ACTION.IDLE] = M.COLOR.player_entity_firing_edge_dark, -- for laser
}

--- @type table<PLAYER_ACTION, [number, number, number]>
--- @type table<PlayerAction, [number, number, number]>
M.PLAYER_ACTION_TO_DESATURATED_COLOR = {
[M.PLAYER_ACTION.COMPANION] = M.desaturate(M.COLOR.player_companion_modifier),
[M.PLAYER_ACTION.BESERK] = M.desaturate(M.COLOR.player_beserker_modifier),
Expand Down
18 changes: 9 additions & 9 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ local PI, INV_PI = Config.PI, Config.INV_PI
--- @class (exact) GameState
--- @field creatures_angle number[]
--- @field creatures_evolution_stage integer[]
--- @field creatures_health HEALTH_TRANSITIONS[] # Transitions from `-1 to 0` and `0..1`.
--- @field creatures_is_active STATUS[]
--- @field creatures_health HealthTransitions[] # Transitions from `-1 to 0` and `0..1`.
--- @field creatures_is_active Status[]
--- @field creatures_vel_x number[]
--- @field creatures_vel_y number[]
--- @field creatures_x number[]
--- @field creatures_y number[]
--- @field lasers_angle number[]
--- @field lasers_is_active STATUS[]
--- @field lasers_is_active Status[]
--- @field lasers_time_left number[]
--- @field lasers_x number[]
--- @field lasers_y number[]
Expand Down Expand Up @@ -141,7 +141,7 @@ parallax_entities = {

--- @class (exact) PlayerTrails
--- @field index integer # 1..`MAX_PLAYER_TRAIL_COUNT`
--- @field is_active STATUS[]
--- @field is_active Status[]
--- @field rot_angle number[]
--- @field time_left number[]
--- @field vel_x number[]
Expand Down Expand Up @@ -412,7 +412,7 @@ end

--- Mutates `player_invulnerability_timer`. Returns player damage state.
--- @param damage integer? Defaults to `1`.
--- @return PLAYER_DAMAGE_STATUS
--- @return PlayerDamageStatus
--- @nodiscard
local function damage_player_fetch_status(damage)
local cs = curr_state
Expand Down Expand Up @@ -507,7 +507,7 @@ end

--- TODO: Add screen transition using a Timer.
--- TODO: Fade to black and then back to player if reset_game
--- @param status PLAYER_DAMAGE_STATUS
--- @param status PlayerDamageStatus
function player_damage_status_actions(status)
if status == Common.PLAYER_DAMAGE_STATUS.DEAD then
screenshake.duration = 0.15 * PHI * PHI
Expand Down Expand Up @@ -1254,7 +1254,7 @@ function draw_player_shield_collectible(alpha)
end

function _draw_active_projectile(i, alpha)
local prev_player_action = player_action --- @type PLAYER_ACTION
local prev_player_action = player_action --- @type PlayerAction

local pos_x = curr_state.lasers_x[i]
local pos_y = curr_state.lasers_y[i]
Expand Down Expand Up @@ -1433,7 +1433,7 @@ function draw_creatures(alpha)
end
end
-- LG.setColor(0.2, 0.8, 0.5)
LG.setColor(Common.CREATURE_STAGE_COLORS[stage])
LG.setColor(Common.CREATURE_STAGE_EYE_COLORS[stage])
LG.circle('fill', x, y, radius * INV_PHI_SQ * INV_PHI)
end
end
Expand Down Expand Up @@ -2208,7 +2208,7 @@ function love.load()
dt_accum = 0.0 --- @type number Accumulator keeps track of time passed between frames.
game_level = 1 --- @type integer
is_debug_hud_enable = not true --- Toggled on key `h` `keyDown` event.
player_action = Common.PLAYER_ACTION.IDLE --- @type PLAYER_ACTION
player_action = Common.PLAYER_ACTION.IDLE --- @type PlayerAction
screenshake = { amount = 5 * 0.5 * Config.INV_PHI, duration = 0.0, offset_x = 0.0, offset_y = 0.0, wait = 0.0 } --[[@type ScreenShake]]

-- Global variables that **must** be reset at each level.
Expand Down

0 comments on commit 6b6e037

Please sign in to comment.