tweaks
This commit is contained in:
parent
2e2bf97cd9
commit
a4a5be2d37
2 changed files with 21 additions and 13 deletions
|
@ -33,8 +33,8 @@ func (a *Actor) CollidesAt(p Point3) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Actor) MoveX(dx float64, onCollide func()) {
|
func (a *Actor) MoveX(x float64, onCollide func()) {
|
||||||
a.xRem += dx
|
a.xRem += x
|
||||||
move := int(a.xRem + 0.5) // Note: math.Round can lead to vibration
|
move := int(a.xRem + 0.5) // Note: math.Round can lead to vibration
|
||||||
if move == 0 {
|
if move == 0 {
|
||||||
return
|
return
|
||||||
|
@ -53,8 +53,8 @@ func (a *Actor) MoveX(dx float64, onCollide func()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Actor) MoveY(dy float64, onCollide func()) {
|
func (a *Actor) MoveY(y float64, onCollide func()) {
|
||||||
a.yRem += dy
|
a.yRem += y
|
||||||
move := int(a.yRem + 0.5)
|
move := int(a.yRem + 0.5)
|
||||||
if move == 0 {
|
if move == 0 {
|
||||||
return
|
return
|
||||||
|
@ -73,8 +73,8 @@ func (a *Actor) MoveY(dy float64, onCollide func()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Actor) MoveZ(dz float64, onCollide func()) {
|
func (a *Actor) MoveZ(z float64, onCollide func()) {
|
||||||
a.zRem += dz
|
a.zRem += z
|
||||||
move := int(a.zRem + 0.5)
|
move := int(a.zRem + 0.5)
|
||||||
if move == 0 {
|
if move == 0 {
|
||||||
return
|
return
|
||||||
|
@ -97,10 +97,3 @@ func (a *Actor) Prepare(g *Game) error {
|
||||||
a.game = g
|
a.game = g
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func sign(m int) int {
|
|
||||||
if m < 0 {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
|
@ -65,6 +65,21 @@ func (p Point3) Coord() (x, y, z int) {
|
||||||
return p.X, p.Y, p.Z
|
return p.X, p.Y, p.Z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sign returns a sign vector.
|
||||||
|
func (p Point3) Sign() Point3 {
|
||||||
|
return Point3{sign(p.X), sign(p.Y), sign(p.Z)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sign(m int) int {
|
||||||
|
if m == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if m < 0 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
// IsoProject performs isometric projection of a 3D coordinate into 2D.
|
// IsoProject performs isometric projection of a 3D coordinate into 2D.
|
||||||
//
|
//
|
||||||
// If π.X = 0, the x returned is p.X; similarly for π.Y and y.
|
// If π.X = 0, the x returned is p.X; similarly for π.Y and y.
|
||||||
|
|
Loading…
Reference in a new issue