Advertisement
sbloom85

main.cpp

Jan 27th, 2023
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. /*
  2.  * Classy Clash
  3.  * Project from GameDev.TV using alternate assets
  4.  * Scott Bloom
  5.  */
  6.  
  7. #include "raylib.h"
  8. #include "raymath.h"
  9. #include "Character.h"
  10.  
  11. int main()
  12. {
  13.     int windowDimensions[2]{384, 384};
  14.  
  15.     InitWindow(windowDimensions[0], windowDimensions[1], "Classy Clash");
  16.  
  17.     // Create Textures
  18.     Texture2D worldMap = LoadTexture("nature_tileset/OpenWorldMap24x24.png");
  19.     // Texture2D swordUp = LoadTexture("characters/weapon_sword.png");
  20.     // Texture2D swordDown = LoadTexture("characters/weapon_sword_1.png");
  21.     // End Create Textures
  22.  
  23.     // Draw Map
  24.     Vector2 mapPos{0.0, 0.0};
  25.     const float mapScale{4.f};
  26.  
  27.     SetTargetFPS(60);
  28.  
  29.     Character knight;
  30.     knight.setScreenPos(windowDimensions[0], windowDimensions[1]);
  31.     while (!WindowShouldClose())
  32.     {
  33.         BeginDrawing();
  34.         ClearBackground(WHITE);
  35.  
  36.         // Begin Game Logic
  37.         mapPos = Vector2Scale(knight.getWorldPos(), -1.f);
  38.  
  39.         // Draw Map
  40.         DrawTextureEx(worldMap, mapPos, 0.0, mapScale, WHITE);
  41.         knight.tick(GetFrameTime());
  42.  
  43.         // Check Map Bounds
  44.         if (knight.getWorldPos().x < 0.f ||
  45.             knight.getWorldPos().y < 0 ||
  46.             knight.getWorldPos().x + windowDimensions[0] > worldMap.width * mapScale ||
  47.             knight.getWorldPos().y + windowDimensions[1] > worldMap.height * mapScale)
  48.         {
  49.             knight.undoMovement();
  50.         }
  51.  
  52.         // End Game Logic
  53.  
  54.         EndDrawing();
  55.     }
  56.     CloseWindow();
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement