fix vibration, tweak spritesheet

This commit is contained in:
Josh Deprez 2021-08-05 14:26:23 +10:00 committed by Josh Deprez
parent 5cdbf5b82b
commit 8bddc09a11
4 changed files with 4 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 633 B

View file

@ -3,7 +3,6 @@ package engine
import ( import (
"encoding/gob" "encoding/gob"
"image" "image"
"math"
) )
func init() { func init() {
@ -40,7 +39,7 @@ func (a *Actor) CollidesAt(p image.Point) bool {
func (a *Actor) MoveX(dx float64, onCollide func()) { func (a *Actor) MoveX(dx float64, onCollide func()) {
a.xRem += dx a.xRem += dx
move := int(math.Round(a.xRem)) move := int(a.xRem + 0.5) // Note: math.Round can lead to vibration
if move == 0 { if move == 0 {
return return
} }
@ -60,7 +59,7 @@ func (a *Actor) MoveX(dx float64, onCollide func()) {
func (a *Actor) MoveY(dy float64, onCollide func()) { func (a *Actor) MoveY(dy float64, onCollide func()) {
a.yRem += dy a.yRem += dy
move := int(math.Round(a.yRem)) move := int(a.yRem + 0.5)
if move == 0 { if move == 0 {
return return
} }

View file

@ -26,8 +26,8 @@ func (aw *Awakeman) Update() error {
const ( const (
bounceDampen = 0.5 bounceDampen = 0.5
gravity = 0.3 gravity = 0.3
jumpVelocity = -5 jumpVelocity = -3
runVelocity = 2 runVelocity = 1.5
) )
// Standing on something? // Standing on something?