mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
examples: Call IsRunningSlowly (#354)
This commit is contained in:
parent
9f53404655
commit
a657cac229
@ -35,13 +35,13 @@ var (
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
w, _ := ebitenImage.Size()
|
||||
const ox = 10
|
||||
const oy = 10
|
||||
|
||||
if err := screen.Fill(color.NRGBA{0x00, 0x40, 0x80, 0xff}); err != nil {
|
||||
return err
|
||||
}
|
||||
screen.Fill(color.NRGBA{0x00, 0x40, 0x80, 0xff})
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(ox, oy)
|
||||
screen.DrawImage(ebitenImage, op)
|
||||
|
@ -194,11 +194,12 @@ func update(screen *ebiten.Image) error {
|
||||
if !rotated {
|
||||
thePlayer.Stabilize()
|
||||
}
|
||||
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
screen.Fill(skyColor)
|
||||
updateGroundImage(groundImage)
|
||||
drawGroundImage(screen, groundImage)
|
||||
|
||||
tutrial := "Space: Move forward\nLeft/Right: Rotate"
|
||||
msg := fmt.Sprintf("FPS: %0.2f\n%s", ebiten.CurrentFPS(), tutrial)
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
@ -213,24 +214,16 @@ func main() {
|
||||
}
|
||||
w, h := gophersImage.Size()
|
||||
const repeat = 5
|
||||
repeatedGophersImage, err = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
repeatedGophersImage, _ = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterNearest)
|
||||
for j := 0; j < repeat; j++ {
|
||||
for i := 0; i < repeat; i++ {
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(float64(w*i), float64(h*j))
|
||||
if err := repeatedGophersImage.DrawImage(gophersImage, op); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
repeatedGophersImage.DrawImage(gophersImage, op)
|
||||
}
|
||||
}
|
||||
groundWidth := screenWidth + 70
|
||||
groundImage, err = ebiten.NewImage(groundWidth, screenHeight*2/3+50, ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
groundImage, _ = ebiten.NewImage(groundWidth, screenHeight*2/3+50, ebiten.FilterNearest)
|
||||
const fogHeight = 8
|
||||
fogRGBA := image.NewRGBA(image.Rect(0, 0, groundWidth, fogHeight))
|
||||
for j := 0; j < fogHeight; j++ {
|
||||
@ -245,10 +238,7 @@ func main() {
|
||||
fogRGBA.SetRGBA(i, j, clr)
|
||||
}
|
||||
}
|
||||
fogImage, err = ebiten.NewImageFromImage(fogRGBA, ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fogImage, _ = ebiten.NewImageFromImage(fogRGBA, ebiten.FilterNearest)
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Air Ship (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -65,7 +65,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)
|
||||
|
@ -198,7 +198,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))
|
||||
|
@ -89,6 +89,9 @@ func parseFont() error {
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
screen.DrawImage(textImage, &ebiten.DrawImageOptions{})
|
||||
return nil
|
||||
}
|
||||
|
@ -49,6 +49,9 @@ func update(screen *ebiten.Image) error {
|
||||
pressedButtons = append(pressedButtons, strconv.Itoa(int(b)))
|
||||
}
|
||||
}
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
|
||||
str := `Gamepad
|
||||
Axes:
|
||||
|
@ -70,6 +70,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)
|
||||
|
@ -37,6 +37,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)
|
||||
|
@ -88,7 +88,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)
|
||||
|
||||
|
@ -90,6 +90,9 @@ func (p pressedKeysParts) Src(i int) (x0, y0, x1, y1 int) {
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
const offsetX, offsetY = 24, 40
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(offsetX, offsetY)
|
||||
|
@ -180,6 +180,9 @@ var (
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
world.Progress()
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
world.DrawImage(noiseImage)
|
||||
screen.ReplacePixels(noiseImage.Pix)
|
||||
return nil
|
||||
|
@ -64,7 +64,9 @@ func update(screen *ebiten.Image) error {
|
||||
spotLightY = -spotLightY + 2*maxY
|
||||
spotLightVY = -spotLightVY
|
||||
}
|
||||
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
maskImage.Clear()
|
||||
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
|
@ -37,6 +37,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)
|
||||
|
@ -58,6 +58,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
|
||||
|
@ -62,7 +62,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)
|
||||
|
@ -55,6 +55,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},
|
||||
}
|
||||
|
@ -207,7 +207,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)
|
||||
|
||||
|
@ -37,6 +37,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)
|
||||
|
@ -99,6 +99,9 @@ func update(screen *ebiten.Image) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
msg := fmt.Sprintf("FPS: %0.2f\nThis is an example using infinite audio stream.", ebiten.CurrentFPS())
|
||||
ebitenutil.DebugPrint(screen, msg)
|
||||
if err := audioContext.Update(); err != nil {
|
||||
|
@ -86,6 +86,10 @@ func update(screen *ebiten.Image) error {
|
||||
ebiten.SetScreenSize(screenWidth, screenHeight)
|
||||
ebiten.SetScreenScale(screenScale)
|
||||
|
||||
if ebiten.IsRunningSlowly() {
|
||||
return nil
|
||||
}
|
||||
|
||||
screen.Fill(color.RGBA{0x80, 0x80, 0xc0, 0xff})
|
||||
w, h := gophersImage.Size()
|
||||
w2, h2 := screen.Size()
|
||||
|
Loading…
Reference in New Issue
Block a user