SNAKE GAME
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: snake.cpp
- Revision:
- 0:24041b847eb5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/snake.cpp Wed Nov 25 04:25:25 2020 +0000 @@ -0,0 +1,28 @@ +// Copyright 2020 Georgia Tech. All rights reserved. +// The materials provided by the instructor in this course are for +// the use of the students currently enrolled in the course. +// Copyrighted course materials may not be further disseminated. +// This file must not be made publicly available anywhere. + +#include "snake.h" + +void snake_init (Snake * s) +{ + s->head_x = 5; + s->head_px =0; + s->head_y = 5; + s->head_py =0; + s->length = 3; + + for (int i = 0; i < SNAKE_MAX_LENGTH; i++) { + s->locations[i].x = s->head_x - i; + s->locations[i].y = s->head_y; + } + + s->pointLockTime = 0; //Time that snake can't gain points + s->speedupTime = 0; + s->slowdownTime = 0; + s->score = 0; //Current score of the snake + s->invincible = false; + s->invincTimer = 0; +}