Deze opdracht kan nog veranderen!
Installeer SFML met de packetmanager (dankzij Lia E.):
Bestudeer de SFML shapes library.
Schrijf een programma dat een rechthoek in een window afbeeldt.
Hieronder staat voorbeeldcode die misschien behulpzaam is.
/// @file main.cpp - incomplete code
/// exercise: draw a SFML rectangle
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>
int main ()
{
// the window in which we want to print the line
sf::RenderWindow window (sf::VideoMode (800, 600), "My window", sf::Style::Default, sf::ContextSettings (0, 0, 2));
// Todo: define a sfml rectangle, e.g. named rshape, located at (4, 2) with a size of 120x50
// ... rshape ...;
// run the program as long as the window is open
while (window.isOpen ())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
// window.display ();
while (window.pollEvent (event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
window.close ();
}
// clear the window
window.clear ();
// Todo: draw the sfml rectangle - uncomment the next line
// window.draw (rshape);
window.display ();
// voorkom gebibber op het scherm
sf::sleep (sf::milliseconds (20));
}
return 0;
}
main.cpp