Skip to main content

10 | Assignment 10

danger

If you goal is to create your own snake game via grabbing code off the web and or using AI helps, then you must really understand OOP deeply and be able to defend your work. If you can't defend your work, you will not get credit for this project. It is not realistic that a beginning student can do this. So follow the step-by-step directions as they are presented, or choose to do the other OOP assignment that I will have in place by later in the semester. You may also do an OOP project of your own, if you wish, just let me know what you are planning to do. There are lots of options in various books and sites, but again, I may ask you to defend your work.

Snake Game

The purpose of this assignment is for all students to get a global feel for what is involved to create a Python game using the Pygame library and Object Orienting programming. This is actually a fairly advanced game. It is not necessary for you to know all of the code requirements in great detail. The goal is not for you to submit one final game file. If that were the goal, then there would be nothing to prevent a student from simply turning in the finished code example that is freely available.

You will start out editing the snake.py file and then you will save it as step_1a_definitions.py. When you finish step_1a_definitions.py you will save it as step_1b_game_loop.py and continue coding. You can only create these files as you go along. At the completion of each file, you should run your program and make sure it runs as expected.

As you continue the process you will finish up with the following files:

step_1a_definitions.py            
step_1b_game_loop.py
step_2a_add_green.py
step_3a_grid_cells.py
step_3b_food_fixed_rect.py
step_3c_food_fixed_image.py
step_3d_food_random.py
step_4a_create_rect_snake.py
step_4b_make_segments_rounded.py
step_5a_move_snake_yes_reverse.py
step_5b_move_snake_no_reverse.py
step_5c_game_class.py
step_6a_eating_food.py
step_6b_gen-rand-pos.py
step_6c_gen-check-snake.py
step_7_make_snake_grow.py
step_8_collision_print_game_over.py
step_8b_game_over_reset.py
step_8c_game_over_restart.py
step_8d_game_over_hit_tail.py

This is not the complete game. This is all that I am requiring for the project. If you want to create additional steps for extra practice or extra credit, then you may do so.

All of these steps are in the Panopto videos.

  1. Video 1: In class video (29:04)
  2. Video 2: In class video (8:50)
  3. Video 3: After class video (24:44)
  4. Video 4: After class video (5:59)

If you have not yet started the project, you will need to download the zipped starter file at the top of this page: https://opal.ils.unc.edu/~lblakej/snake-game/01-pygame/

Pygame installation

We had a previous online session for all students to confirm that they had Pygame installed.

If you are having issues with Pygame running, then contact me. You will not be able to test your code if Pygame is not installed and working. Here is the page to make sure you have pygame installed. https://opal.ils.unc.edu/~lblakej/snake-game/01-pygame/

Resources

There is a website that has step by step instructions: https://opal.ils.unc.edu/~lblakej/snake-game/

These are mostly formatted, but I still need to polish up a few pages.

If you would like to have primarly instructional video you can access it here. https://opal.ils.unc.edu/~lblakej/560/

Login and Password is in the Canvas Assignment page

It is my hope that you will take this opportunity to document this process for future reference. Therefore it would be good to add comments as you go that will help you remember what you learned as you do the project. These comments should be your own comments. Each project should be done individually. This is not a group project. Any files that are exactly the same with the exact same comments will constitute a potential integrity issue. Any submissions with no additional comments will not earn full points.

Snake Game Submission

When you have completed all of the steps, you can zip up the folder and email it to me as it is a pretty small file. You may submit some text in Canvas to let me know that you have emailed it to me. This will auto-send me an additional email, and also will show in the grading window that you have submitted the project.

caution

I have been in communication with Nick Koumaris and have donated to his channel and I want to protect his rights to the code and not have it posted on GitHub where it will get indexed or copied without proper attribution. Since this code is Nick's don't upload this project to GitHub where it could be seen as code you created. This protects you most of all. If you have already done this, no worries, just please remove it as soon as possible. Delete in your local directory and stage, commit and push. Or you can use the steps shown below to delete the file from the web version of your repository.

There will be a resubmit opportunity provided you submit it early enough.

delete assignment 10 instructions