fix other bugs

This commit is contained in:
Josh Deprez 2021-09-09 09:26:41 +10:00
parent b2e2a370fc
commit d3527d192f
2 changed files with 193 additions and 191 deletions

View file

@ -6,6 +6,7 @@ import (
"math"
"drjosh.dev/gurgle/engine"
"drjosh.dev/gurgle/geom"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
)
@ -118,7 +119,7 @@ func (aw *Awakeman) realUpdate() error {
ux, uy, uz := aw.vx, aw.vy, aw.vz
// Has traction?
if aw.vy >= 0 && aw.Sprite.Actor.CollidesAt(aw.Sprite.Actor.Pos.Add(engine.Pt3(0, 1, 0))) {
if aw.vy >= 0 && aw.Sprite.Actor.CollidesAt(aw.Sprite.Actor.Pos.Add(geom.Pt3(0, 1, 0))) {
// Not falling.
// Instantly decelerate (AW absorbs all kinetic E in legs, or something)
if aw.jumpBuffer > 0 {

381
main.go
View file

@ -12,6 +12,7 @@ import (
"drjosh.dev/gurgle/engine"
"drjosh.dev/gurgle/game"
"drjosh.dev/gurgle/geom"
"github.com/hajimehoshi/ebiten/v2"
)
@ -52,12 +53,12 @@ func main() {
g := &engine.Game{
ScreenSize: image.Pt(320, 240), // Window interior is this many pixels.
Projection: engine.IntProjection{
Projection: geom.IntProjection{
// Each 1 voxel step in Z is projected into 1 pixel in Y.
X: 0,
Y: 1,
},
VoxelScale: engine.Float3{
VoxelScale: geom.Float3{
// Each voxel counts for this much Eucliden space.
X: 1,
Y: 1,
@ -113,14 +114,14 @@ func level1() *engine.Scene {
&engine.PrismMap{
ID: "hexagons",
DrawOrderBias: image.Pt(0, -1), // draw higher Y after lower Y
PosToWorld: engine.IntMatrix3x4{
PosToWorld: geom.IntMatrix3x4{
// For each tile in the X direction, go right by 24 and
// forward by 8, etc
0: [4]int{24, 0, 0, 0},
1: [4]int{0, 16, 0, 0},
2: [4]int{8, 0, 16, 0},
},
PrismSize: engine.Int3{X: 32, Y: 16, Z: 16},
PrismSize: geom.Int3{X: 32, Y: 16, Z: 16},
PrismTop: []image.Point{
{X: 8, Y: 0},
{X: 0, Y: 8},
@ -133,209 +134,209 @@ func level1() *engine.Scene {
CellSize: image.Pt(32, 32),
Src: engine.ImageRef{Path: "assets/hexprism32.png"},
},
Map: map[engine.Int3]*engine.Prism{
engine.Pt3(11, 0, -6): {},
engine.Pt3(12, 0, -6): {},
Map: map[geom.Int3]*engine.Prism{
geom.Pt3(11, 0, -6): {},
geom.Pt3(12, 0, -6): {},
engine.Pt3(9, 0, -5): {},
engine.Pt3(10, 0, -5): {},
engine.Pt3(11, 0, -5): {},
engine.Pt3(12, 0, -5): {},
geom.Pt3(9, 0, -5): {},
geom.Pt3(10, 0, -5): {},
geom.Pt3(11, 0, -5): {},
geom.Pt3(12, 0, -5): {},
engine.Pt3(7, 0, -4): {},
engine.Pt3(8, 0, -4): {},
engine.Pt3(9, 0, -4): {},
engine.Pt3(10, 0, -4): {},
engine.Pt3(11, 0, -4): {},
engine.Pt3(12, 0, -4): {},
geom.Pt3(7, 0, -4): {},
geom.Pt3(8, 0, -4): {},
geom.Pt3(9, 0, -4): {},
geom.Pt3(10, 0, -4): {},
geom.Pt3(11, 0, -4): {},
geom.Pt3(12, 0, -4): {},
engine.Pt3(5, 0, -3): {},
engine.Pt3(6, 0, -3): {},
engine.Pt3(7, 0, -3): {},
engine.Pt3(8, 0, -3): {},
engine.Pt3(9, 0, -3): {},
engine.Pt3(10, 0, -3): {},
engine.Pt3(11, 0, -3): {},
engine.Pt3(12, 0, -3): {},
geom.Pt3(5, 0, -3): {},
geom.Pt3(6, 0, -3): {},
geom.Pt3(7, 0, -3): {},
geom.Pt3(8, 0, -3): {},
geom.Pt3(9, 0, -3): {},
geom.Pt3(10, 0, -3): {},
geom.Pt3(11, 0, -3): {},
geom.Pt3(12, 0, -3): {},
engine.Pt3(3, 0, -2): {},
engine.Pt3(4, 0, -2): {},
engine.Pt3(5, 0, -2): {},
engine.Pt3(6, 0, -2): {},
engine.Pt3(7, 0, -2): {},
engine.Pt3(8, 0, -2): {},
engine.Pt3(9, 0, -2): {},
engine.Pt3(10, 0, -2): {},
engine.Pt3(11, 0, -2): {},
engine.Pt3(12, 0, -2): {},
geom.Pt3(3, 0, -2): {},
geom.Pt3(4, 0, -2): {},
geom.Pt3(5, 0, -2): {},
geom.Pt3(6, 0, -2): {},
geom.Pt3(7, 0, -2): {},
geom.Pt3(8, 0, -2): {},
geom.Pt3(9, 0, -2): {},
geom.Pt3(10, 0, -2): {},
geom.Pt3(11, 0, -2): {},
geom.Pt3(12, 0, -2): {},
engine.Pt3(1, 0, -1): {},
engine.Pt3(2, 0, -1): {},
engine.Pt3(3, 0, -1): {},
engine.Pt3(4, 0, -1): {},
engine.Pt3(5, 0, -1): {},
engine.Pt3(6, 0, -1): {},
engine.Pt3(7, 0, -1): {},
engine.Pt3(8, 0, -1): {},
engine.Pt3(9, 0, -1): {},
engine.Pt3(10, 0, -1): {},
engine.Pt3(11, 0, -1): {},
engine.Pt3(12, 0, -1): {},
geom.Pt3(1, 0, -1): {},
geom.Pt3(2, 0, -1): {},
geom.Pt3(3, 0, -1): {},
geom.Pt3(4, 0, -1): {},
geom.Pt3(5, 0, -1): {},
geom.Pt3(6, 0, -1): {},
geom.Pt3(7, 0, -1): {},
geom.Pt3(8, 0, -1): {},
geom.Pt3(9, 0, -1): {},
geom.Pt3(10, 0, -1): {},
geom.Pt3(11, 0, -1): {},
geom.Pt3(12, 0, -1): {},
engine.Pt3(0, 0, 0): {},
engine.Pt3(1, 0, 0): {},
engine.Pt3(2, 0, 0): {},
engine.Pt3(3, 0, 0): {},
engine.Pt3(4, 0, 0): {},
engine.Pt3(5, 0, 0): {},
engine.Pt3(6, 0, 0): {},
engine.Pt3(7, 0, 0): {},
engine.Pt3(8, 0, 0): {},
engine.Pt3(9, 0, 0): {},
engine.Pt3(10, 0, 0): {},
engine.Pt3(11, 0, 0): {},
engine.Pt3(12, 0, 0): {},
geom.Pt3(0, 0, 0): {},
geom.Pt3(1, 0, 0): {},
geom.Pt3(2, 0, 0): {},
geom.Pt3(3, 0, 0): {},
geom.Pt3(4, 0, 0): {},
geom.Pt3(5, 0, 0): {},
geom.Pt3(6, 0, 0): {},
geom.Pt3(7, 0, 0): {},
geom.Pt3(8, 0, 0): {},
geom.Pt3(9, 0, 0): {},
geom.Pt3(10, 0, 0): {},
geom.Pt3(11, 0, 0): {},
geom.Pt3(12, 0, 0): {},
engine.Pt3(0, 0, 1): {},
engine.Pt3(1, 0, 1): {},
engine.Pt3(2, 0, 1): {},
engine.Pt3(3, 0, 1): {},
engine.Pt3(4, 0, 1): {},
engine.Pt3(5, 0, 1): {},
engine.Pt3(6, 0, 1): {},
engine.Pt3(7, 0, 1): {},
engine.Pt3(8, 0, 1): {},
engine.Pt3(9, 0, 1): {},
engine.Pt3(10, 0, 1): {},
engine.Pt3(11, 0, 1): {},
engine.Pt3(12, 0, 1): {},
geom.Pt3(0, 0, 1): {},
geom.Pt3(1, 0, 1): {},
geom.Pt3(2, 0, 1): {},
geom.Pt3(3, 0, 1): {},
geom.Pt3(4, 0, 1): {},
geom.Pt3(5, 0, 1): {},
geom.Pt3(6, 0, 1): {},
geom.Pt3(7, 0, 1): {},
geom.Pt3(8, 0, 1): {},
geom.Pt3(9, 0, 1): {},
geom.Pt3(10, 0, 1): {},
geom.Pt3(11, 0, 1): {},
geom.Pt3(12, 0, 1): {},
engine.Pt3(0, 0, 2): {},
engine.Pt3(1, 0, 2): {},
engine.Pt3(2, 0, 2): {},
engine.Pt3(3, 0, 2): {},
engine.Pt3(4, 0, 2): {},
engine.Pt3(5, 0, 2): {},
engine.Pt3(6, 0, 2): {},
engine.Pt3(7, 0, 2): {},
engine.Pt3(8, 0, 2): {},
engine.Pt3(9, 0, 2): {},
engine.Pt3(10, 0, 2): {},
engine.Pt3(11, 0, 2): {},
engine.Pt3(12, 0, 2): {},
geom.Pt3(0, 0, 2): {},
geom.Pt3(1, 0, 2): {},
geom.Pt3(2, 0, 2): {},
geom.Pt3(3, 0, 2): {},
geom.Pt3(4, 0, 2): {},
geom.Pt3(5, 0, 2): {},
geom.Pt3(6, 0, 2): {},
geom.Pt3(7, 0, 2): {},
geom.Pt3(8, 0, 2): {},
geom.Pt3(9, 0, 2): {},
geom.Pt3(10, 0, 2): {},
geom.Pt3(11, 0, 2): {},
geom.Pt3(12, 0, 2): {},
engine.Pt3(0, 0, 3): {},
engine.Pt3(1, 0, 3): {},
engine.Pt3(2, 0, 3): {},
engine.Pt3(3, 0, 3): {},
engine.Pt3(4, 0, 3): {},
engine.Pt3(5, 0, 3): {},
engine.Pt3(6, 0, 3): {},
engine.Pt3(7, 0, 3): {},
engine.Pt3(8, 0, 3): {},
engine.Pt3(9, 0, 3): {},
engine.Pt3(10, 0, 3): {},
engine.Pt3(11, 0, 3): {},
engine.Pt3(12, 0, 3): {},
geom.Pt3(0, 0, 3): {},
geom.Pt3(1, 0, 3): {},
geom.Pt3(2, 0, 3): {},
geom.Pt3(3, 0, 3): {},
geom.Pt3(4, 0, 3): {},
geom.Pt3(5, 0, 3): {},
geom.Pt3(6, 0, 3): {},
geom.Pt3(7, 0, 3): {},
geom.Pt3(8, 0, 3): {},
geom.Pt3(9, 0, 3): {},
geom.Pt3(10, 0, 3): {},
geom.Pt3(11, 0, 3): {},
geom.Pt3(12, 0, 3): {},
engine.Pt3(0, 0, 4): {},
engine.Pt3(1, 0, 4): {},
engine.Pt3(2, 0, 4): {},
engine.Pt3(3, 0, 4): {},
engine.Pt3(4, 0, 4): {},
engine.Pt3(5, 0, 4): {},
engine.Pt3(6, 0, 4): {},
engine.Pt3(7, 0, 4): {},
engine.Pt3(8, 0, 4): {},
engine.Pt3(9, 0, 4): {},
engine.Pt3(10, 0, 4): {},
engine.Pt3(11, 0, 4): {},
engine.Pt3(12, 0, 4): {},
geom.Pt3(0, 0, 4): {},
geom.Pt3(1, 0, 4): {},
geom.Pt3(2, 0, 4): {},
geom.Pt3(3, 0, 4): {},
geom.Pt3(4, 0, 4): {},
geom.Pt3(5, 0, 4): {},
geom.Pt3(6, 0, 4): {},
geom.Pt3(7, 0, 4): {},
geom.Pt3(8, 0, 4): {},
geom.Pt3(9, 0, 4): {},
geom.Pt3(10, 0, 4): {},
geom.Pt3(11, 0, 4): {},
geom.Pt3(12, 0, 4): {},
engine.Pt3(0, 0, 5): {},
engine.Pt3(1, 0, 5): {},
engine.Pt3(2, 0, 5): {},
engine.Pt3(3, 0, 5): {},
engine.Pt3(4, 0, 5): {},
engine.Pt3(5, 0, 5): {},
engine.Pt3(6, 0, 5): {},
engine.Pt3(6, -1, 5): {Cell: 1},
engine.Pt3(7, 0, 5): {},
engine.Pt3(8, 0, 5): {},
engine.Pt3(9, 0, 5): {},
engine.Pt3(10, 0, 5): {},
engine.Pt3(11, 0, 5): {},
engine.Pt3(12, 0, 5): {},
geom.Pt3(0, 0, 5): {},
geom.Pt3(1, 0, 5): {},
geom.Pt3(2, 0, 5): {},
geom.Pt3(3, 0, 5): {},
geom.Pt3(4, 0, 5): {},
geom.Pt3(5, 0, 5): {},
geom.Pt3(6, 0, 5): {},
geom.Pt3(6, -1, 5): {Cell: 1},
geom.Pt3(7, 0, 5): {},
geom.Pt3(8, 0, 5): {},
geom.Pt3(9, 0, 5): {},
geom.Pt3(10, 0, 5): {},
geom.Pt3(11, 0, 5): {},
geom.Pt3(12, 0, 5): {},
engine.Pt3(0, 0, 6): {},
engine.Pt3(1, 0, 6): {},
engine.Pt3(2, 0, 6): {},
engine.Pt3(3, 0, 6): {},
engine.Pt3(4, 0, 6): {},
engine.Pt3(5, 0, 6): {},
engine.Pt3(6, 0, 6): {},
engine.Pt3(7, 0, 6): {},
engine.Pt3(8, 0, 6): {},
engine.Pt3(9, 0, 6): {},
engine.Pt3(10, 0, 6): {},
engine.Pt3(11, 0, 6): {},
engine.Pt3(12, 0, 6): {},
geom.Pt3(0, 0, 6): {},
geom.Pt3(1, 0, 6): {},
geom.Pt3(2, 0, 6): {},
geom.Pt3(3, 0, 6): {},
geom.Pt3(4, 0, 6): {},
geom.Pt3(5, 0, 6): {},
geom.Pt3(6, 0, 6): {},
geom.Pt3(7, 0, 6): {},
geom.Pt3(8, 0, 6): {},
geom.Pt3(9, 0, 6): {},
geom.Pt3(10, 0, 6): {},
geom.Pt3(11, 0, 6): {},
geom.Pt3(12, 0, 6): {},
engine.Pt3(0, 0, 7): {},
engine.Pt3(1, 0, 7): {},
engine.Pt3(2, 0, 7): {},
engine.Pt3(3, 0, 7): {},
engine.Pt3(4, 0, 7): {},
engine.Pt3(5, 0, 7): {},
engine.Pt3(6, 0, 7): {},
engine.Pt3(7, 0, 7): {},
engine.Pt3(8, 0, 7): {},
engine.Pt3(9, 0, 7): {},
engine.Pt3(10, 0, 7): {},
engine.Pt3(11, 0, 7): {},
engine.Pt3(12, 0, 7): {},
geom.Pt3(0, 0, 7): {},
geom.Pt3(1, 0, 7): {},
geom.Pt3(2, 0, 7): {},
geom.Pt3(3, 0, 7): {},
geom.Pt3(4, 0, 7): {},
geom.Pt3(5, 0, 7): {},
geom.Pt3(6, 0, 7): {},
geom.Pt3(7, 0, 7): {},
geom.Pt3(8, 0, 7): {},
geom.Pt3(9, 0, 7): {},
geom.Pt3(10, 0, 7): {},
geom.Pt3(11, 0, 7): {},
geom.Pt3(12, 0, 7): {},
engine.Pt3(0, 0, 8): {},
engine.Pt3(1, 0, 8): {},
engine.Pt3(2, 0, 8): {},
engine.Pt3(3, 0, 8): {},
engine.Pt3(4, 0, 8): {},
engine.Pt3(5, 0, 8): {},
engine.Pt3(6, 0, 8): {},
engine.Pt3(7, 0, 8): {},
engine.Pt3(8, 0, 8): {},
engine.Pt3(9, 0, 8): {},
engine.Pt3(10, 0, 8): {},
geom.Pt3(0, 0, 8): {},
geom.Pt3(1, 0, 8): {},
geom.Pt3(2, 0, 8): {},
geom.Pt3(3, 0, 8): {},
geom.Pt3(4, 0, 8): {},
geom.Pt3(5, 0, 8): {},
geom.Pt3(6, 0, 8): {},
geom.Pt3(7, 0, 8): {},
geom.Pt3(8, 0, 8): {},
geom.Pt3(9, 0, 8): {},
geom.Pt3(10, 0, 8): {},
engine.Pt3(0, 0, 9): {},
engine.Pt3(1, 0, 9): {},
engine.Pt3(2, 0, 9): {},
engine.Pt3(3, 0, 9): {},
engine.Pt3(4, 0, 9): {},
engine.Pt3(5, 0, 9): {},
engine.Pt3(6, 0, 9): {},
engine.Pt3(7, 0, 9): {},
engine.Pt3(8, 0, 9): {},
geom.Pt3(0, 0, 9): {},
geom.Pt3(1, 0, 9): {},
geom.Pt3(2, 0, 9): {},
geom.Pt3(3, 0, 9): {},
geom.Pt3(4, 0, 9): {},
geom.Pt3(5, 0, 9): {},
geom.Pt3(6, 0, 9): {},
geom.Pt3(7, 0, 9): {},
geom.Pt3(8, 0, 9): {},
engine.Pt3(0, 0, 10): {},
engine.Pt3(1, 0, 10): {},
engine.Pt3(2, 0, 10): {},
engine.Pt3(3, 0, 10): {},
engine.Pt3(4, 0, 10): {},
engine.Pt3(5, 0, 10): {},
engine.Pt3(6, 0, 10): {},
geom.Pt3(0, 0, 10): {},
geom.Pt3(1, 0, 10): {},
geom.Pt3(2, 0, 10): {},
geom.Pt3(3, 0, 10): {},
geom.Pt3(4, 0, 10): {},
geom.Pt3(5, 0, 10): {},
geom.Pt3(6, 0, 10): {},
engine.Pt3(0, 0, 11): {},
engine.Pt3(1, 0, 11): {},
engine.Pt3(2, 0, 11): {},
engine.Pt3(3, 0, 11): {},
engine.Pt3(4, 0, 11): {},
geom.Pt3(0, 0, 11): {},
geom.Pt3(1, 0, 11): {},
geom.Pt3(2, 0, 11): {},
geom.Pt3(3, 0, 11): {},
geom.Pt3(4, 0, 11): {},
engine.Pt3(0, 0, 12): {},
engine.Pt3(1, 0, 12): {},
engine.Pt3(2, 0, 12): {},
geom.Pt3(0, 0, 12): {},
geom.Pt3(1, 0, 12): {},
geom.Pt3(2, 0, 12): {},
engine.Pt3(0, 0, 13): {},
geom.Pt3(0, 0, 13): {},
},
},
&game.Awakeman{
@ -344,8 +345,8 @@ func level1() *engine.Scene {
Sprite: engine.Sprite{
Actor: engine.Actor{
CollisionDomain: "level_1",
Pos: engine.Pt3(100, -32, 100),
Size: engine.Pt3(8, 16, 2),
Pos: geom.Pt3(100, -32, 100),
Size: geom.Pt3(8, 16, 2),
},
DrawOffset: image.Pt(-1, 0),
Sheet: engine.Sheet{