Skip to content

Instantly share code, notes, and snippets.

View plutov's full-sized avatar
🎥
https://www.youtube.com/packagemain

Alex Pliutau plutov

🎥
https://www.youtube.com/packagemain
View GitHub Profile
// ...
var (
backgroundColor = color.RGBA{50, 100, 50, 50}
snakeColor = color.RGBA{200, 50, 150, 150}
foodColor = color.RGBA{200, 200, 50, 150}
)
type Game struct {
input *Input
package snake
import (
"math/rand"
"time"
"github.com/hajimehoshi/ebiten/v2"
)
type Board struct {
package snake
import "github.com/hajimehoshi/ebiten/v2"
type Coord struct {
x, y int
}
type Snake struct {
body []Coord
package snake
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
)
type Input struct{}
func NewInput() *Input {
package snake
type Food struct {
x, y int
}
func NewFood(x, y int) *Food {
return &Food{
x: x,
y: y,
package main
import (
"log"
"github.com/hajimehoshi/ebiten/v2"
"github.com/plutov/packagemain/drafts/ebiten-snake/snake"
)
func main() {
@plutov
plutov / game.go
Last active February 22, 2024 10:01
package snake
import (
"fmt"
"image/color"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
package snake
import (
"fmt"
"image/color"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
@plutov
plutov / testable9.go
Created May 4, 2020 19:42
testable9.go
package testable_test
import (
"testing"
"github.com/plutov/packagemain/19-testable-go-code/testable"
)
// ...
@plutov
plutov / testable8.go
Created May 4, 2020 19:42
testable8.go
// ...
mock := new(Mock)
got, err := GetAverageStarsPerRepo(mock, tt.username)
// ...