SnakeMLX

over 2 years

2023 02

This is a challenge for anyone who wants to have fun! Cheers and GL!

SnakeMLX Challenge

Hello, friends.
I bet you have played the snake game before, it was very popular when phones were not "smart" at all.
It is a simple game that I find to be an amazing example to train your brain and your problem-solving skills.
I encourage you to try the challenge without consulting any resources on the internet or elsewhere. Invite your friends, even if they are not programmers, they can help you with this task, and you can discuss, reflect, and come up with a solution on how you think the game works.

The Challenge

I will provide you with most of the code to generate the window, images & the snake.
You have to generate the code for the logic.
  • Snake movement.
  • Snake speed
  • Snake growth
  • Snake hit itself
BONUS
  • Wall collision
  • Snake goes beyond the edge and appears on the opposite side
  • Multiplayer
I will provide you with the project to get started.
You will need to decide how it's best to represent the food (whatever the snake consumes in order to grow)
On the code I provide, you already have a working game and a snake but it does nothing!
You have to figure out how to move it, how to collect the food, how to grow and how to die!

You can change anything, if you think there is a bug or something that could be improved from the code I provide, don't hesitate to contact me.
This Challenge is meant for you to only change the function update and read_keys. You also need to think about how it is best to represent the food and add it to the code accordingly.
Download the game with the button below and get started!
Run make test to visualize the project before getting started!




The following commands can come in handy
make test
make show
gdb ./snake OR lldb ./snake

Please share your game on slack or discord and let others know about it! :D

***SPOILER!!!*** Link to my solution