Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "sl.h"
- //10.0, 10.0
- int main()
- {
- //Class representing each space on board. Black = empty space, Green = snake, Red = pill
- class BoardSpace{
- public:
- void SetSpaceColor( double red, double blue, double green, double alpha){
- slSetForeColor( red, green , blue, alpha);
- }
- void DrawSpace( double x, double y, double width, double height){
- slRectangleFill( x, y, width, height);
- }
- };
- // Set up our window and a few resources we need
- slWindow( 993, 601, "Snake Game", false);
- BoardSpace SnakeBoard[43][26];
- while(!slShouldClose() && !slGetKey(SL_KEY_ESCAPE)){
- for(int i = 0; i < 43; ++i){
- for(int j = 0; j < 26; ++j){
- SnakeBoard[i][j].SetSpaceColor( 0.0, 0.0, 1.0, 1.0);
- SnakeBoard[i][j].DrawSpace( 13 + (23 * i), 13 + (23 * j), 20.0, 20.0);
- }
- }
- slRender();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement