Skip to content

Commit

Permalink
grant speed score bonus to all manner of fast play
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinorg committed May 14, 2022
1 parent dfa14ed commit fd0c29f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ sdk.dir=/opt/homebrew/share/android-commandlinetools/
* Achieving greatness:

```shell
desktop/build/libs/desktop-0.1.jar
desktop/build/libs/desktop-1.0.jar
```

* Which you can run:

```shell
java -jar desktop/build/libs/desktop-0.1.jar
java -jar desktop/build/libs/desktop-1.0.jar
# or, on a Mac
java -XstartOnFirstThread -jar desktop/build/libs/desktop-0.1.jar
java -XstartOnFirstThread -jar desktop/build/libs/desktop-1.0.jar
```

### Packaging for a Mac
Expand All @@ -81,14 +81,14 @@ jpackage \
--input desktop/build/libs/ \
--name Tertis \
--app-version 1.0 \
--main-jar desktop-0.1.jar \
--main-jar desktop-1.0.jar \
--main-class org.merlin.tertis.DesktopLauncher \
--type dmg \
--java-options '-XstartOnFirstThread' \
--icon mac/Tertis.icns
```

Yielding: `Tertis-1.0.dmg`. Version 0 is not allowed.
Yielding: `Tertis-1.0.dmg`.

## Building for Android

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
allprojects {
apply plugin: "eclipse"

version = '0.1'
version = '1.0'
ext {
appName = "run"
gdxVersion = '1.11.0'
Expand Down
14 changes: 8 additions & 6 deletions core/src/org/merlin/tertis/game/Player.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.badlogic.gdx.Input.Peripheral
import com.badlogic.gdx.graphics.g2d.{BitmapFont, PolygonSpriteBatch}
import org.merlin.tertis.Geometry._
import org.merlin.tertis.Tertis
import org.merlin.tertis.util.Average

case class BlockLoc(block: Block, rotation: Int, column: Int, y: Float)

Expand All @@ -15,15 +16,15 @@ object BlockLoc {
}

class Player(game: Game) {
// how many seconds has this been touched down
// how many seconds has the piece been touched down
var touchdown: Option[Float] = None
// was this piece played all speeidly
var speedy: Boolean = true
// average speed
val speed = new Average

var blockOpt: Option[BlockLoc] = None

def next(block: Block): Unit = {
speedy = true
speed.reset()
blockOpt = Some(BlockLoc(block))
}

Expand Down Expand Up @@ -53,7 +54,6 @@ class Player(game: Game) {
val now = System.currentTimeMillis
val fastness =
game.fast.fold(1f, Prefs.TiltSpeed.fold(tiltSpeed, 0f))
if (fastness < .8f) speedy = false

val speedup =
1f + game.zenMode.fold(
Expand All @@ -64,6 +64,8 @@ class Player(game: Game) {
GravitySpeed,
SlowSpeed + (FastSpeed - SlowSpeed) * fastness * speedup
)
speed += velocityY

// if you move two dimension units you could jump through blocks
val deltaY = (velocityY * Dimension * delta) min (Dimension * 15 / 8)
val newY = oldLoc.y - deltaY
Expand Down Expand Up @@ -105,7 +107,7 @@ class Player(game: Game) {
touchdown = None
blockOpt = None
game.gravity = false
game.score.drop(speedy)
game.score.drop(speed.value / SlowSpeed)
} else {
touchdown = touchdown.map(_ + delta).orElse(Some(0f))
}
Expand Down
10 changes: 5 additions & 5 deletions core/src/org/merlin/tertis/game/Score.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ class Score {
var score: Int = 0
var count: Int = 0
var rows: Int = 0
var speedRun: Int = 0
var speedRun: Int = 0 // sequential piece dropped at >= SpeedRunSpeed
var highScore: Boolean = false

// TODO: gravity assist should be equivalent to speedy if you are quick about it. zen lower score?

def drop(speedy: Boolean): Unit = {
// speed is multiple of slow speed that was used
def drop(speed: Float): Unit = {
count = count + 1
speedRun = speedy.fold(1 + speedRun, 0)
speedRun = (speed >= SpeedRunSpeed).fold(1 + speedRun, 0)
score = score + speedRun
}

Expand Down Expand Up @@ -71,4 +70,5 @@ class Score {
}

val FadeInSeconds = 1f
val SpeedRunSpeed = 4f // a piece is speedy if dropped at >= 4x slow speed
}
18 changes: 18 additions & 0 deletions core/src/org/merlin/tertis/util/Average.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.merlin.tertis.util

class Average {
private var average = 0f
private var count = 0

def +=(f: Float): Unit = {
average += f
count += 1
}

def value: Float = average / (count max 1) // heh

def reset(): Unit = {
average = 0f
count = 0
}
}

0 comments on commit fd0c29f

Please sign in to comment.