Commit 5d3856f9 authored by Evert Prants's avatar Evert Prants

Fix goal calulcation

parent 85dd6cf4
......@@ -2,6 +2,8 @@ import { canvas, ctx } from './canvas'
import { Level, Rock, Gold, Diamond, Lootbag } from './level'
import { randomi } from './utils'
const MAP_CLEARANCE_PERCENTAGE = 80
const REWARD_TABLE = {
rock: 16,
gold: [129, 543, 2399],
......@@ -16,6 +18,7 @@ export class Game {
this.roundTime = time
this.time = time
this.score = 0
this.lastGoal = 0
this.goal = 0
this.level = null
......@@ -68,7 +71,8 @@ export class Game {
this.currentLevel++
this.time = this.roundTime
this.level = Level.create(this.currentLevel, this.oh, this.gw, this.gh)
this.goal = Math.floor(this.score / 2 + Game.calculateLevelScore(this.level) * 0.65)
this.lastGoal = this.goal
this.goal = Math.floor(this.lastGoal + Game.calculateLevelScore(this.level) * (MAP_CLEARANCE_PERCENTAGE / 100))
this.player.hook.clear()
}
......@@ -142,6 +146,7 @@ export class Game {
setTimeout(() => {
this.currentLevel = 0
this.score = 0
this.lastGoal = 0
this.nextLevel()
this.state = 0
}, 500)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment