examples/raycasting: Fixed duplicated points, plotting ray count (#1225)

This commit is contained in:
João Wiciuk 2020-06-30 11:47:42 -05:00 committed by GitHub
parent 6fd2a82614
commit c57e569aea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,7 +84,10 @@ func (o object) points() [][2]float64 {
for _, wall := range o.walls { for _, wall := range o.walls {
points = append(points, [2]float64{wall.X2, wall.Y2}) points = append(points, [2]float64{wall.X2, wall.Y2})
} }
p := [2]float64{o.walls[0].X1, o.walls[0].Y1}
if p[0] != points[len(points)-1][0] && p[1] != points[len(points)-1][1] {
points = append(points, [2]float64{o.walls[0].X1, o.walls[0].Y1}) points = append(points, [2]float64{o.walls[0].X1, o.walls[0].Y1})
}
return points return points
} }
@ -282,6 +285,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
} }
ebitenutil.DebugPrintAt(screen, "WASD: move", 160, 0) ebitenutil.DebugPrintAt(screen, "WASD: move", 160, 0)
ebitenutil.DebugPrintAt(screen, fmt.Sprintf("Rays: 2*%d", len(rays)/2), padding, 16)
ebitenutil.DebugPrintAt(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()), 51, 51) ebitenutil.DebugPrintAt(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()), 51, 51)
} }