diff --git a/Slang/Main.cpp b/Slang/Main.cpp index 218d508..7620b49 100644 --- a/Slang/Main.cpp +++ b/Slang/Main.cpp @@ -558,29 +558,29 @@ int parseSlang(string script) return 0; } -// -//int main(int argc, char* argv[]) -//{ -// // Get builtin script contents -// ifstream builtin("../Slang/builtin.slg"); -// stringstream builtinString; -// builtinString << builtin.rdbuf(); -// -// // Gathers builtin functions and variables -// GetBuiltins(builtinString.str()); -// functionValues = builtinFunctionValues; -// globalVariableValues = builtinVarVals; -// -// // Get default script contents -// ifstream script("../Slang/script.slg"); -// stringstream scriptString; -// scriptString << script.rdbuf(); -// -// while (true) { -// system("pause"); -// break; -// } -// parseSlang(scriptString.str()); -// -// return 0; -//} + +int main(int argc, char* argv[]) +{ + // Get builtin script contents + ifstream builtin("../Slang/builtin.slg"); + stringstream builtinString; + builtinString << builtin.rdbuf(); + + // Gathers builtin functions and variables + GetBuiltins(builtinString.str()); + functionValues = builtinFunctionValues; + globalVariableValues = builtinVarVals; + + // Get default script contents + ifstream script("../Slang/script.slg"); + stringstream scriptString; + scriptString << script.rdbuf(); + + while (true) { + system("pause"); + break; + } + parseSlang(scriptString.str()); + + return 0; +} diff --git a/Slang/Slang.vcxproj b/Slang/Slang.vcxproj index 4a8a0cf..75335ed 100644 --- a/Slang/Slang.vcxproj +++ b/Slang/Slang.vcxproj @@ -150,7 +150,6 @@ - diff --git a/Slang/Slang.vcxproj.filters b/Slang/Slang.vcxproj.filters index fba0eed..75811a9 100644 --- a/Slang/Slang.vcxproj.filters +++ b/Slang/Slang.vcxproj.filters @@ -24,9 +24,6 @@ Source Files - - Source Files - diff --git a/Slang/builtin.h b/Slang/builtin.h index 2016332..cabadbc 100644 --- a/Slang/builtin.h +++ b/Slang/builtin.h @@ -17,7 +17,7 @@ using namespace std; using namespace boost; -vector types = { "int", "float", "string", "bool", "void", "null", "Circle"}; +vector types = { "int", "float", "string", "bool", "void", "null", "Sprite"}; unordered_map>> builtinFunctionValues; unordered_map builtinVarVals; @@ -123,18 +123,15 @@ boost::any CPPFunction(const string& name, const vector& args) return AnyAsInt(args[0]); else if (name == "CPP.Graphics.Init") { - /*cout << "\x1B[32mInit graphics\033[0m\t\t" << endl; - mainWindow.Start(AnyAsInt(args[0]), AnyAsInt(args[1]));*/ + cout << "\x1B[32mInit graphics\033[0m\t\t" << endl; + initGraphics(AnyAsString(args[0]), AnyAsInt(args[1]), AnyAsInt(args[2])); } - else if (name == "CPP.Graphics.Circle") + else if (name == "CPP.Graphics.Sprite") { - /*Circle c; - c.x = AnyAsInt(args[0]); - c.y = AnyAsInt(args[1]); - c.r = AnyAsInt(args[2]); - boost::any a = c; - Circle d = any_cast(a); - return d;*/ + Sprite s(AnyAsString(args[0]), any_cast(args[1]), any_cast(args[2]), AnyAsFloat(args[3])); + boost::any a = s; + Sprite d = any_cast(a); + return d; } else if (name == "CPP.System.Print") cout << AnyAsString(args[0]); diff --git a/Slang/builtin.slg b/Slang/builtin.slg index 7ecf14a..34464d7 100644 --- a/Slang/builtin.slg +++ b/Slang/builtin.slg @@ -78,9 +78,16 @@ func Printl(in) CPP.System.PrintLine(in) } -// Creates new circle class -func NewCircle(x, y, r) +// Creates new sprite class +func NSprite(path, x, y, r) { - Circle c = CPP.Graphics.Circle(x, y, r) - return c + Sprite s = CPP.Graphics.Sprite(path, x, y, r) + return s +} + +// Creates new Vector2 class +func Vec2(x, y) +{ + Vec2 v = CPP.Graphics.Vec2(x, y) + return v } diff --git a/Slang/graphics.cpp b/Slang/graphics.cpp deleted file mode 100644 index 144d523..0000000 --- a/Slang/graphics.cpp +++ /dev/null @@ -1,405 +0,0 @@ -#include -#include -#include -#include -#include -//#include "graphics.h" - -const int WINDOW_WIDTH = 1280; -const int WINDOW_HEIGHT = 720; - -enum Buttons -{ - PaddleOneUp = 0, - PaddleOneDown, - PaddleTwoUp, - PaddleTwoDown, -}; - -const float PADDLE_SPEED = 1.0f; - - -//The window we'll be rendering to -SDL_Window* gWindow = NULL; - -//The renderer we'll be rendering to -SDL_Renderer* gRenderer = NULL; - -//The surface contained by the window -SDL_Surface* gScreenSurface = NULL; - - -SDL_Surface* loadSurface(std::string path) -{ - //The final optimized image - SDL_Surface* optimizedSurface = NULL; - - //Load image at specified path - SDL_Surface* loadedSurface = IMG_Load(path.c_str()); - if (loadedSurface == NULL) - { - printf("Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError()); - } - else - { - //Convert surface to screen format - optimizedSurface = SDL_ConvertSurface(loadedSurface, gScreenSurface->format, 0); - if (optimizedSurface == NULL) - { - printf("Unable to optimize image %s! SDL Error: %s\n", path.c_str(), SDL_GetError()); - } - - //Get rid of old loaded surface - SDL_FreeSurface(loadedSurface); - } - - return optimizedSurface; -} - -class Vec2 -{ -public: - Vec2() - : x(0.0f), y(0.0f) - {} - - Vec2(float x, float y) - : x(x), y(y) - {} - - Vec2 operator+(Vec2 const& rhs) - { - return Vec2(x + rhs.x, y + rhs.y); - } - - Vec2& operator+=(Vec2 const& rhs) - { - x += rhs.x; - y += rhs.y; - - return *this; - } - - Vec2 operator*(float rhs) - { - return Vec2(x * rhs, y * rhs); - } - - float x, y; -}; - -const int BALL_WIDTH = 15; -const int BALL_HEIGHT = 15; - -class Ball -{ -public: - Ball(Vec2 position) - : position(position) - { - rect.x = static_cast(position.x); - rect.y = static_cast(position.y); - rect.w = BALL_WIDTH; - rect.h = BALL_HEIGHT; - } - - void Draw(SDL_Renderer* renderer) - { - rect.x = static_cast(position.x); - rect.y = static_cast(position.y); - - SDL_RenderFillRect(renderer, &rect); - } - - Vec2 position; - SDL_Rect rect{}; -}; - - -const int PADDLE_WIDTH = 15; -const int PADDLE_HEIGHT = 80; -class Paddle -{ -public: - Paddle(Vec2 position, Vec2 velocity) - : position(position), velocity(velocity) - { - rect.x = static_cast(position.x); - rect.y = static_cast(position.y); - rect.w = PADDLE_WIDTH; - rect.h = PADDLE_HEIGHT; - } - - void Update(float dt) - { - position += velocity * dt; - - if (position.y < 0) - { - // Restrict to top of the screen - position.y = 0; - } - else if (position.y > (WINDOW_HEIGHT - PADDLE_HEIGHT)) - { - // Restrict to bottom of the screen - position.y = WINDOW_HEIGHT - PADDLE_HEIGHT; - } - } - - void Draw(SDL_Renderer* renderer) - { - rect.y = static_cast(position.y); - - SDL_RenderFillRect(renderer, &rect); - } - - Vec2 position; - Vec2 velocity; - SDL_Rect rect{}; -}; - -class Sprite -{ -public: - Sprite(Vec2 position, std::string path) - : position(position) - { - rect.x = static_cast(position.x); - rect.y = static_cast(position.y); - rect.w = PADDLE_WIDTH; - rect.h = PADDLE_HEIGHT; - - SDL_Surface* surface = loadSurface(path); - texture = SDL_CreateTextureFromSurface(gRenderer, surface); - SDL_FreeSurface(surface); - } - - void Draw() - { - rect.y = static_cast(position.y); - - //SDL_RenderFillRect(renderer, &rect); - SDL_RenderCopy(gRenderer, texture, NULL, &rect); - } - - Vec2 position; - std::string path; - SDL_Rect rect{}; - SDL_Texture* texture; -}; - -class PlayerScore -{ -public: - PlayerScore(Vec2 position, SDL_Renderer* renderer, TTF_Font* font, SDL_Color scoreColor) - : renderer(renderer), font(font) - { - surface = TTF_RenderText_Solid(font, "0", scoreColor); - texture = SDL_CreateTextureFromSurface(renderer, surface); - - int width, height; - SDL_QueryTexture(texture, nullptr, nullptr, &width, &height); - - rect.x = static_cast(position.x); - rect.y = static_cast(position.y); - rect.w = width; - rect.h = height; - } - - ~PlayerScore() - { - SDL_FreeSurface(surface); - SDL_DestroyTexture(texture); - } - - void Draw() - { - SDL_RenderCopy(renderer, texture, nullptr, &rect); - } - - SDL_Renderer* renderer; - TTF_Font* font; - SDL_Surface* surface{}; - SDL_Texture* texture{}; - SDL_Rect rect{}; -}; - -int main(int argc, char* argv[]) -{ - // Initialize SDL components - SDL_Init(SDL_INIT_VIDEO); - TTF_Init(); - - gWindow = SDL_CreateWindow("Pong", 20, 20, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN); - gRenderer = SDL_CreateRenderer(gWindow, -1, 0); - - //Get window surface - gScreenSurface = SDL_GetWindowSurface(gWindow); - - // Initialize the font - TTF_Font* scoreFont = TTF_OpenFont("arial.ttf", 40); - - SDL_Color scoreColor = { 0xFF, 0xFF, 0xFF, 0xFF }; - - // Create the player score text fields - PlayerScore playerOneScoreText(Vec2(WINDOW_WIDTH / 4, 20), gRenderer, scoreFont, scoreColor); - - PlayerScore playerTwoScoreText(Vec2(3 * WINDOW_WIDTH / 4, 20), gRenderer, scoreFont, scoreColor); - - // Create the ball - Ball ball( - Vec2((WINDOW_WIDTH / 2.0f) - (BALL_WIDTH / 2.0f), - (WINDOW_HEIGHT / 2.0f) - (BALL_WIDTH / 2.0f))); - - // Create the paddles - Paddle paddleOne( - Vec2(50.0f, WINDOW_HEIGHT / 2.0f), - Vec2(0.0f, 0.0f)); - - Paddle paddleTwo( - Vec2(WINDOW_WIDTH - 50.0f, WINDOW_HEIGHT / 2.0f), - Vec2(0.0f, 0.0f)); - - Sprite randomAssSprite( - Vec2((WINDOW_WIDTH / 2.0f) - (100 / 2.0f), - (WINDOW_HEIGHT / 2.0f) - (100 / 2.0f)), "./circle.png"); - - - // Game logic - { - bool running = true; - bool buttons[4] = {}; - float dt = 0.0f; - - // Continue looping and processing events until user exits - while (running) - { - auto startTime = std::chrono::high_resolution_clock::now(); - - SDL_Event event; - while (SDL_PollEvent(&event)) - { - if (event.type == SDL_QUIT) - { - running = false; - } - else if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym == SDLK_ESCAPE) - { - running = false; - } - else if (event.key.keysym.sym == SDLK_w) - { - buttons[Buttons::PaddleOneUp] = true; - } - else if (event.key.keysym.sym == SDLK_s) - { - buttons[Buttons::PaddleOneDown] = true; - } - else if (event.key.keysym.sym == SDLK_UP) - { - buttons[Buttons::PaddleTwoUp] = true; - } - else if (event.key.keysym.sym == SDLK_DOWN) - { - buttons[Buttons::PaddleTwoDown] = true; - } - } - else if (event.type == SDL_KEYUP) - { - if (event.key.keysym.sym == SDLK_w) - { - buttons[Buttons::PaddleOneUp] = false; - } - else if (event.key.keysym.sym == SDLK_s) - { - buttons[Buttons::PaddleOneDown] = false; - } - else if (event.key.keysym.sym == SDLK_UP) - { - buttons[Buttons::PaddleTwoUp] = false; - } - else if (event.key.keysym.sym == SDLK_DOWN) - { - buttons[Buttons::PaddleTwoDown] = false; - } - } - } - - if (buttons[Buttons::PaddleOneUp]) - { - paddleOne.velocity.y = -PADDLE_SPEED; - } - else if (buttons[Buttons::PaddleOneDown]) - { - paddleOne.velocity.y = PADDLE_SPEED; - } - else - { - paddleOne.velocity.y = 0.0f; - } - - if (buttons[Buttons::PaddleTwoUp]) - { - paddleTwo.velocity.y = -PADDLE_SPEED; - } - else if (buttons[Buttons::PaddleTwoDown]) - { - paddleTwo.velocity.y = PADDLE_SPEED; - } - else - { - paddleTwo.velocity.y = 0.0f; - } - - // Update the paddle positions - paddleOne.Update(dt); - paddleTwo.Update(dt); - - // Clear the window to black - SDL_SetRenderDrawColor(gRenderer, 0x0, 0x0, 0x0, 0xFF); - SDL_RenderClear(gRenderer); - - // Set the draw color to be white - SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF); - - // Draw the net - for (int y = 0; y < WINDOW_HEIGHT; ++y) - { - if (y % 5) - { - SDL_RenderDrawPoint(gRenderer, WINDOW_WIDTH / 2, y); - } - } - - // Draw the ball - ball.Draw(gRenderer); - - // Draw the paddles - paddleOne.Draw(gRenderer); - paddleTwo.Draw(gRenderer); - - // Display the scores - playerOneScoreText.Draw(); - playerTwoScoreText.Draw(); - - randomAssSprite.Draw(); - - // Present the backbuffer - SDL_RenderPresent(gRenderer); - - // Calculate frame time - auto stopTime = std::chrono::high_resolution_clock::now(); - dt = std::chrono::duration(stopTime - startTime).count(); - } - } - - // Cleanup - SDL_DestroyRenderer(gRenderer); - SDL_DestroyWindow(gWindow); - TTF_CloseFont(scoreFont); - SDL_Quit(); - - return 0; -} \ No newline at end of file diff --git a/Slang/graphics.h b/Slang/graphics.h index 27a96fa..42e08dc 100644 --- a/Slang/graphics.h +++ b/Slang/graphics.h @@ -15,105 +15,329 @@ #include #include #include +#include +#include +#include +#include +#include -using namespace std; +int WINDOW_WIDTH = 1280; +int WINDOW_HEIGHT = 720; -class Parser +enum Buttons +{ + PaddleOneUp = 0, + PaddleOneDown, + PaddleTwoUp, + PaddleTwoDown, +}; + +const float PADDLE_SPEED = 1.0f; + + +//The window we'll be rendering to +SDL_Window* gWindow = NULL; + +//The renderer we'll be rendering to +SDL_Renderer* gRenderer = NULL; + +//The surface contained by the window +SDL_Surface* gScreenSurface = NULL; + +bool running = true; +bool buttons[4] = {}; +float dt = 0.0f; + +SDL_Surface* loadSurface(std::string path) +{ + //The final optimized image + SDL_Surface* optimizedSurface = NULL; + + //Load image at specified path + SDL_Surface* loadedSurface = IMG_Load(path.c_str()); + if (loadedSurface == NULL) + { + printf("Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError()); + } + else + { + //Convert surface to screen format + optimizedSurface = SDL_ConvertSurface(loadedSurface, gScreenSurface->format, 0); + if (optimizedSurface == NULL) + { + printf("Unable to optimize image %s! SDL Error: %s\n", path.c_str(), SDL_GetError()); + } + + //Get rid of old loaded surface + SDL_FreeSurface(loadedSurface); + } + + return optimizedSurface; +} + +class Vec2 { public: - int Start(int SCREEN_W, int SCREEN_H) + Vec2() + : x(0.0f), y(0.0f) + {} + + Vec2(float x, float y) + : x(x), y(y) + {} + + Vec2 operator+(Vec2 const& rhs) { - //// variable declarations - //SDL_Window* win = NULL; - //SDL_Renderer* renderer = NULL; - //int w, h; // texture width & height + return Vec2(x + rhs.x, y + rhs.y); + } - //// Initialize SDL. - //if (SDL_Init(SDL_INIT_VIDEO) < 0) - // return 1; + Vec2& operator+=(Vec2 const& rhs) + { + x += rhs.x; + y += rhs.y; - //// create the window and renderer - //// note that the renderer is accelerated - //win = SDL_CreateWindow("Image Loading", 100, 100, SCREEN_W, SCREEN_H, 0); - //renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED); + return *this; + } - //// load our image - //SDL_Surface* imgSurface = IMG_Load("circle.png"); + Vec2 operator*(float rhs) + { + return Vec2(x * rhs, y * rhs); + } - //// main loop - //while (1) { + float x, y; +}; - // // event handling - // SDL_Event e; - // if (SDL_PollEvent(&e)) { - // if (e.type == SDL_QUIT) - // break; - // else if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_ESCAPE) - // break; - // } +class Sprite +{ +public: + Sprite(std::string path, Vec2 position, Vec2 scale, double angle) + : position(position), angle(angle) + { + rect.x = static_cast(position.x); + rect.y = static_cast(position.y); + rect.w = scale.x; + rect.h = scale.y; - // // clear the screen - // SDL_RenderClear(renderer); - // // copy the texture to the rendering context - // SDL_RenderCopy(renderer, img, NULL, &texr); - // // flip the backbuffer - // // this means that everything that we prepared behind the screens is actually shown - // SDL_RenderPresent(renderer); + SDL_Surface* surface = loadSurface(path); + texture = SDL_CreateTextureFromSurface(gRenderer, surface); + SDL_FreeSurface(surface); + } - //} + void Draw() + { + rect.y = static_cast(position.y); - //SDL_DestroyTexture(img); - //SDL_DestroyRenderer(renderer); - //SDL_DestroyWindow(win); + SDL_RenderCopy(gRenderer, texture, NULL, &rect); + } - //return 0; + Vec2 position; + double angle; + std::string path; + SDL_Rect rect{}; + SDL_Texture* texture; +};/* + +class PlayerScore +{ +public: + PlayerScore(Vec2 position, SDL_Renderer* renderer, TTF_Font* font, SDL_Color scoreColor) + : renderer(renderer), font(font) + { + surface = TTF_RenderText_Solid(font, "0", scoreColor); + texture = SDL_CreateTextureFromSurface(renderer, surface); + + int width, height; + SDL_QueryTexture(texture, nullptr, nullptr, &width, &height); + + rect.x = static_cast(position.x); + rect.y = static_cast(position.y); + rect.w = width; + rect.h = height; + } + + ~PlayerScore() + { + SDL_FreeSurface(surface); + SDL_DestroyTexture(texture); + } + + void Draw() + { + SDL_RenderCopy(renderer, texture, nullptr, &rect); + } + + SDL_Renderer* renderer; + TTF_Font* font; + SDL_Surface* surface{}; + SDL_Texture* texture{}; + SDL_Rect rect{}; +};*/ + +int cleanupGraphics() +{ + // Cleanup + SDL_DestroyRenderer(gRenderer); + SDL_DestroyWindow(gWindow); + SDL_Quit(); + + return 0; +} +int updateLoop() +{ + // Continue looping and processing events until user exits + while (running) + { + auto startTime = std::chrono::high_resolution_clock::now(); - ////Initialize SDL - //if (SDL_Init(SDL_INIT_VIDEO) < 0) + SDL_Event event; + while (SDL_PollEvent(&event)) + { + if (event.type == SDL_QUIT) + { + running = false; + } + else if (event.type == SDL_KEYDOWN) + { + if (event.key.keysym.sym == SDLK_ESCAPE) + { + running = false; + } + else if (event.key.keysym.sym == SDLK_w) + { + buttons[Buttons::PaddleOneUp] = true; + } + else if (event.key.keysym.sym == SDLK_s) + { + buttons[Buttons::PaddleOneDown] = true; + } + else if (event.key.keysym.sym == SDLK_UP) + { + buttons[Buttons::PaddleTwoUp] = true; + } + else if (event.key.keysym.sym == SDLK_DOWN) + { + buttons[Buttons::PaddleTwoDown] = true; + } + } + else if (event.type == SDL_KEYUP) + { + if (event.key.keysym.sym == SDLK_w) + { + buttons[Buttons::PaddleOneUp] = false; + } + else if (event.key.keysym.sym == SDLK_s) + { + buttons[Buttons::PaddleOneDown] = false; + } + else if (event.key.keysym.sym == SDLK_UP) + { + buttons[Buttons::PaddleTwoUp] = false; + } + else if (event.key.keysym.sym == SDLK_DOWN) + { + buttons[Buttons::PaddleTwoDown] = false; + } + } + } + + //if (buttons[Buttons::PaddleOneUp]) //{ - // printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError()); + // paddleOne.velocity.y = -PADDLE_SPEED; + //} + //else if (buttons[Buttons::PaddleOneDown]) + //{ + // paddleOne.velocity.y = PADDLE_SPEED; //} //else //{ - // //Create window - // window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, SDL_WINDOW_SHOWN); - // if (window == NULL) - // { - // printf("Window could not be created! SDL_Error: %s\n", SDL_GetError()); - // } - // else - // { - // //Get window surface - // screenSurface = SDL_GetWindowSurface(window); - - // while (OnUpdate() == 0) - // { - // //Fill the surface white - // SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0x00, 0x00)); - // - // //Update the surface - // SDL_UpdateWindowSurface(window); - // } - // } + // paddleOne.velocity.y = 0.0f; //} - ////Destroy window - //SDL_DestroyWindow(window); + //if (buttons[Buttons::PaddleTwoUp]) + //{ + // paddleTwo.velocity.y = -PADDLE_SPEED; + //} + //else if (buttons[Buttons::PaddleTwoDown]) + //{ + // paddleTwo.velocity.y = PADDLE_SPEED; + //} + //else + //{ + // paddleTwo.velocity.y = 0.0f; + //} - //Quit SDL subsystems - SDL_Quit(); + //// Update the paddle positions + //paddleOne.Update(dt); + //paddleTwo.Update(dt); + + // Clear the window to black + SDL_SetRenderDrawColor(gRenderer, 0x0, 0x0, 0x0, 0xFF); + SDL_RenderClear(gRenderer); + + // Set the draw color to be white + SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF); + + // Draw the net + for (int y = 0; y < WINDOW_HEIGHT; ++y) + { + if (y % 5) + { + SDL_RenderDrawPoint(gRenderer, WINDOW_WIDTH / 2, y); + } + } + + //// Draw the ball + //ball.Draw(gRenderer); + + //// Draw the paddles + //paddleOne.Draw(gRenderer); + //paddleTwo.Draw(gRenderer); + + //// Display the scores + //playerOneScoreText.Draw(); + //playerTwoScoreText.Draw(); + + //randomAssSprite.Draw(); + + // Present the backbuffer + SDL_RenderPresent(gRenderer); + + // Calculate frame time + auto stopTime = std::chrono::high_resolution_clock::now(); + dt = std::chrono::duration(stopTime - startTime).count(); return 0; } +} - int OnUpdate() - { - ExecuteFunction("Update", vector()); - //cout << "update" << endl; - return 0; - } -}; +int initGraphics(std::string windowTitle, int width, int height) +{ + WINDOW_WIDTH = width; + WINDOW_HEIGHT = height; + + // Initialize SDL components + SDL_Init(SDL_INIT_VIDEO); + TTF_Init(); + + gWindow = SDL_CreateWindow(windowTitle.c_str(), 40, 40, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN || SDL_WINDOW_RESIZABLE); + gRenderer = SDL_CreateRenderer(gWindow, -1, 0); + + //Get window surface + gScreenSurface = SDL_GetWindowSurface(gWindow); + + //Sprite randomAssSprite( + // Vec2((WINDOW_WIDTH / 2.0f) - (100 / 2.0f), (WINDOW_HEIGHT / 2.0f) - (100 / 2.0f)), + // Vec2(100, 100), + // 0, + // "./circle.png"); + + updateLoop(); + + cleanupGraphics(); + + return 0; +} #endif \ No newline at end of file diff --git a/Slang/script.slg b/Slang/script.slg index bf0a213..3f36268 100644 --- a/Slang/script.slg +++ b/Slang/script.slg @@ -2,7 +2,6 @@ func Main(input, in) { - print "PI is: " + PI int x = 1 print x @@ -18,9 +17,9 @@ func Main(input, in) x += 1 } - - NewCircle(0, 0, 5) - CPP.Graphics.Init(64, 64) + Vec2 aa = Vec2(0, 0) + Sprite thisisasprite = CPP.Graphics.Sprite("circle.png", aa, aa, 0) + //CPP.Graphics.Init("This is a pong game", 64, 64) } func Update(input)