5 ms·
Snake game made in Go
- Cheyana 7y agoYou should call it Go Snake Go! Also, I always wondered what it would be like if you mixed a snake game with Conway's Game of Life. Watching a snake go around the screen blasting through automata would be interesting ( or maybe not).
- Impossible 7y agohttp://www.asahi-net.or.jp/~cs8k-cyu/flash/la2/index.html http://www.asahi-net.or.jp/~cs8k-cyu/flash/la2/index.html. LA-2 is close to what you're describing although it's a shmup instead of a snake game. It's old so unfortunately it's a Java applet that might be hard to run now :(. Google has been very successful in killing all old interactive content on the web.
- gdm85 7y agoInteresting! Let me give this a try :)
- tristangoossens 7y agoThat sounds kind of cool. Might be a good prequel to this game
- ubu7737 7y agoWhat next, a chess game? Oops.
- tristangoossens 7y agouuhm well yeah i could, thank you for the suggestion haha
- ubu7737 7y agoSorry. I was actually goofing on the fact that Go demos are rehashing the history of C. And frustrated that I'm not hearing anything from Golang programmers about how it enables a larger class of software. "We're writing the same software, just better" isn't a reason to come up with a new language.
- Insanity 7y agoI'd say it is a great reason to write a new language. I mean, otherwise we'd just stick with assembly, no?
- ubu7737 7y agoIt's a great reason to write a new runtime. JVM is still okay. If you thought using a new language would give you better runtime character, you were wrong. Languages are transpiled and cross-compiled on the reg, and it really makes no difference to the runtime what language you used to get your bytecodez into the scheduler.
- ubu7737 7y agoIt really feels as though someone has done career JVM professionals a huge favor, sending all the upcomers to Python and PHP and Golang. Let them learn in their sandboxes, right? Newcomers don't need connectors anyway, they need the room to experiment with syntax and such, get their head around ASCII symbols. It's great, good luck. In my teens I wrote Snake and Dig-Dug and Chinese Checkers and whatnot. I was learning to write anything at all. But twenty years on, distributed systems are applications. Writing Golang as though it changes the paradigm is fucking silly. But learn however you want to learn.
- tristangoossens 7y agowell as im not very familiar i cant judge about it, the only other languages i know are c#, php, html and css but i do get your point!
- shipit 7y agoIs that War Games reference?
- Mountain_Skies 7y agoBe worried if they start playing tic tac toe.
- lspears 7y agoPlug: https://github.com/notnil/chess https://github.com/notnil/chess
- tristangoossens 7y agoThis looks awesome, i gave it a star
- jilles 7y agoReally cool! As a Go noob, I love the comments everywhere.
- tristangoossens 7y agoYeah i put them there so if anyone would ever want to recreate it, they would understand my functions and maybe work on top or from them
- acomjean 7y agoVery readable, and I don't even know GO.
- kissgyorgy 7y agoI have an idea: there are a couple of these already, pretty fun to play. There could be a service, in which you can SSH into then play these games! with scoreboards, forum, discoverability and stuff. It would be a pretty niche product/service, but would be fun to build and play! It could be the steam of modern terminal games :D
- tristangoossens 7y agoI am actually trying to get my project out there, as this is actually my first big project.So every star would be appreciated(maybe we can even reach trending)
- K0SM0S 7y agoIs your ultimate interest more in game dev or the 'classic' Go problem space (servers, concurrency, scaling, etc.), or both maybe? Like what would your 50th project be, ideally?
- tristangoossens 7y agoI would’n’t know actually, i would say that they both sound good to me. I am only 17, so ive got plenty of things ahead of me :)
- K0SM0S 7y agoAha, with that kind of skill and ethics at such a yound age, indeed! Way to Go ;)
- Mountain_Skies 7y agoThis is a bit off topic but since there might be some Go folks in here, does anyone know of a Go equivalent of WebGoat (an intentionally insecure code base for testing vulnerability scanners)? Doesn't need to be a WebGoat clone, just an insecure code base written in Go.
- tristangoossens 7y agoi dont think i can help you with that one, sorry chief
- daehee 7y agoThe recent Square CTF had some good Go related challenges, e.g. https://squarectf.com/2019/lockbox.html https://squarectf.com/2019/lockbox.html
- gameswithgo 7y agoIf you are interested in gamedev and Golang, a while back I did a video series teaching programming via game projects in Go. Starts out with text games, then 2d, then some opengl 3d stuff at the end. Jump in wherever you like! All free. https://gameswithgo.org/ https://gameswithgo.org/
- tristangoossens 7y agoIll definitely check that out, thanks!
- crehn 7y agoLooks good! Also made something similar, although with much less features and in a single file: http://github.com/hoffa/snake http://github.com/hoffa/snake
- tristangoossens 7y agoi gave it a star! i think the simplicity of the game is what makes it special!
- archarios 7y agoNow write it in Clojure and compare your line counts
- tristangoossens 7y agowell i would if i knew the language, sounds like a challenge though
- sahil-kang 7y agoHere’s one in Common Lisp if you’re interested in comparing loc with a lisp :) https://github.com/SahilKang/cl-snake https://github.com/SahilKang/cl-snake
- stupidcar 7y agoFinally QBasic has a serious competitor.
- tristangoossens 7y agoI dont really know what you mean by that, but thanks?!
- stupidcar 7y agoJust a silly joke. one of the more famous example programs that came with QBasic for MS-DOS was a snake game called Nibbles: https://en.m.wikipedia.org/wiki/Nibbles_(video_game) https://en.m.wikipedia.org/wiki/Nibbles_(video_game)
- amasad 7y agoIf you want to play it online I just cloned it into repl.it and it worked: https://repl.it/@amasad/snake-go https://repl.it/@amasad/snake-go
- sliken 7y agoNot for me.
- tristangoossens 7y agoi think we might need more users to test it, here is a link to the pull request. please test these and leave your feedback https://github.com/tristangoossens/snake-go/pull/2 https://github.com/tristangoossens/snake-go/pull/2
- compi 7y agoSnake games are my go-to when I learn new languages, it's always under 1000 lines of code and can usually be done without libraries. In not a lot of time you can learn how the language: - does timers - does sleeping and/or threads - handles user input - gets some kind of output to screen - provides basic data structures - writes and loads files for high scores There are a lot of things that I like about the original Snake that most people don't put into their hobby projects: - There is a delay right before you hit the wall. If you are playing at the fastest speed and barrel towards the wall, it slows down to the slowest speed when you are on the final square before game over. I always loved this because the it made the most deadly obstacle the snake body which is the one that you yourself created. - When it polled input it stored one of each press. If you pressed up then left, and the next tick the snake would turn up, and the next tick the snake would turn left. - There are only four parts of the screen max that are updated each tick, the new snake head is drawn, the previous snake head is drawn as a body, the previous snake butt is cleared, and maybe a new egg is drawn. Very common to see a snake game draw the entire screen, or redraw the entire snake on each tick. Super frustrating to have a game get start to stutter more and more as your snake gets longer. - You could play using two buttons instead of four. The game could be played by using buttons 2=up 8=down 4=left 6=right. But it could also be played using buttons 1=up-or-left and 9=down-or-right because you can only change from your current direction to two other directions since you can't have a button to go the opposite direction, and you don't need a button to go the same direction. It was never super intuitive though, a "right turn" or "left turn" button would make more sense. The only critique I have for this is your snake almost doubles speed when you move up or down which is pretty jarring.
- keyle 7y agoGood points, I never realised about the screen update size, although most renderer will redraw the whole screen every frame (immediate mode).
- tristangoossens 7y agothank you for the very detailed and useful reply! i will definitely think about adding some, if not most of your suggestions. The problem i have with the snake is that one cell in a termloop is not a square but a rectangle. for example a cell could be 1 width and 2 height, so if the snake would move 1 cell up, it would actually move 2 up.
- hobojones 7y agoCongratulations! It may not seem like a big accomplishment, but it is. It's one thing to toy around with a language, but creating a fully realized product is a big deal. There's nothing that compares to that feeling when you load up your project and it just works as you expect it should. You should definitely walk around the next few days with a big grin on your face :).
- rishav_sharan 7y agoQuick question; Whats been the performance like, specially with Go's GC. I know snake is probably not a project to push the language run time to its limit but still would love someone to chime in. I may be wrong here but i assume that GO's GC is more geared towards concurrent data access tasks like web servers. I am currently evaluating 2 tiny frameworks; ebiten and oak. Oak is super interesting as it doent uses sdl/glfw etc in its core. But has a rougher api. Ebiten on the other hand feels very frinctionless.