examples/platformer: add more descrpitive comments (#2866)

This commit is contained in:
LidlDev 2023-12-17 19:25:57 +03:00 committed by GitHub
parent b8df1217c3
commit c80a82c501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,6 +113,7 @@ func (c *char) draw(screen *ebiten.Image) {
} }
op := &ebiten.DrawImageOptions{} op := &ebiten.DrawImageOptions{}
// Use a smaller scale than 1 to shrink the image.
op.GeoM.Scale(0.5, 0.5) op.GeoM.Scale(0.5, 0.5)
op.GeoM.Translate(float64(c.x)/unit, float64(c.y)/unit) op.GeoM.Translate(float64(c.x)/unit, float64(c.y)/unit)
screen.DrawImage(s, op) screen.DrawImage(s, op)
@ -141,15 +142,15 @@ func (g *Game) Update() error {
} }
func (g *Game) Draw(screen *ebiten.Image) { func (g *Game) Draw(screen *ebiten.Image) {
// Draws Background Image // Draws Background Image.
op := &ebiten.DrawImageOptions{} op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(0.5, 0.5) op.GeoM.Scale(0.5, 0.5)
screen.DrawImage(backgroundImage, op) screen.DrawImage(backgroundImage, op)
// Draws the Gopher // Draws the Gopher.
g.gopher.draw(screen) g.gopher.draw(screen)
// Show the message // Show the message.
msg := fmt.Sprintf("TPS: %0.2f\nPress the space key to jump.", ebiten.ActualTPS()) msg := fmt.Sprintf("TPS: %0.2f\nPress the space key to jump.", ebiten.ActualTPS())
ebitenutil.DebugPrint(screen, msg) ebitenutil.DebugPrint(screen, msg)
} }