mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2026-04-22 15:57:15 +08:00
examples/doom: refactor fire pixel update loops and intensity logic (#3295)
Replaced for-loops in updateFirePixels with range-based loops for clarity. Simplified newI calculation in updateFireIntensityPerPixel using max().
This commit is contained in:
@@ -87,8 +87,8 @@ func NewGame() *Game {
|
||||
}
|
||||
|
||||
func (g *Game) updateFirePixels() {
|
||||
for i := 0; i < screenWidth; i++ {
|
||||
for j := 0; j < screenHeight; j++ {
|
||||
for i := range screenWidth {
|
||||
for j := range screenHeight {
|
||||
idx := i + (screenWidth * j)
|
||||
g.updateFireIntensityPerPixel(idx)
|
||||
}
|
||||
@@ -102,10 +102,7 @@ func (g *Game) updateFireIntensityPerPixel(currentPixelIndex int) {
|
||||
}
|
||||
|
||||
d := rand.IntN(3)
|
||||
newI := int(g.indices[below]) - d
|
||||
if newI < 0 {
|
||||
newI = 0
|
||||
}
|
||||
newI := max(int(g.indices[below])-d, 0)
|
||||
|
||||
if currentPixelIndex-d < 0 {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user