diff --git a/font.ttf b/font.ttf new file mode 100644 index 0000000..04e56b9 Binary files /dev/null and b/font.ttf differ diff --git a/main.cpp b/main.cpp index 32e1428..7c8de6e 100644 --- a/main.cpp +++ b/main.cpp @@ -5,23 +5,43 @@ int main() { - int windowWidth = 1200; - int windowHeight = 800; + // Global Variables + int windowWidth = 700; + int windowHeight = 700; - int sideBarWidth = 400; - int titleHeight = 100; + int sideBarGap = 50; + int titleHeight = 75; int width = 600; int height = 600; int size = 40; - int x = width / size; - int y = height / size; + // Game Variables + bool paused = false; + // Create the main window sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight), "Game of Life"); + window.setKeyRepeatEnabled(false); + + // Create Grid + int x = width / size; + int y = height / size; + + Grid grid(size, sideBarGap, titleHeight, x, y); - Grid grid(size, sideBarWidth, titleHeight, x, y); + // Create Font + sf::Font font; + font.loadFromFile("font.ttf"); + + // Title Text + sf::Text title; + title.setFont(font); + title.setString("Game Of Life"); + title.setCharacterSize(32); + title.setPosition(windowWidth / 2 - 100, 15); + + // Create Clock sf::Clock clock; // Main Loop while (1 == window.isOpen()) @@ -34,11 +54,22 @@ int main() { window.close(); } + + if (event.type == sf::Event::KeyPressed) + { + if (event.key.code == sf::Keyboard::P) + { + paused = !paused; + } + } } window.clear(sf::Color::Black); - if (clock.getElapsedTime().asSeconds() > 1.0f) + // Draw Text + window.draw(title); + + if (clock.getElapsedTime().asSeconds() > 1.0f && !paused) { grid.update(); clock.restart(); diff --git a/main.o b/main.o index e4ad7b0..4760099 100644 Binary files a/main.o and b/main.o differ diff --git a/run b/run index 2ac3af2..877cf2d 100755 Binary files a/run and b/run differ