Here is a little terminal game I wrote during some free time at work. It’s not quite finished and may be buggy, but it’s good enough to share for testing.
Compile with:
cc snek.c -o snek -Wall
and run:
./snek
Here is a little terminal game I wrote during some free time at work. It’s not quite finished and may be buggy, but it’s good enough to share for testing.
Compile with:
cc snek.c -o snek -Wall
and run:
./snek
Nice, just gave it a go
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}"
}
I gotta rewrite this in rust
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?
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…
Who knows…maybe some day you will regret about it, maybe you’ll find modification of it in some smart watch or something
What about -O3
& -flto
? Can’t leave any performance on the table.
I know! Let’s use -O4
!
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.
My favourite mode:
./snek -w 18 -h 14 -s 9 -r
are you playing on a watch ?
I love the colors of the snake. usually the snek is a single color. great game.
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.
It’s actually pretty nice. Would love to see an animation when the snake hits the wall.
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…
The snake shrinking and add a simple small “explosion” where the head runs into the wall.