Skip to content

Commit

Permalink
cleaunp player gravity
Browse files Browse the repository at this point in the history
  • Loading branch information
Grafne23 committed May 16, 2018
1 parent 2d4d63f commit 1f7e899
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions server/models/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,8 @@ func (p *Player) HitPlayer(ph *Player, height float64, width float64) {
// ApplyGravity applys a vector towards given position
func (p *Player) ApplyGravity(h *Hole) {
gravityVector := Velocity{0, 0}

if p.Position.X < h.Position.X {
gravityVector.Dx = h.Position.X - p.Position.X
} else {
gravityVector.Dx = h.Position.X - p.Position.X
}

if p.Position.Y < h.Position.Y {
gravityVector.Dy = h.Position.Y - p.Position.Y
} else {
gravityVector.Dy = h.Position.Y - p.Position.Y
}
gravityVector.Dx = h.Position.X - p.Position.X
gravityVector.Dy = h.Position.Y - p.Position.Y

inverseMagnitude := 1.0 / gravityVector.magnitude()
gravityVector.normalize()
Expand Down

0 comments on commit 1f7e899

Please sign in to comment.