simple snake game
Dependencies: C12832_lcd EthernetInterface WebSocketClient mbed-rtos mbed
Snake.h
- Committer:
- lyukx
- Date:
- 2016-12-08
- Revision:
- 0:2e5a51003afe
File content as of revision 0:2e5a51003afe:
/**************************** * A LCD-based snake game. * *****************************/ #include "mbed.h" #include "C12832_lcd.h" #include <math.h> #include <iostream> #include <string> #include <sstream> #include <stdio.h> using namespace std; // 40 * 32 -> 5 Byte * 32 // LCD controll class class Screen{ public: void init(); // Initial the screen data void generate_lcd(); // Generate lcd data from raw screen data void write_to_screen(); // Write the screen data to }; class SnakeControll{ public: int point; void init(); // Initial the game status int direction; // Direction list: // 0 - left // 1 - right // 2 - up // 3 - down int step(); void set_direction(int d); void generate_food(); string get_gamedata(); // Return a json string private: string num2str(int num); string pos2str(int x, int y); };