Compare commits
No commits in common. "master" and "v20231124" have entirely different histories.
@ -1,18 +0,0 @@
|
|||||||
# 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
|
|
@ -1,28 +0,0 @@
|
|||||||
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
Executable file
5
build.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/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,24 +9,20 @@ import (
|
|||||||
// drawScore Print the score
|
// drawScore Print the score
|
||||||
func drawScore(screen tcell.Screen, style tcell.Style, score *Score) {
|
func drawScore(screen tcell.Screen, style tcell.Style, score *Score) {
|
||||||
var x, y int = 5, 24
|
var x, y int = 5, 24
|
||||||
content := "[ Score: " + strconv.FormatInt(int64(score.score), 10) + " ]"
|
for _, r := range []rune("[ Score: " + strconv.FormatInt(int64(score.score), 10) + " ]") {
|
||||||
for i := 0; i < len(content); i++ {
|
screen.SetContent(x, y-1, r, nil, style)
|
||||||
screen.SetContent(x, y-1, rune(content[i]), nil, style)
|
|
||||||
x++
|
x++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// drawCoords Print the coordinates of the head of the snake
|
// drawCoords Print the coordinates of the head of the snake
|
||||||
// func drawCoords(screen tcell.Screen, style tcell.Style, snake *Snake) {
|
func drawCoords(screen tcell.Screen, style tcell.Style, snake *Snake) {
|
||||||
// var x, y int = 25, 24
|
var x, y int = 25, 24
|
||||||
// var snakex int = *&snake.head.x
|
for _, r := range []rune("[ x:" + strconv.FormatInt(int64(*&snake.head.x), 10) + " y: " + strconv.FormatInt(int64(*&snake.head.y), 10) + " ]") {
|
||||||
// var snakey int = *&snake.head.y
|
screen.SetContent(x, y-1, r, nil, style)
|
||||||
// content := "[ x:" + strconv.Itoa(snakex) + " y: " + strconv.Itoa(snakey) + " ]"
|
x++
|
||||||
// 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
|
// 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) {
|
func drawBox(s tcell.Screen, style tcell.Style, x1, y1, x2, y2 int) {
|
||||||
|
4
snake.go
4
snake.go
@ -14,7 +14,7 @@ func initSnake(snakex int, snakey int) Snake {
|
|||||||
},
|
},
|
||||||
tail: []Position{
|
tail: []Position{
|
||||||
{
|
{
|
||||||
x: x - 3,
|
x: x - 1,
|
||||||
y: y,
|
y: y,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ func initSnake(snakex int, snakey int) Snake {
|
|||||||
y: y,
|
y: y,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
x: x - 1,
|
x: x - 3,
|
||||||
y: y,
|
y: y,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user