Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MotionSensor
Entity/Snake/Snake.h
- Committer:
- el17sm
- Date:
- 2019-04-24
- Revision:
- 16:ddb203a74dfc
- Child:
- 17:99e533f7f2fb
- Child:
- 19:bfe410c82b45
File content as of revision 16:ddb203a74dfc:
#ifndef SNAKE_H
#define SNAKE_H
#include "Entity.h"
class Snake : public Entity {
public:
// Constructor
Snake(float, float);
// Functions
virtual void move(float, float);
virtual int * get_frame();
};
const float velocity_pattern[6] = {0, 0.3, 0.5, 0.7, 0.5, -0.2};
const int sprite_snake[4][6][12][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
{ // Up
{
{0,0,0,0,0,0,},
{1,0,0,0,0,0,},
{0,1,1,1,1,0,},
{1,0,1,1,0,1,},
{0,0,1,1,0,0,},
{0,0,1,1,0,0,},
{0,1,0,0,1,0,},
{0,1,0,0,1,0,},
{0,1,0,0,1,0,}
},
{
{0,0,0,0,0,0,},
{0,0,0,1,0,0,},
{0,1,1,1,1,0,},
{1,0,1,1,0,1,},
{0,0,1,1,0,0,},
{0,0,1,1,0,0,},
{0,1,0,0,1,0,},
{0,1,0,0,1,0,},
{0,0,0,0,1,0,}
},
{
{0,0,0,0,1,0,},
{0,0,1,0,0,0,},
{0,1,1,1,1,0,},
{1,0,1,1,0,1,},
{0,0,1,1,0,0,},
{0,0,1,1,0,0,},
{0,1,0,0,1,0,},
{0,1,0,0,1,0,},
{0,1,0,0,1,0,}
},
{
{0,1,0,0,0,0,},
{0,0,0,0,0,0,},
{0,1,1,1,1,0,},
{1,0,1,1,0,1,},
{0,0,1,1,0,0,},
{0,0,1,1,0,0,},
{0,1,0,0,1,0,},
{0,1,0,0,1,0,},
{0,1,0,0,0,0,}
},
{
{0,0,0,0,1,0,},
{0,0,1,0,0,0,},
{0,1,1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