Skip to content

Commit

Permalink
refactor(constants): replace avatar with expression
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 27, 2025
1 parent d95908f commit 19122f2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
5 changes: 0 additions & 5 deletions src/constants/avatar.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/constants/expression.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export enum Expression {
Dead = 'Dead',
Hit = 'Hit',
Hurt = 'Hurt',
Normal = 'Normal',
Pissed = 'Pissed',
Smug = 'Smug',
Sus = 'Sus',
}
1 change: 0 additions & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './animation'
export * from './avatar'
export * from './expression'
export * from './layer'
export * from './music'
Expand Down
14 changes: 7 additions & 7 deletions src/gameobjects/player.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Avatar, Expression, Scene, Sound, Sprite, Tag } from '../constants'
import { Expression, Scene, Sound, Sprite, Tag } from '../constants'
import { addAttack, addCursorKeys } from '../events'
import { getAvatar, getChildBubble, stopMusic } from '../gameobjects'
import { gameState } from '../helpers'
Expand Down Expand Up @@ -32,7 +32,7 @@ export function addPlayer(x = center().x, y = center().y) {
player.onCollide(Tag.Projectile, onHit(player))

player.onDeath(() => {
getAvatar().play(Avatar.Hurt)
getAvatar().play(Expression.Hurt)

const deadPlayer = add([
sprite(Sprite.Kiki),
Expand Down Expand Up @@ -76,17 +76,17 @@ function onHit(player: Player) {
const avatar = getAvatar()

if (player.hp() < player.maxHP()! / 4) {
player.play(Expression.Pissed)
avatar.play(Avatar.Hurt)
player.play(Expression.Hurt)
avatar.play(Expression.Hurt)
} else {
player.play(Expression.Hit)
avatar.play(Avatar.Hit)
avatar.play(Expression.Hit)
}

wait(1, () => {
player.play(Expression.Normal)
if (player.exists()) {
avatar.play(Avatar.Normal)
player.play(Expression.Normal)
avatar.play(Expression.Normal)
}
})
}
Expand Down
9 changes: 4 additions & 5 deletions src/scenes/preload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Animation,
Avatar,
Expression,
Music,
Scene,
Expand Down Expand Up @@ -74,17 +73,17 @@ scene(Scene.Preload, () => {
[Expression.Smug]: 1,
[Expression.Sus]: 2,
[Expression.Hit]: 3,
[Expression.Pissed]: 4,
[Expression.Hurt]: 4,
[Expression.Dead]: 5,
},
})

loadSprite(Sprite.Avatar, 'sprites/avatar.png', {
sliceX: 3,
anims: {
[Avatar.Normal]: 0,
[Avatar.Hit]: 1,
[Avatar.Hurt]: 2,
[Expression.Normal]: 0,
[Expression.Hit]: 1,
[Expression.Hurt]: 2,
},
})

Expand Down

0 comments on commit 19122f2

Please sign in to comment.