(root)/src/snake.cpp - Rev 14
Rev 13 |
Rev 15 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <vector>
using namespace std;
#include "point.hpp"
#include "snake.hpp"
Snake::Snake()
{
R = 255;
G = 255;
B = 0;
direction = Up;
}
void Snake::nextPoint(Point newPoint)
{
points.insert(points.begin(), newPoint);
points.pop_back();
}
void Snake::move()
{
switch (direction)
{
case up:
nextPoint(Point(points[0].X, points[0].Y - 1));
case down:
nextPoint(Point(points[0].X, points[0].Y + 1));
case left:
nextPoint(Point(points[0].X - 1, points[0].Y));
case right:
nextPoint(Point(points[0].X + 1, points[0].Y));
}
}