-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakeBody.cpp
48 lines (39 loc) · 1007 Bytes
/
SnakeBody.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// SnakeBody.cpp
// Game
//
// Created by chenjinpeng on 15/5/10.
//
//
#include "SnakeBody.h"
USING_NS_CC;
SnakeBody::SnakeBody() : x(0), y(0), direction(Direction::NONE), type(Type::FOOD)
{
}
SnakeBody::~SnakeBody()
{
}
void SnakeBody::calculate()
{
{
clear();
switch(type)
{
case Type::BODY :
{
drawSolidRect(cocos2d::Point(20+50*x, 20+50*y), cocos2d::Point(20+50*(x + 1), 20 +50*(y + 1)), cocos2d::Color4F::GREEN);
break;
}
case Type::FOOD:
{
drawSolidRect(cocos2d::Point(20+50*x, 20+50*y), cocos2d::Point(20+50*(x + 1), 20 +50*(y + 1)), cocos2d::Color4F::ORANGE);
break;
}
case Type::HEAD:
{
drawSolidRect(cocos2d::Point(20+50*x, 20+50*y), cocos2d::Point(20+50*(x + 1), 20 +50*(y + 1)), cocos2d::Color4F::BLUE);
break;
}
}
}
}