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

Merge branch 'open-window' into 'master'

Fix #6, #7 and #8 - Open window, draw and move circle + collsion example

Closes #8, #7, and #6

See merge request !1
parents 4406e0d6 40ac3f77
build/
.vscode/
[submodule "external/sfml"]
path = external/sfml
url = https://github.com/SFML/SFML
#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;
}
## 02-jumping-boxes
Introducing rudimentary physics.
\ No newline at end of file
This diff is collapsed.
project(double-trouble)
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
01-red-circle
02-jumping-boxes
)
foreach(target ${targets})
add_executable(${target} "${SRCDIR}/${target}/main.cpp")
set_target_properties(
${target}
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
RUNTIME_OUTPUT_DIRECTORY "${BINDIR}"
LIBRARY_OUTPUT_DIRECTORY "${BINDIR}/bin"
)
target_link_libraries(
${target}
PRIVATE sfml-window
PRIVATE sfml-graphics
PRIVATE sfml-audio
)
endforeach()
.PHONY: 01 02 all
all:
mkdir -p build;
cmake -S . -B build;
make -C build;
01:
mkdir -p build;
cmake --target 01-red-circle -S . -B build;
make -C build;
./build/01-red-circle;
02:
mkdir -p build;
cmake --target 02-jumping-boxes -S . -B build;
make -C build;
./build/02-jumping-boxes;
# Double Trouble
A IMT3601 Games Programming project by Jonas and Viktor
\ No newline at end of file
A IMT3601 Games Programming project by Jonas and Viktor
## Getting started
To build all:
```
make
```
To build and run a specific game:
```
make 01 # To run 01-red-circle
make 02 # To run 02-jumping-boxes
```
_See `Makefile` for complete list of commands_
## System requirements
### Ubuntu and Pop!\_OS 20.04
```
sudo apt install \
cmake \
libflac-dev \
libvorbis-dev \
libopenal-dev \
libudev-dev;
```
Subproject commit 241b542ca30751e9283230288b4d704fe3e80981
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