Hungry Snake

Recommended levellevel
A long serpentine creature slithers across a limited field, obeying the player's orders (moving right, left, down, and up). And there's no way to stop it from moving. Just don't touch the boundaries or you'll die! And don't bite yourself or... well, you get the idea. Along the way, the creature encounters food that makes it even longer. As it grows, it gets more and more cramped... Stop the madness! You probably recognize this comedic storyline from the famous game "Snake". This game originated in the 1970s. That's when it first appeared on arcade machines. In the 21st century, it was popularized by Nokia, which pre-installed Snake on almost all their mobile phones. Between these two milestones, there were versions for the Commodore VIC-20, MS-DOS, ZX Spectrum, Windows, Mac OS… If you go to Google Play or the App Store, you'll probably find a couple dozen different versions of Snake. It's hard to imagine a platform that doesn't have its own version of Snake. Why? On the one hand, it's an interesting game that is perfect for passing the time. On the other hand, Snake is simple enough to create on your own. See for yourself! Use Java to write your own version of this game about the adventures of a growing reptile. On CodeGym, we've already described every step, which will help a novice player handle this task without problems. Carry on!
Comments (84)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Anonymous #10826558
Level 0 , Recklinghausen, Germany
16 September, 15:40
Ey Leute kann mir jemand sagen wie gut er jetzt schon ist ?
Justin Smith
Level 17 , Greenfield, USA, United States
24 July, 15:30
I can't publish this one for some reason. From IDEA, it says I can't publish until I have completed all the parts (but it says I have completed 20/20, both in IDEA and here on this page). When I try to publish from this page, it gets an "Error while publishing. An unknown error has occurred. No additional information is available."
Level 41 , Solar System
25 July, 08:29
Please submit a question in the Help section, with your entire code included, then send the link to your question to
Justin Smith
Level 17 , Greenfield, USA, United States
25 July, 14:19
The help section doesn't allow you to include code from tasks marked as completed.
Level 41 , Solar System
30 July, 12:00
You can send your entire solution (all classes as separate txt files) to
Maxim Raitin
Level 20 , Tomsk, Russian Federation
20 July, 03:58
import com.codegym.engine.cell.*;
I can't import in intellij idea this, so I can't create games in my IDE. ☹️
John Squirrels Website Admin at CodeGym
23 July, 04:43
It should work. Could be because of your IntelliJ IDEA and/or javaFX settings. Please contact support at
Nevaeh Mizell
Level 0
14 July, 21:45
Level 0
5 July, 17:49
Level 0
28 June, 17:53
Calis-Rita Moses
Level 0 , Ridgewood
11 June, 11:16
not work
Level 41 , Solar System
11 June, 19:48
Please submit a question in the Help section, if your code does not pass verification.
Level 24 , Wittenberg, Germany
9 June, 14:53
part 16 validator strangeness: the validator failed my submission because I didn't perform the GOAL test if the snake was dead. Decoupling the two conditions worked (even though it doesn't make much sense to have the snake win after the game is already over because the snake died). Based on that experienced I shelved all plans to review the logic with regard to isGameOver ...
27 May, 15:53
The way codegym has put up the coding walthrough and coding execution requirements and stuff and really amazing and helpful to learn. But still i need to bridge a little gap between everything i learned in java and the way things are designed and coded. I mean, i cannot think this way on my own. I am literally forgetting the implementations after i move on further. not much concepts are needed here but still, the way it is designed, i cannot code most of this without getting repetititive errors. What should i do else to feel more comfortable with this?? Kindly help!!
Maxim Raitin
Level 20 , Tomsk, Russian Federation
31 May, 03:38
more practise?
Karas Java Developer
14 April, 22:41
@CodeGym There seems to be a small bug somewhere in the setScreenSize method it creates the screen but it is funky it has black squares. I checked a small bunch of completed ones and seem mlike all of them have this bug. Sorry if this is not the correct way to submit a ticket.
Level 41 , Solar System
17 April, 14:57
Please send a screenshot or, even better, a video, to