First commit.
This commit is contained in:
31
projectile.go
Normal file
31
projectile.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import "math"
|
||||
|
||||
type Projectile struct {
|
||||
Pos Coordinates
|
||||
Velocity float64
|
||||
a float64
|
||||
}
|
||||
|
||||
func NewProjectile(origin Coordinates, angle, velocity float64) *Projectile {
|
||||
return &Projectile{
|
||||
Velocity: velocity,
|
||||
a: angle,
|
||||
Pos: origin,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Projectile) Update() {
|
||||
|
||||
dx := p.Velocity * math.Cos(p.a)
|
||||
dy := p.Velocity * math.Sin(p.a)
|
||||
|
||||
p.Pos.X += dx
|
||||
p.Pos.Y += dy
|
||||
|
||||
}
|
||||
|
||||
func (p *Projectile) Draw() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user