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 / main.go
Created August 9, 2019 09:12
main.go
package main
import (
"log"
"net/http"
)
var limiter = NewIPRateLimiter(1, 5)
func main() {
@plutov
plutov / rate.go
Created August 9, 2019 09:08
rate.go
package main
import (
"sync"
"golang.org/x/time/rate"
)
// IPRateLimiter .
type IPRateLimiter struct {