Fixed monster z-fighting.
This commit is contained in:
parent
17008871ce
commit
24db632470
4
TODO.md
4
TODO.md
@ -8,8 +8,8 @@
|
||||
- [ ] Change layout when playing in portrait mode.
|
||||
- [X] Fix wobble animation.
|
||||
- [ ] Add more unit tests?
|
||||
- [ ] Fix z-fighting of monsters.
|
||||
- [ ] Add exploding animation of monsters.
|
||||
- [X] Fix z-fighting of monsters.
|
||||
- [X] Add exploding animation of monsters.
|
||||
- [ ] Add audio settings (music & sound volume).
|
||||
- [X] Hearts must be saved as well for resume.
|
||||
- [ ] Add demo mode.
|
||||
|
@ -338,22 +338,29 @@ func (r levelController) Render(ctx ui.Context) {
|
||||
renderer.DrawTexturePoint(player, playerPosition.Add(centerTopSquare))
|
||||
}
|
||||
|
||||
for pos, monsterType := range r.Level.Monsters {
|
||||
tile := r.Level.Tiles[pos]
|
||||
if tile == nil {
|
||||
continue
|
||||
}
|
||||
texture := monsterTextures[monsterType.Type()]
|
||||
_, platformPos := positionOfTile(pos)
|
||||
if target, ok := r.Level.MonsterTargets[pos]; ok {
|
||||
_, targetPlatformPos := positionOfTile(target)
|
||||
dt := float32(r.MovingMonsters.Frame(pos)) / 50.
|
||||
delta := targetPlatformPos.Sub(platformPos)
|
||||
curve := geom.PtF32(0, .6*geom.Sin32(dt*geom.Pi)*textureWidth)
|
||||
interpolatedPos := platformPos.Add(delta.Mul(dt)).Sub(curve)
|
||||
texture.Draw(renderer, interpolatedPos.Add(propOffset), r.Animations["monster"].Frame(pos))
|
||||
} else {
|
||||
texture.Draw(renderer, platformPos.Add(propOffset), r.Animations["monster"].Frame(pos))
|
||||
for y := r.Level.Bounds.Min.Y; y < r.Level.Bounds.Max.Y; y++ {
|
||||
for x := r.Level.Bounds.Min.X; x < r.Level.Bounds.Max.X; x++ {
|
||||
pos := geom.Pt(x, y)
|
||||
monsterType, ok := r.Level.Monsters[pos]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
tile := r.Level.Tiles[pos]
|
||||
if tile == nil {
|
||||
continue
|
||||
}
|
||||
texture := monsterTextures[monsterType.Type()]
|
||||
_, platformPos := positionOfTile(pos)
|
||||
if target, ok := r.Level.MonsterTargets[pos]; ok {
|
||||
_, targetPlatformPos := positionOfTile(target)
|
||||
dt := float32(r.MovingMonsters.Frame(pos)) / 50.
|
||||
delta := targetPlatformPos.Sub(platformPos)
|
||||
curve := geom.PtF32(0, .6*geom.Sin32(dt*geom.Pi)*textureWidth)
|
||||
interpolatedPos := platformPos.Add(delta.Mul(dt)).Sub(curve)
|
||||
texture.Draw(renderer, interpolatedPos.Add(propOffset), r.Animations["monster"].Frame(pos))
|
||||
} else {
|
||||
texture.Draw(renderer, platformPos.Add(propOffset), r.Animations["monster"].Frame(pos))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user