Commit 84a97dc2 authored by jack.webb's avatar jack.webb

Update Snake

parent ac354c5b
Pipeline #581 failed with stages
......@@ -52,6 +52,9 @@ void draw() {
//Boundries, so game ends if touch sides
if(x.get(0) < 0 || y.get(0) < 0 || x.get(0) >= w || y.get(0) >= h) gameover = true;
//Prevents the snake moving over itself, and going backwords
for(int i=1;i<x.size();i++) if(x.get(0)==x.get(i)&&y.get(0)==y.get(i)) gameover=true;
//If snake eats apple, add length and randomise apple position
if (x.get(0)==applex && y.get(0)==appley) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment