Skip to content

Commit

Permalink
Merge pull request #11 from mattjennings/dev
Browse files Browse the repository at this point in the history
d
  • Loading branch information
mattjennings committed Jul 9, 2023
2 parents c7ae1d4 + 234af07 commit 4aa501a
Show file tree
Hide file tree
Showing 16 changed files with 444 additions and 51 deletions.
Binary file added public/sprites/hud_instructions/hud_instructions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/sprites/referee/REFEREE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions public/sprites/score_numbers/score_numbers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{ "frames": {
"score_numbers 0.aseprite": {
"frame": { "x": 0, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 1.aseprite": {
"frame": { "x": 48, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 2.aseprite": {
"frame": { "x": 96, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 3.aseprite": {
"frame": { "x": 144, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 4.aseprite": {
"frame": { "x": 192, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 5.aseprite": {
"frame": { "x": 240, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 6.aseprite": {
"frame": { "x": 288, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 7.aseprite": {
"frame": { "x": 336, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 8.aseprite": {
"frame": { "x": 384, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
},
"score_numbers 9.aseprite": {
"frame": { "x": 432, "y": 0, "w": 48, "h": 48 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 48, "h": 48 },
"sourceSize": { "w": 48, "h": 48 },
"duration": 100
}
},
"meta": {
"app": "https://www.aseprite.org/",
"version": "1.2.34.1-arm64",
"image": "score_numbers.png",
"format": "RGBA8888",
"size": { "w": 480, "h": 48 },
"scale": "1",
"frameTags": [
{ "name": "0", "from": 0, "to": 0, "direction": "forward" },
{ "name": "1", "from": 1, "to": 1, "direction": "forward" },
{ "name": "2", "from": 2, "to": 2, "direction": "forward" },
{ "name": "3", "from": 3, "to": 3, "direction": "forward" },
{ "name": "4", "from": 4, "to": 4, "direction": "forward" },
{ "name": "5", "from": 5, "to": 5, "direction": "forward" },
{ "name": "6", "from": 6, "to": 6, "direction": "forward" },
{ "name": "7", "from": 7, "to": 7, "direction": "forward" },
{ "name": "8", "from": 8, "to": 8, "direction": "forward" },
{ "name": "9", "from": 9, "to": 9, "direction": "forward" }
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}
Binary file added public/sprites/score_numbers/score_numbers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/sprites/team_badges/blue_team_badge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/sprites/team_badges/red_team_badge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions src/actors/base-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export class BasePlayer extends ex.Actor {
animations: Record<string, Animation>

isPain = false
painFrames = 5
isSprinting = false
debug = false

constructor({ sprite, debug, team, ...args }: BasePlayerArgs) {
super({
width: 16,
height: 12,
height: 16,
collisionType: ex.CollisionType.Active,
collider: ex.Shape.Box(16, 12, ex.vec(0.5, 1), ex.vec(0, 12)),
...args,
})
this.team = team
Expand All @@ -52,7 +52,7 @@ export class BasePlayer extends ex.Actor {
this.animations.Pain.events.on('loop', (a) => {
isPainCount++

if (isPainCount > 3) {
if (isPainCount > this.painFrames) {
this.isPain = false
isPainCount = 0
}
Expand Down Expand Up @@ -91,17 +91,21 @@ export class BasePlayer extends ex.Actor {
this.currentGraphic().flipHorizontal = flip
}

isAnimation(name: string) {
return this.currentGraphic() === this.animations[name]
}

moveTo(pos: ex.Vector, speed: number) {
const angle = pos.sub(this.pos).toAngle()

this.vel = ex.vec(speed * Math.cos(angle), speed * Math.sin(angle))
}

hit(direction: ex.Vector) {
scare(direction: ex.Vector) {
this.isPain = true
this.isSprinting = false
this.setAnimation('Pain')
assets.snd_clack.play()
assets.snd_dashB.play()

this.vel = direction.scale(500)
}
Expand Down
108 changes: 108 additions & 0 deletions src/actors/icecream-truck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Engine } from 'excalibur'
import { assets } from 'src/assets'
import MatchScene from 'src/classes/MatchScene'

export class IcecreamTruck extends ex.Actor {
declare scene: MatchScene

hasIcecream = true
isGivingIcecream = false

animations = {
PopUp: assets.ase_icecreamTruck.getAnimation('PopUp')!,
PopDown: assets.ase_icecreamTruck.getAnimation('PopDown')!,
}

sprites = {
hide: assets.ase_icecreamTruck.getSpriteSheet()?.getSprite(0, 0)!,
}

initialPosition: ex.Vector
constructor() {
super({
z: 1,
collisionType: ex.CollisionType.Fixed,
width: 80,
height: 48,
anchor: ex.vec(0.5, 1),
})

this.body.mass = 999999
this.graphics.use(this.sprites.hide)
}

onInitialize(_engine: Engine): void {
this.initialPosition = ex.vec(
this.scene.field.right - this.width / 2 - 80,
this.scene.field.top + this.height + 4
)

this.pos = this.initialPosition

this.animations.PopUp.events.on('frame', (ev: any) => {
const isLastFrame = this.animations.PopUp.frames[3].graphic === ev.graphic

if (isLastFrame) {
this.animations.PopUp.pause()
}
})

this.animations.PopDown.events.on('loop', () => {
this.graphics.use(this.sprites.hide)
})
}

update(engine: Engine, delta: number): void {
const distanceToRef = this.scene.referee.pos.distance(this.pos)

const currentAnim = this.graphics.current[0]

if (!this.isGivingIcecream) {
if (
this.hasIcecream &&
distanceToRef < 50 &&
currentAnim.graphic !== this.animations.PopUp
) {
this.animations.PopUp.goToFrame(0)
this.graphics.use(this.animations.PopUp)
this.animations.PopUp.play()
} else if (
distanceToRef >= 50 &&
currentAnim.graphic === this.animations.PopUp
) {
this.graphics.use(this.animations.PopDown)
}
}
}

giveIcecream() {
const distractionTime = 20000
const restockTime = 20000

if (!this.isGivingIcecream && this.hasIcecream) {
assets.snd_bell.play()
this.isGivingIcecream = true
this.hasIcecream = false
this.graphics.use(this.animations.PopUp)
this.animations.PopUp.play()
this.scene.away.goalie.distract(this, distractionTime)

this.actions
.delay(distractionTime)
.toPromise()
.then(() => {
this.isGivingIcecream = false
this.graphics.use(this.animations.PopDown)
this.actions
.delay(restockTime)
.toPromise()
.then(() => {
this.hasIcecream = true
assets.snd_watchOut.play()
})
})
return true
}
return false
}
}
4 changes: 2 additions & 2 deletions src/actors/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export class Net extends ex.Actor {
name: 'goalLine',
collisionType: ex.CollisionType.Passive,
collider: new ex.EdgeCollider({
begin: topFront.add(ex.vec(this.team === 'home' ? -12 : 12, 0)),
end: bottomFront.add(ex.vec(this.team === 'home' ? -12 : 12, 0)),
begin: topFront.add(ex.vec(this.team === 'home' ? -12 : 12, 4)),
end: bottomFront.add(ex.vec(this.team === 'home' ? -12 : 12, -2)),
}),
})

Expand Down
Loading

0 comments on commit 4aa501a

Please sign in to comment.