Finally fixed scale constants
authorNils Forssén <nilfo359@student.liu.se>
Thu, 9 Nov 2023 14:12:29 +0000 (15:12 +0100)
committerNils Forssén <nilfo359@student.liu.se>
Thu, 9 Nov 2023 14:12:29 +0000 (15:12 +0100)
src/Object.cc [deleted file]
src/_main.cc

diff --git a/src/Object.cc b/src/Object.cc
deleted file mode 100644 (file)
index e69de29..0000000
index b77518e5cd9eb77cd8d1106915b4cfec5f0dcbf0..47a590372bbdaed2acc789b86efed4e579b59390 100644 (file)
@@ -6,33 +6,33 @@
 
 #include <SFML/Graphics.hpp> // includes most things in SFML
 
-using namespace sf;
+const unsigned int S_WIDTH {1280};
+const unsigned int S_HEIGHT {720};
 
-static const int s_width {1280};
-static const int s_height {720};
-
-static const int scale_koeff {s_width / 1920};
+const double S_SCALE_KOEFF {s_width / 1920.0};
 
 int main ()
 {
-    RenderWindow window{
-        VideoMode{s_width, s_height},
+    sf::RenderWindow window{
+        sf::VideoMode{S_WIDTH, S_HEIGHT},
         "DespYrat"
     };
 
-    Texture t;
+
+    sf::Texture t;
     t.loadFromFile("assets/hel_bakgrund.png");
-    Sprite s(t);
-    s.setScale(0.6666667, 0.6666667);
+    sf::Sprite s(t);
+
+    s.setScale(S_SCALE_KOEFF, S_SCALE_KOEFF);
     
     while (window.isOpen())
     {
         /* hantera events */
-        Event event;
+        sf::Event event;
         // hämta ett event i taget
         while (window.pollEvent(event))
         {
-            if (event.type == Event::Closed)
+            if (event.type == sf::Event::Closed)
             {
                 window.close();
             }