26
6
Games are fun
this codegolf here was so fun I had to make a version for other classic games similar in complexity. Shortest Way of creating a basic Space Invaders Game in Python
This time, however, try to recreate the classic 'Snake' game, in which you start out as a small shape, constantly moving to collecting pieces to increase your score. When you collect a piece, your 'tail' grows, which follows the path you have made. The objective is to last the longest without crashing into your own tail, or into the walls
Qualifications:
- You, the characters that make up the tail, the walls, and the pieces you collect should all be different characters
- show an HUD with the score. The score increases by 1 point for each piece you collect
- The player loses when they collide with their own tail or the wall
- a piece spawns in a random area immediately after a piece is collected, not to mention at the start of the game
- Speed of the game doesn't matter, as long as it is consistent
The 'cells' should be 2x1 characters, since the height of block characters is ~twice the widthCan be 1x1, because 2x1 is just ugly and I didnt really think of that- The keys for changing the direction should be
awsd
, left, up, down, right respectively - the starting direction should always be up
- You must show the edges of the wall. The score may overlap the wall
Shortest code that meets the above criteria wins. Imaginary Bonus Points for creativity
1@scrblnrd3
M-: (progn(define-key snake-mode-map"a"'snake-move-left)...(setq snake-initial-velocity-x 0 snake-initial-velocity-y 1)(snake))
would do the trick then. – Jonathan Leech-Pepin – 2016-03-31T12:51:09.150Related: Nibbles Nostalgia
– sergiol – 2018-06-09T01:11:29.0132Without the
awsd
and thestarting direction should always be up
requirements,M-x snake
would work – scrblnrd3 – 2014-04-22T14:12:12.097The snake isn't supposed to grow when eating? – ceased to turn counterclockwis – 2012-01-04T00:18:09.750
hm? "When you collect a piece, your 'tail' grows, which follows the path you have made.", so yes, the snake grows. – Blazer – 2012-01-04T02:46:25.583