fixed observers, added GameObserver

This commit is contained in:
2024-02-11 14:24:30 +01:00
parent 72f0aa7691
commit 65ddec3fa4
18 changed files with 122 additions and 53 deletions

View File

@@ -10,14 +10,18 @@ type Renderable struct {
Image *ebiten.Image
}
type Particle struct {
Index int
Particles []*ebiten.Image
}
type Speed struct {
Value int
}
// only tile entities will have those
type Tilish struct{}
type Solid struct{}
type Floor struct{}
type Player struct{}
type Collectible struct{}
type Particle struct {
Index int
Particles []*ebiten.Image
}

View File

@@ -70,8 +70,8 @@ func (position *Position) String() string {
)
}
func (position *Position) Move(velocity *Velocity) {
position.Update(position.X+velocity.Data.X, position.Y+velocity.Data.Y)
func (position *Position) Move(velocity *Velocity, speed *Speed) {
position.Update(position.X+(velocity.Data.X*speed.Value), position.Y+(velocity.Data.Y*speed.Value))
}
func (position *Position) Set(newpos *Position) {

View File

@@ -11,21 +11,19 @@ type Velocity struct {
}
func (velocity *Velocity) Change(direction int) {
ticks := 4
switch direction {
case East:
velocity.Data.X = ticks
velocity.Data.X = 1
velocity.Data.Y = 0
case West:
velocity.Data.X = ticks - (ticks * 2)
velocity.Data.X = -1
velocity.Data.Y = 0
case South:
velocity.Data.X = 0
velocity.Data.Y = ticks
velocity.Data.Y = 1
case North:
velocity.Data.X = 0
velocity.Data.Y = ticks - (ticks * 2)
velocity.Data.Y = -1
case Stop:
velocity.Data.X = 0
velocity.Data.Y = 0