SNAKE GAME

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
congvu
Date:
Wed Nov 25 04:25:25 2020 +0000
Revision:
0:24041b847eb5
ECE2035 SNAKE GAME;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
congvu 0:24041b847eb5 1 // Copyright 2020 Georgia Tech. All rights reserved.
congvu 0:24041b847eb5 2 // The materials provided by the instructor in this course are for
congvu 0:24041b847eb5 3 // the use of the students currently enrolled in the course.
congvu 0:24041b847eb5 4 // Copyrighted course materials may not be further disseminated.
congvu 0:24041b847eb5 5 // This file must not be made publicly available anywhere.
congvu 0:24041b847eb5 6
congvu 0:24041b847eb5 7 #include "snake.h"
congvu 0:24041b847eb5 8
congvu 0:24041b847eb5 9 void snake_init (Snake * s)
congvu 0:24041b847eb5 10 {
congvu 0:24041b847eb5 11 s->head_x = 5;
congvu 0:24041b847eb5 12 s->head_px =0;
congvu 0:24041b847eb5 13 s->head_y = 5;
congvu 0:24041b847eb5 14 s->head_py =0;
congvu 0:24041b847eb5 15 s->length = 3;
congvu 0:24041b847eb5 16
congvu 0:24041b847eb5 17 for (int i = 0; i < SNAKE_MAX_LENGTH; i++) {
congvu 0:24041b847eb5 18 s->locations[i].x = s->head_x - i;
congvu 0:24041b847eb5 19 s->locations[i].y = s->head_y;
congvu 0:24041b847eb5 20 }
congvu 0:24041b847eb5 21
congvu 0:24041b847eb5 22 s->pointLockTime = 0; //Time that snake can't gain points
congvu 0:24041b847eb5 23 s->speedupTime = 0;
congvu 0:24041b847eb5 24 s->slowdownTime = 0;
congvu 0:24041b847eb5 25 s->score = 0; //Current score of the snake
congvu 0:24041b847eb5 26 s->invincible = false;
congvu 0:24041b847eb5 27 s->invincTimer = 0;
congvu 0:24041b847eb5 28 }