mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
parent
9fe4191a6a
commit
f01f5045ba
@ -83,7 +83,11 @@ type mascot struct {
|
|||||||
count int
|
count int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mascot) update(screen *ebiten.Image) error {
|
func (m *mascot) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||||
|
return width, height
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mascot) Update(screen *ebiten.Image) error {
|
||||||
m.count++
|
m.count++
|
||||||
|
|
||||||
sw, sh := ebiten.ScreenSizeInFullscreen()
|
sw, sh := ebiten.ScreenSizeInFullscreen()
|
||||||
@ -121,11 +125,10 @@ func (m *mascot) update(screen *ebiten.Image) error {
|
|||||||
m.vx16 = -m.vx16
|
m.vx16 = -m.vx16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ebiten.IsDrawingSkipped() {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mascot) Draw(screen *ebiten.Image) {
|
||||||
img := gopher1
|
img := gopher1
|
||||||
if m.y16 == 0 {
|
if m.y16 == 0 {
|
||||||
switch (m.count / 3) % 4 {
|
switch (m.count / 3) % 4 {
|
||||||
@ -143,7 +146,6 @@ func (m *mascot) update(screen *ebiten.Image) error {
|
|||||||
op.GeoM.Translate(width, 0)
|
op.GeoM.Translate(width, 0)
|
||||||
}
|
}
|
||||||
screen.DrawImage(img, op)
|
screen.DrawImage(img, op)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -151,8 +153,8 @@ func main() {
|
|||||||
ebiten.SetWindowDecorated(false)
|
ebiten.SetWindowDecorated(false)
|
||||||
ebiten.SetRunnableOnUnfocused(true)
|
ebiten.SetRunnableOnUnfocused(true)
|
||||||
ebiten.SetWindowFloating(true)
|
ebiten.SetWindowFloating(true)
|
||||||
m := &mascot{}
|
ebiten.SetWindowSize(width, height)
|
||||||
if err := ebiten.Run(m.update, width, height, 1, "Mascot (Ebiten Demo)"); err != nil {
|
if err := ebiten.RunGame(&mascot{}); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user