Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6d23349e43 | |||
feced4cd7f | |||
76b6150a1e | |||
b7af5b64ad |
18
.pre-commit-config.yaml
Normal file
18
.pre-commit-config.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/dnephin/pre-commit-golang
|
||||
rev: v0.5.1
|
||||
hooks:
|
||||
- id: go-fmt
|
||||
- id: go-imports
|
||||
- id: no-go-testing
|
||||
- id: golangci-lint
|
||||
- id: go-unit-tests
|
28
Taskfile.dist.yaml
Normal file
28
Taskfile.dist.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
version: '3'
|
||||
|
||||
vars:
|
||||
APP: snake
|
||||
BUILD_DIR: builds
|
||||
|
||||
tasks:
|
||||
default:
|
||||
cmds:
|
||||
- go run .
|
||||
build:
|
||||
cmds:
|
||||
- mkdir -p {{.BUILD_DIR}}
|
||||
- rm {{.BUILD_DIR}}/* || true
|
||||
- go tool dist list | grep -v android | grep -v ios | grep -v wasip1 | awk -F '/' '{printf "echo Compiling %s/%s; env CGO_ENABLED=1 GOOS=%s GOARCH=%s go build -o {{.BUILD_DIR}}/{{.APP}}.%s-%s\n",$1,$2,$1,$2,$1,$2 }' | sh
|
||||
- for i in `ls {{.BUILD_DIR}}/*windows*`; do mv -v $i $i.exe; done
|
||||
lint:
|
||||
cmds:
|
||||
- golangci-lint run
|
||||
precommit:
|
||||
cmds:
|
||||
- pre-commit autoupdate
|
||||
- pre-commit run --all
|
||||
silent: true
|
||||
gource:
|
||||
cmds:
|
||||
- gource --auto-skip-seconds 1 --key -r 60
|
||||
silent: true
|
5
build.sh
5
build.sh
@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir -p builds
|
||||
|
||||
go tool dist list | grep -v android | grep -v darwin | grep -v ios | grep -v wasip1 | awk -F '/' '{printf "echo Compiling %s/%s; env CGO_ENABLED=1 GOOS=%s GOARCH=%s go build -o builds/snake.%s-%s\n",$1,$2,$1,$2,$1,$2 }' | sh
|
22
render.go
22
render.go
@ -9,20 +9,24 @@ import (
|
||||
// drawScore Print the score
|
||||
func drawScore(screen tcell.Screen, style tcell.Style, score *Score) {
|
||||
var x, y int = 5, 24
|
||||
for _, r := range []rune("[ Score: " + strconv.FormatInt(int64(score.score), 10) + " ]") {
|
||||
screen.SetContent(x, y-1, r, nil, style)
|
||||
content := "[ Score: " + strconv.FormatInt(int64(score.score), 10) + " ]"
|
||||
for i := 0; i < len(content); i++ {
|
||||
screen.SetContent(x, y-1, rune(content[i]), nil, style)
|
||||
x++
|
||||
}
|
||||
}
|
||||
|
||||
// drawCoords Print the coordinates of the head of the snake
|
||||
func drawCoords(screen tcell.Screen, style tcell.Style, snake *Snake) {
|
||||
var x, y int = 25, 24
|
||||
for _, r := range []rune("[ x:" + strconv.FormatInt(int64(*&snake.head.x), 10) + " y: " + strconv.FormatInt(int64(*&snake.head.y), 10) + " ]") {
|
||||
screen.SetContent(x, y-1, r, nil, style)
|
||||
x++
|
||||
}
|
||||
}
|
||||
// func drawCoords(screen tcell.Screen, style tcell.Style, snake *Snake) {
|
||||
// var x, y int = 25, 24
|
||||
// var snakex int = *&snake.head.x
|
||||
// var snakey int = *&snake.head.y
|
||||
// content := "[ x:" + strconv.Itoa(snakex) + " y: " + strconv.Itoa(snakey) + " ]"
|
||||
// for i := 0; i < len(content); i++ {
|
||||
// screen.SetContent(x, y-1, rune(content[i]), nil, style)
|
||||
// x++
|
||||
// }
|
||||
// }
|
||||
|
||||
// drawBox Draw the outline of the box the snake can move in
|
||||
func drawBox(s tcell.Screen, style tcell.Style, x1, y1, x2, y2 int) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user