SHARE
TWEET

Untitled

a guest Jun 19th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include "sl.h"
  3. //10.0, 10.0
  4.  
  5. int main()
  6. {
  7.     //Class representing each space on board. Black = empty space, Green = snake, Red = pill
  8.     class BoardSpace{
  9.         public:
  10.             void SetSpaceColor( double red, double blue, double green, double alpha){
  11.                 slSetForeColor( red, green , blue, alpha);
  12.             }
  13.  
  14.             void DrawSpace( double x, double y, double width, double height){
  15.                 slRectangleFill( x, y, width, height);
  16.             }
  17.     };
  18.  
  19.     // Set up our window and a few resources we need
  20.     slWindow( 993, 601, "Snake Game", false);
  21.     BoardSpace SnakeBoard[43][26];
  22.  
  23.  
  24.     while(!slShouldClose() && !slGetKey(SL_KEY_ESCAPE)){
  25.         for(int i = 0; i < 43; ++i){
  26.             for(int j = 0; j < 26; ++j){
  27.                 SnakeBoard[i][j].SetSpaceColor( 0.0, 0.0, 1.0, 1.0);
  28.                 SnakeBoard[i][j].DrawSpace( 13 + (23 * i), 13 + (23 * j), 20.0, 20.0);
  29.  
  30.             }
  31.         }
  32.  
  33.         slRender();
  34.     }
  35. }
RAW Paste Data
Top