Commit c87fff34 authored by Jonas Johan Solsvik's avatar Jonas Johan Solsvik 🎮
Browse files

Add 02-jumping-boxes

parent 53d46d71
#include <cstdio>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
int main()
{
// # Create the main window and camera
//
// ## TODO
// - [ ] Make framerate limit adjustable
// - [ ] Make video and camera size the same as hardware window size
// - [ ] Resize video and camera size when user resizes window.
//
const int WIDTH = 800;
const int HEIGHT = 600;
const int FRAMERATE_LIMIT = 90;
sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "Double trouble");
window.setFramerateLimit(FRAMERATE_LIMIT);
sf::View camera(sf::FloatRect(0, 0, WIDTH, HEIGHT));
camera.setCenter(0, 0);
window.setView(camera);
// # Create things
sf::CircleShape circle;
circle.setPosition(0, 0);
circle.setRadius(10);
circle.setFillColor(sf::Color::Red);
while (window.isOpen())
{
// # Process events
sf::Event event;
while (window.pollEvent(event))
{
// ## Close window on exit
if (event.type == sf::Event::Closed ||
event.type == sf::Event::KeyPressed &&
event.key.code == sf::Keyboard::Escape)
{
window.close();
}
}
// # Render video
window.clear();
window.draw(circle);
window.display();
}
return 0;
}
......@@ -4,9 +4,12 @@ cmake_minimum_required (VERSION 3.16.3 FATAL_ERROR)
set(SRCDIR "${CMAKE_SOURCE_DIR}")
set(BINDIR ${CMAKE_BINARY_DIR})
set(SFML_USE_STATIC_STD_LIBS TRUE)
add_subdirectory("./external/sfml")
set(targets
set(
targets
01-red-circle
02-jumping-boxes
)
foreach(target ${targets})
......@@ -21,7 +24,6 @@ foreach(target ${targets})
LIBRARY_OUTPUT_DIRECTORY "${BINDIR}/bin"
)
add_subdirectory("./external/sfml")
target_link_libraries(
${target}
PRIVATE sfml-window
......
......@@ -9,4 +9,10 @@ all:
make -C build;
./build/01-red-circle;
.PHONY: 01 all
02:
mkdir -p build;
cmake --target 02-jumping-boxes -S . -B build;
make -C build;
./build/02-jumping-boxes;
.PHONY: 01 02 all
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment