fixed higher speed collisions, removed Speed comp, put into Velocity

This commit is contained in:
2024-02-26 12:56:12 +01:00
parent 2e3acf4ec4
commit ffaa5e6129
13 changed files with 525 additions and 37 deletions

View File

@@ -16,10 +16,6 @@ type Particle struct {
Tiles []*ebiten.Image
}
type Speed struct {
Value int
}
// only tile entities will have those
type Tilish struct{}
type Solid struct{}

View File

@@ -34,7 +34,8 @@ func NewPosition(point image.Point, cellsize int) *Position {
func (position *Position) GetMoved(velosity *Velocity) *Position {
pos := &Position{}
pos.Update(position.X+velosity.Data.X, position.Y+velosity.Data.Y, position.Cellsize)
pos.Update(position.X+(velosity.Data.X*velosity.Speed),
position.Y+(velosity.Data.Y*velosity.Speed), position.Cellsize)
return pos
}
@@ -70,13 +71,13 @@ func (position *Position) String() string {
)
}
func (position *Position) Move(velocity *Velocity, speed *Speed) {
func (position *Position) Move(velocity *Velocity) {
// if velocity.Direction != 0 {
// slog.Debug("moving", "velocity", velocity, "speed", speed)
// }
position.Update(
position.X+(velocity.Data.X*speed.Value),
position.Y+(velocity.Data.Y*speed.Value),
position.X+(velocity.Data.X*velocity.Speed),
position.Y+(velocity.Data.Y*velocity.Speed),
)
}

View File

@@ -9,6 +9,7 @@ type Velocity struct {
Data Position
Direction int
PointingAt int
Speed int
}
func (velocity *Velocity) Set(new *Velocity) {