twitchapon-anim

Basic Twitchapon Receiver/Visuals
git clone git://bsandro.tech/twitchapon-anim
Log | Files | Refs | README | LICENSE

commit 2d914ffbe94bd2d82f5f95c710887e59cb33dde1
parent 31993e51017b4c26d7149eb1be431beec50aab28
Author: bsandro <brian.drosan@gmail.com>
Date:   Tue, 17 Nov 2020 03:08:47 +0300

go fmt

Diffstat:
Mebitest.go | 23+++++++++++++----------
Minit.go | 4++--
2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/ebitest.go b/ebitest.go @@ -25,10 +25,11 @@ var ScreenSize struct { var BakaHa *ebiten.Image type Sprite struct { - img *ebiten.Image - opt ebiten.DrawImageOptions - x, y float64 - angle float64 + img *ebiten.Image + opt ebiten.DrawImageOptions + x, y float64 + angle float64 + rotation float64 } type Game struct { @@ -42,10 +43,6 @@ func (g *Game) Update() error { g.init() } - //if ebiten.IsDrawingSkipped() { - // return nil - //} - if ebiten.IsKeyPressed(ebiten.KeyQ) || ebiten.IsKeyPressed(ebiten.KeyEscape) { // @todo find out if it is possible to gracefully stop the game via ebiten structure return errors.New("exit") @@ -106,6 +103,9 @@ func (sprite *Sprite) Update() error { sprite.y = y } + // rotating image + sprite.rotation += math.Pi / 60.0 + return nil } @@ -113,8 +113,11 @@ func (g *Game) Draw(screen *ebiten.Image) { defer g.ShowDebug(screen) for _, sprite := range g.sprites { + //w, h := sprite.img.Size() sprite.opt.GeoM.Reset() - sprite.opt.GeoM.Translate(float64(sprite.x), float64(sprite.y)) + //sprite.opt.GeoM.Translate(-float64(w)/2.0, -float64(h)/2.0) + //sprite.opt.GeoM.Rotate(sprite.rotation) + sprite.opt.GeoM.Translate(sprite.x, sprite.y) screen.DrawImage(sprite.img, &sprite.opt) } } @@ -138,7 +141,7 @@ func (g *Game) init() { y := float64(ScreenSize.height) / 2.0 angle := rand.Float64() * math.Pi * 2.0 fmt.Printf("initial x, y, angle: %0.2f %0.2f %0.2f\n", x, y, angle) - g.sprites = append(g.sprites, &Sprite{BakaHa, ebiten.DrawImageOptions{}, x, y, angle}) + g.sprites = append(g.sprites, &Sprite{BakaHa, ebiten.DrawImageOptions{}, x, y, angle, 0.0 /* rotation */}) } } diff --git a/init.go b/init.go @@ -4,9 +4,9 @@ import ( "bytes" "fmt" "github.com/hajimehoshi/ebiten/v2" - "log" - "image" _ "golang.org/x/image/webp" + "image" + "log" ) //go:generate go run generate/embed.go