Skip to content

Commit

Permalink
Merge pull request #14 from mattjennings/dev
Browse files Browse the repository at this point in the history
adjust message box size, add message at end for suspicion
  • Loading branch information
mattjennings committed Jul 9, 2023
2 parents d01047a + d7d5689 commit 8dd6d48
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/actors/referee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class Referee extends BasePlayer {
) as BasePlayer[]

if (nearbyPlayers.length) {
this.suspicion += nearbyPlayers.length * 0.1
this.suspicion += nearbyPlayers.length * 0.5
nearbyPlayers.forEach((player) => {
player.scare(player.pos.sub(this.pos).normalize())
})
Expand Down
23 changes: 19 additions & 4 deletions src/classes/MatchScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { Scoreboard } from '../hud/scoreboard'
import { IcecreamTruck } from 'src/actors/icecream-truck'
import { MessageBox } from 'src/hud/message-box'

export const SCORE_TO_WIN = 5
export const SCORE_TO_WIN = 3

export default class MatchScene extends ex.Scene {
ball: Ball
home: {
Expand Down Expand Up @@ -193,7 +194,7 @@ export default class MatchScene extends ex.Scene {
engine.add(new Scoreboard())
engine.add(
new MessageBox(
'You are a referee. Team Blue paid you to\nhelp them win. Do whatever it takes.\n\nPress Enter to start the game.'
'You are a referee. Team Blue paid you to help them win.\nDo whatever it takes, first to 3 goals wins.\n\nPress Enter to start the game.'
)
)

Expand All @@ -216,15 +217,29 @@ export default class MatchScene extends ex.Scene {
assets.snd_crowdBLow.play()

if (this.home.score >= SCORE_TO_WIN) {
let suspicionMessage = `Team Red didn't suspect a thing.`

if (this.referee.suspicion > 30) {
suspicionMessage = `Team Red was a little suspicious...`
} else if (this.referee.suspicion > 50) {
suspicionMessage = `Team Red is outraged, but you told them\nto deal with it.`
}

this.gameHasStarted = false
this.gameOver = true
this.engine.add(
new MessageBox('Team Blue wins!\n\nPress Enter to play again.')
new MessageBox(
`Team Blue wins! ${suspicionMessage}\n\nPress Enter to play again.`
)
)
} else if (this.away.score >= SCORE_TO_WIN) {
this.gameHasStarted = false
this.gameOver = true
this.engine.add(new MessageBox('You lose.\n\nPress Enter to play again.'))
this.engine.add(
new MessageBox(
'Despite your antics, Team Blue lost.\n\nPress Enter to play again.'
)
)
}

this.reset()
Expand Down
4 changes: 2 additions & 2 deletions src/hud/message-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class MessageBox extends ScreenElement {
constructor(public message: string) {
super({
x: 0,
y: 142,
y: 160,
z: 99999,
})
}
Expand All @@ -29,7 +29,7 @@ export class MessageBox extends ScreenElement {
const text = new ex.Text({
text: this.message,
font: whiteFont,
scale: ex.vec(0.75, 0.75),
scale: ex.vec(0.5, 0.5),
})

const bg = new ex.Rectangle({
Expand Down

0 comments on commit 8dd6d48

Please sign in to comment.