Calculate correct delay for pro game

This commit is contained in:
Mikko Ahlroth 2022-10-08 18:04:12 +03:00
parent 8c8c44053a
commit bb0b4bbf19
5 changed files with 6015 additions and 7 deletions

6001
Score-delay chart.fods Normal file

File diff suppressed because it is too large Load diff

View file

@ -52,9 +52,6 @@ config :ex_speed_game,
# Delay at start of game between ticks, in milliseconds.
delay_start: 570,
# Delay at start of pro game
delay_pro: 321,
# Score at start of pro game
score_pro: 100,

View file

@ -11,16 +11,19 @@ defmodule ExSpeedGame.Game.Menu do
alias ExSpeedGame.PubSub
@initial_delay Application.compile_env!(:ex_speed_game, :delay_start)
@pro_score Application.compile_env!(:ex_speed_game, :score_pro)
@menu {
{"SpeedGame", Speed,
%Speed.Options{
initial_score: 0,
initial_delay: Application.get_env(:ex_speed_game, :delay_start)
initial_delay: @initial_delay
}},
{"SpeedGame Pro", Speed,
%Speed.Options{
initial_score: Application.get_env(:ex_speed_game, :score_pro),
initial_delay: Application.get_env(:ex_speed_game, :delay_pro)
initial_score: @pro_score,
initial_delay: Speed.get_delay_at(@pro_score, @initial_delay)
}},
{"MemoryGame", Speed, %{}},
{"Show IP", ShowIP, %{}},

View file

@ -128,6 +128,13 @@ defmodule ExSpeedGame.Game.Modes.Speed do
ButtonInput.release(ButtonInput)
end
@spec get_delay_at(integer(), float()) :: float()
def get_delay_at(score, initial_delay) do
for _i <- 1..score, reduce: initial_delay do
acc -> get_next_delay(acc)
end
end
@spec schedule_tick(float()) :: float()
defp schedule_tick(delay) do
Process.send_after(self(), :tick, trunc(delay))

View file

@ -2,7 +2,7 @@ defmodule ExSpeedGame.MixProject do
use Mix.Project
@app :ex_speed_game
@version "0.3.0"
@version "0.3.1"
@all_targets [:rpi0]
def project do