Here is a little terminal game I wrote during some free time. Itās not quite finished and may be buggy, but itās good enough to share for testing.
The source code consists of only one file (snek.c
). Compile with:
cc snek.c -o snek -Wall
and run:
./snek
For help, run:
./snek --help
Enjoy!
12 Likes
Hereās a simple pkgbuild if youād like to put it up on the AUR. (or I could put it there if youād like)
_pkgname=snek
pkgname="${_pkgname}-git"
pkgver=r8.2c92a3b
pkgrel=1
pkgdesc="A simple terminal snake game written in C"
arch=("any")
url="https://gitlab.com/Kresimir235/snek"
license=("MIT")
makedepends=( "git" )
provides=("snek")
source=("${_pkgname}::git+${url}.git")
sha256sums=("SKIP")
pkgver() {
cd "${srcdir}/${_pkgname}"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
build() {
cd "${_pkgname}"
cc snek.c -o snek -Wall -O2
}
package() {
install -Dm0755 "${_pkgname}/${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}"
}
Also...
I gotta rewrite this in rust
3 Likes
flyingcakes:
-O2
Optimisations? In my C? Outrageous!
I donāt want to put it on the AUR before it is thoroughly testedā¦ and I donāt really care about maintaining it.
But if you want to, feel free to, itās MIT license, so anyone can do anything with it. Even compile it with -O2
MIT?!
You want to find out it used as some proprietary spy software later?
1 Like
The target audience for this software is unlikely to use proprietary spyware, so Iām not terribly worried. Itās what I call the IDGAF licenseā¦
2 Likes
Who knowsā¦maybe some day you will regret about it, maybe youāll find modification of it in some smart watch or something
2 Likes
What about -O3
& -flto
? Canāt leave any performance on the table.
2 Likes
There is a new commit to the Snek game. A bunch of new features have been added:
ā command line arguments
ā pause functionality: so you can go to the loo in the middle of the game
ā repeat mode: so you start a new game automatically after losing
ā setting game size: you can play on a board size between 18Ć14 and 160Ć100
ā setting the game speed
ā monochrome mode for -terminals
It should be feature complete now.
5 Likes
My favourite mode:
./snek -w 18 -h 14 -s 9 -r
1 Like
are you playing on a watch ?
I love the colors of the snake. usually the snek is a single color. great game.
2 Likes
anon31549144:
snek is a single color
Yeah, just added that featureā¦ And another commit, fixed a little bug so that the game now automatically switches to monochrome mode in -terminals.
No
I just love infinite death
Well, it is aā¦ *puts on sunglasses*
ā¦terminal game.
2 Likes
Itās actually pretty nice. Would love to see an animation when the snake hits the wall.
1 Like
Thanks! What kind of animation did you have in mind? I was thinking about letting Snek shrink to nothing (head standing still, tail continuing on its way). That would be fairly straightforward to implement, but if Snek is long, it might take awhile and detract from the gameplay. I donāt knowā¦
1 Like
The snake shrinking and add a simple small āexplosionā where the head runs into the wall.