Randomize starting position, angle and angular velocity
This commit is contained in:
parent
19298adf8a
commit
e0c78d77e6
4 changed files with 31 additions and 13 deletions
|
@ -7,6 +7,9 @@
|
|||
**Note:** This game was created for the [LibreJam December 2020 game jam](https://leagueh.xyz/en/jam.html).
|
||||
It is playable and winnable, however it is minimalist to say the least.
|
||||
|
||||
Starting position and angle were the same between each game at the time of submission.
|
||||
Randomization has since been added.
|
||||
|
||||
## Screenshot
|
||||
|
||||
[![Screenshot](https://gitlab.com/tslocum/basiclander/-/raw/master/screenshot.png)](https://gitlab.com/tslocum/basiclander/-/raw/master/screenshot.png)
|
||||
|
|
6
go.mod
6
go.mod
|
@ -4,9 +4,9 @@ go 1.15
|
|||
|
||||
require (
|
||||
github.com/ByteArena/box2d v1.0.2
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201109052606-7d87d8188c8d
|
||||
github.com/gdamore/tcell/v2 v2.1.0
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
gitlab.com/tslocum/cbind v0.1.4
|
||||
gitlab.com/tslocum/cview v1.5.2
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect
|
||||
gitlab.com/tslocum/cview v1.5.3-0.20201215184006-1af0da7606b8
|
||||
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 // indirect
|
||||
)
|
||||
|
|
15
go.sum
15
go.sum
|
@ -3,8 +3,8 @@ github.com/ByteArena/box2d v1.0.2/go.mod h1:LzEuxY9iCz+tskfWCY3o0ywYBRafDDugdSj+
|
|||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
github.com/gdamore/tcell/v2 v2.0.0-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201109052606-7d87d8188c8d h1:C1FQEuzw5kUUveSXpZp3v0+qOR+VEnzHsQ7K6n39LsM=
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201109052606-7d87d8188c8d/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/gdamore/tcell/v2 v2.1.0 h1:UnSmozHgBkQi2PGsFr+rpdXuAPRRucMegpQp3Z3kDro=
|
||||
github.com/gdamore/tcell/v2 v2.1.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
|
@ -16,14 +16,13 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
|||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
gitlab.com/tslocum/cbind v0.1.4 h1:cbZXPPcieXspk8cShoT6efz7HAT8yMNQcofYWNizis4=
|
||||
gitlab.com/tslocum/cbind v0.1.4/go.mod h1:RvwYE3auSjBNlCmWeGspzn+jdLUVQ8C2QGC+0nP9ChI=
|
||||
gitlab.com/tslocum/cview v1.5.2 h1:pt1d4L0LGghwpGRDXN5dPTp0+M5cZhoYooblLLNOA1A=
|
||||
gitlab.com/tslocum/cview v1.5.2/go.mod h1:tnNYj71jg9ZvvF9Eu9/2f0Yji0Rwjy2JK36UoS/Hxvo=
|
||||
gitlab.com/tslocum/cview v1.5.3-0.20201215184006-1af0da7606b8 h1:GrT9EG/Q90R1YeJC9XJ5lwzbGupALYIflYl4o0rylZA=
|
||||
gitlab.com/tslocum/cview v1.5.3-0.20201215184006-1af0da7606b8/go.mod h1:xe2ufDmSecnLDd/0sq7QR9BZYWShV61aTXdvr/tEqy0=
|
||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201013132646-2da7054afaeb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201202213521-69691e467435 h1:25AvDqqB9PrNqj1FLf2/70I4W0L19qqoaFq3gjNwbKk=
|
||||
golang.org/x/sys v0.0.0-20201202213521-69691e467435/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88 h1:KmZPnMocC93w341XZp26yTJg8Za7lhb2KhkYmixoeso=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
|
||||
golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
|
||||
|
|
20
main.go
20
main.go
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -41,6 +42,11 @@ const (
|
|||
startX = 15
|
||||
startY = 32
|
||||
|
||||
fuzzStartA = 15 // Angle
|
||||
fuzzStartAV = 0.25 // Angular velocity
|
||||
fuzzStartX = 32
|
||||
fuzzStartY = 3
|
||||
|
||||
startFuel = 2375
|
||||
|
||||
thrustBurnRate = 15
|
||||
|
@ -60,6 +66,7 @@ var (
|
|||
|
||||
playerFuel int
|
||||
|
||||
classicMode bool
|
||||
gameOver bool
|
||||
playerCrashed bool
|
||||
)
|
||||
|
@ -259,9 +266,16 @@ func runSimulation() {
|
|||
bd.FixedRotation = true
|
||||
bd.AllowSleep = false
|
||||
|
||||
body := world.CreateBody(&bd)
|
||||
angle := startAngle
|
||||
if !classicMode {
|
||||
angle += float64(rand.Intn(fuzzStartA))
|
||||
bd.AngularVelocity += fuzzStartAV - (float64(rand.Intn(fuzzStartAV*200)) / 100)
|
||||
bd.Position.X += float64(rand.Intn(fuzzStartX))
|
||||
bd.Position.Y -= float64(rand.Intn(fuzzStartY))
|
||||
}
|
||||
|
||||
body.SetTransform(body.GetPosition(), startAngle)
|
||||
body := world.CreateBody(&bd)
|
||||
body.SetTransform(body.GetPosition(), angle)
|
||||
|
||||
shape := box2d.MakeB2CircleShape()
|
||||
shape.M_radius = 0.5
|
||||
|
@ -348,6 +362,8 @@ func runSimulation() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
app = cview.NewApplication()
|
||||
|
||||
err := app.Init()
|
||||
|
|
Loading…
Reference in a new issue