Fixed monster z-fighting.

This commit is contained in:
Sander Schobers 2021-08-14 09:46:38 +02:00
parent 17008871ce
commit 24db632470
2 changed files with 25 additions and 18 deletions

View File

@ -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.

View File

@ -338,7 +338,13 @@ func (r levelController) Render(ctx ui.Context) {
renderer.DrawTexturePoint(player, playerPosition.Add(centerTopSquare))
}
for pos, monsterType := range r.Level.Monsters {
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
@ -356,6 +362,7 @@ func (r levelController) Render(ctx ui.Context) {
texture.Draw(renderer, platformPos.Add(propOffset), r.Animations["monster"].Frame(pos))
}
}
}
var died []geom.Point
for pos, monster := range r.DyingMonsterTypes {