Cong Vu / Mbed 2 deprecated Project2_cvu31

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers snake.cpp Source File

snake.cpp

00001 // Copyright 2020 Georgia Tech.  All rights reserved.
00002 // The materials provided by the instructor in this course are for
00003 // the use of the students currently enrolled in the course.
00004 // Copyrighted course materials may not be further disseminated.
00005 // This file must not be made publicly available anywhere.
00006 
00007 #include "snake.h"
00008 
00009 void snake_init (Snake * s)
00010 {
00011     s->head_x = 5;
00012     s->head_px =0;
00013     s->head_y = 5;
00014     s->head_py =0;
00015     s->length = 3; 
00016     
00017     for (int i = 0; i < SNAKE_MAX_LENGTH; i++) {
00018         s->locations[i].x = s->head_x - i;
00019         s->locations[i].y = s->head_y;
00020     }  
00021     
00022     s->pointLockTime = 0; //Time that snake can't gain points
00023     s->speedupTime = 0;
00024     s->slowdownTime = 0;
00025     s->score = 0; //Current score of the snake
00026     s->invincible = false;
00027     s->invincTimer = 0;
00028 }