eliasdaler

Pixel Go

Dec 18th, 2022
1,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.79 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "image/color"
  5.     "log"
  6.     "math"
  7.  
  8.     "github.com/hajimehoshi/ebiten/v2"
  9.     "github.com/hajimehoshi/ebiten/v2/ebitenutil"
  10. )
  11.  
  12. type Game struct{}
  13.  
  14. func (g *Game) Update() error {
  15.     return nil
  16. }
  17.  
  18. func (g *Game) Draw(screen *ebiten.Image) {
  19.     screen.Clear()
  20.  
  21.     ebitenutil.DrawRect(screen, 32, 32, 1, 1, color.White)
  22.     ebitenutil.DrawRect(screen, 72, 72, 1, 1, color.RGBA{0, 0, 255, 255})
  23.  
  24.     for i := 0; i < 128; i++ {
  25.         x := float64(i)
  26.         y := math.Sin(float64(x)) + 64
  27.         ebitenutil.DrawRect(screen, x, y, 1, 1, color.RGBA{255, 0, 0, 255})
  28.     }
  29. }
  30.  
  31. func (g *Game) Layout(_, _ int) (int, int) {
  32.     return 128, 128
  33. }
  34.  
  35. func main() {
  36.     ebiten.SetWindowSize(512, 512)
  37.     ebiten.SetWindowTitle("GO-8")
  38.     if err := ebiten.RunGame(&Game{}); err != nil {
  39.         log.Fatal(err)
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment