walking around on hexagons
This commit is contained in:
parent
6c5f482e56
commit
d73715f3e2
4 changed files with 227 additions and 18 deletions
|
@ -52,6 +52,20 @@ func (b Box) Sub(p Int3) Box {
|
|||
}
|
||||
}
|
||||
|
||||
// Canon returns a copy of b that is well-formed.
|
||||
func (b Box) Canon() Box {
|
||||
if b.Max.X < b.Min.X {
|
||||
b.Min.X, b.Max.X = b.Max.X, b.Min.X
|
||||
}
|
||||
if b.Max.Y < b.Min.Y {
|
||||
b.Min.Y, b.Max.Y = b.Max.Y, b.Min.Y
|
||||
}
|
||||
if b.Max.Z < b.Min.Z {
|
||||
b.Min.Z, b.Max.Z = b.Max.Z, b.Min.Z
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Back returns an image.Rectangle representing the back of the box, using
|
||||
// the given projection π.
|
||||
func (b Box) Back(π IntProjection) image.Rectangle {
|
||||
|
|
|
@ -60,9 +60,13 @@ func (m *PrismMap) CollidesWith(b Box) bool {
|
|||
// (Spoilers: I did this already in Prepare)
|
||||
b.Min = m.pwinverse.IntApply(b.Min)
|
||||
b.Max = m.pwinverse.IntApply(b.Max.Sub(Int3{1, 1, 1}))
|
||||
for k := b.Min.Z; k < b.Max.Z; k++ {
|
||||
for j := b.Min.Y; j < b.Max.Y; j++ {
|
||||
for i := b.Min.X; i < b.Max.X; i++ {
|
||||
b = b.Canon() // inverse might flip the corners around...
|
||||
|
||||
log.Printf("b.Max = %v", b.Max)
|
||||
|
||||
for k := b.Min.Z; k <= b.Max.Z; k++ {
|
||||
for j := b.Min.Y; j <= b.Max.Y; j++ {
|
||||
for i := b.Min.X; i <= b.Max.X; i++ {
|
||||
// TODO: take into account the prism shape...
|
||||
if _, found := m.Map[Int3{i, j, k}]; found {
|
||||
return true
|
||||
|
@ -80,7 +84,7 @@ func (m *PrismMap) Prepare(g *Game) error {
|
|||
return fmt.Errorf("inverting PosToWorld: %w", err)
|
||||
}
|
||||
m.pwinverse = pwi
|
||||
log.Printf("inverted PosToWorld: %v", pwi)
|
||||
// log.Printf("inverted PosToWorld: %v", pwi)
|
||||
for v, p := range m.Map {
|
||||
p.pos = v
|
||||
p.m = m
|
||||
|
|
|
@ -48,6 +48,7 @@ func (aw *Awakeman) Update() error {
|
|||
// TODO: better cheat for noclip
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyN) {
|
||||
aw.noclip = !aw.noclip
|
||||
aw.vx, aw.vy, aw.vz = 0, 0, 0
|
||||
if aw.toast != nil {
|
||||
if aw.noclip {
|
||||
aw.toast.Toast("noclip enabled")
|
||||
|
|
214
main.go
214
main.go
|
@ -150,20 +150,210 @@ func level1() *engine.Scene {
|
|||
Src: engine.ImageRef{Path: "assets/hexprism32.png"},
|
||||
},
|
||||
Map: map[engine.Int3]*engine.Prism{
|
||||
engine.Pt3(11, 0, -6): {},
|
||||
engine.Pt3(12, 0, -6): {},
|
||||
|
||||
engine.Pt3(9, 0, -5): {},
|
||||
engine.Pt3(10, 0, -5): {},
|
||||
engine.Pt3(11, 0, -5): {},
|
||||
engine.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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
engine.Pt3(0, 0, 0): {},
|
||||
engine.Pt3(1, 0, 0): {},
|
||||
engine.Pt3(2, 0, 0): {},
|
||||
|
||||
engine.Pt3(4, -2, 0): {},
|
||||
engine.Pt3(4, -1, 0): {},
|
||||
engine.Pt3(3, 0, 0): {},
|
||||
engine.Pt3(4, 0, 0): {},
|
||||
|
||||
engine.Pt3(6, 0, -2): {},
|
||||
engine.Pt3(6, 0, -1): {},
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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(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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
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): {},
|
||||
|
||||
engine.Pt3(0, 0, 12): {},
|
||||
engine.Pt3(1, 0, 12): {},
|
||||
engine.Pt3(2, 0, 12): {},
|
||||
|
||||
engine.Pt3(0, 0, 13): {},
|
||||
},
|
||||
},
|
||||
&engine.Tilemap{
|
||||
/*&engine.Tilemap{
|
||||
ID: "terrain",
|
||||
ZOrder: -1,
|
||||
Map: tiles,
|
||||
|
@ -187,8 +377,8 @@ func level1() *engine.Scene {
|
|||
CellSize: image.Pt(16, 16),
|
||||
Src: engine.ImageRef{Path: "assets/boxes.png"},
|
||||
},
|
||||
},
|
||||
&engine.SolidRect{
|
||||
},*/
|
||||
/*&engine.SolidRect{
|
||||
ID: "ceiling",
|
||||
Box: engine.Box{Min: engine.Pt3(0, -1, 0), Max: engine.Pt3(320, 0, 100)},
|
||||
},
|
||||
|
@ -199,15 +389,15 @@ func level1() *engine.Scene {
|
|||
&engine.SolidRect{
|
||||
ID: "right_wall",
|
||||
Box: engine.Box{Min: engine.Pt3(320, 0, 0), Max: engine.Pt3(321, 240, 100)},
|
||||
},
|
||||
},*/
|
||||
&game.Awakeman{
|
||||
CameraID: "game_camera",
|
||||
ToastID: "toast",
|
||||
Sprite: engine.Sprite{
|
||||
Actor: engine.Actor{
|
||||
CollisionDomain: "level_1",
|
||||
Pos: engine.Pt3(100, 100, 0),
|
||||
Size: engine.Pt3(8, 16, 8),
|
||||
Pos: engine.Pt3(100, 0, 100),
|
||||
Size: engine.Pt3(8, 16, 1),
|
||||
},
|
||||
DrawOffset: image.Pt(-1, 0),
|
||||
Sheet: engine.Sheet{
|
||||
|
|
Loading…
Reference in a new issue