doc: Update examples (#354)

This commit is contained in:
Hajime Hoshi 2017-05-16 10:38:34 +09:00
parent a657cac229
commit 4770abd2fe
15 changed files with 45 additions and 6 deletions

View File

@ -78,7 +78,9 @@ func update(screen *ebiten.Image) error {
case 240 < count:
diff = float64(480-count) * 0.2
}
if ebiten.IsRunningSlowly() {
return nil
}
screen.Fill(color.NRGBA{0x00, 0x00, 0x80, 0xff})
op := &ebiten.DrawImageOptions{}
op.ColorM.Scale(1.0, 1.0, 1.0, 0.5)

View File

@ -211,7 +211,9 @@ func update(screen *ebiten.Image) error {
}
musicPlayer.updateVolume()
}
if ebiten.IsRunningSlowly() {
return nil
}
op := &ebiten.DrawImageOptions{}
x, y, w, h := playerBarRect()
op.GeoM.Translate(float64(x), float64(y))

View File

@ -102,6 +102,9 @@ func parseFont() error {
}
func update(screen *ebiten.Image) error {
if ebiten.IsRunningSlowly() {
return nil
}
screen.DrawImage(textImage, &ebiten.DrawImageOptions{})
return nil
}

View File

@ -62,6 +62,9 @@ func update(screen *ebiten.Image) error {
pressedButtons = append(pressedButtons, strconv.Itoa(int(b)))
}
}
if ebiten.IsRunningSlowly() {
return nil
}
str := `Gamepad
Axes:

View File

@ -83,6 +83,9 @@ func update(screen *ebiten.Image) error {
if ebiten.IsKeyPressed(ebiten.KeyX) {
valueInt++
}
if ebiten.IsRunningSlowly() {
return nil
}
hueInt = clamp(hueInt, -256, 256)
saturationInt = clamp(saturationInt, 0, 256)
valueInt = clamp(valueInt, 0, 256)

View File

@ -50,6 +50,9 @@ var (
func update(screen *ebiten.Image) error {
count++
if ebiten.IsRunningSlowly() {
return nil
}
w, h := gophersImage.Size()
op := &ebiten.DrawImageOptions{}
op.GeoM.Translate(float64(screenWidth-w)/2, float64(screenHeight-h)/2)

View File

@ -101,7 +101,9 @@ func drawGroundImage(screen *ebiten.Image, ground *ebiten.Image) {
func update(screen *ebiten.Image) error {
theViewport.Move()
if ebiten.IsRunningSlowly() {
return nil
}
updateGroundImage(groundImage)
drawGroundImage(screen, groundImage)

View File

@ -184,6 +184,9 @@ var (
func update(screen *ebiten.Image) error {
world.Progress()
if ebiten.IsRunningSlowly() {
return nil
}
world.DrawImage(noiseImage)
screen.ReplacePixels(noiseImage.Pix)
return nil

View File

@ -77,7 +77,9 @@ func update(screen *ebiten.Image) error {
spotLightY = -spotLightY + 2*maxY
spotLightVY = -spotLightVY
}
if ebiten.IsRunningSlowly() {
return nil
}
maskImage.Clear()
op := &ebiten.DrawImageOptions{}

View File

@ -50,6 +50,9 @@ var (
)
func update(screen *ebiten.Image) error {
if ebiten.IsRunningSlowly() {
return nil
}
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(1.0/mosaicRatio, 1.0/mosaicRatio)
gophersRenderTarget.DrawImage(gophersImage, op)

View File

@ -71,6 +71,9 @@ func update(screen *ebiten.Image) error {
noiseImage.Pix[4*i+2] = uint8(x >> 8)
noiseImage.Pix[4*i+3] = 0xff
}
if ebiten.IsRunningSlowly() {
return nil
}
screen.ReplacePixels(noiseImage.Pix)
ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %f", ebiten.CurrentFPS()))
return nil

View File

@ -75,7 +75,9 @@ func update(screen *ebiten.Image) error {
if drawn {
count++
}
if ebiten.IsRunningSlowly() {
return nil
}
screen.DrawImage(canvasImage, nil)
msg := fmt.Sprintf("(%d, %d)", mx, my)

View File

@ -68,6 +68,9 @@ func (p parts) Src(i int) (x0, y0, x1, y1 int) {
}
func update(screen *ebiten.Image) error {
if ebiten.IsRunningSlowly() {
return nil
}
op := &ebiten.DrawImageOptions{
ImageParts: &parts{gophersImage},
}

View File

@ -220,7 +220,9 @@ func update(screen *ebiten.Image) error {
return err
}
}
if ebiten.IsRunningSlowly() {
return nil
}
screen.Fill(color.RGBA{0x80, 0x80, 0xc0, 0xff})
screen.DrawImage(imagePiano, nil)

View File

@ -50,6 +50,9 @@ var (
func update(screen *ebiten.Image) error {
count++
if ebiten.IsRunningSlowly() {
return nil
}
w, h := gophersImage.Size()
op := &ebiten.DrawImageOptions{}
op.GeoM.Translate(-float64(w)/2, -float64(h)/2)