TI-S2

Opdrachten Classes C++

Inhoud

Deze opdracht kan nog veranderen!

Opdracht OO1.51 SFML window

Installeer SFML met de packetmanager (dankzij Lia E.):

Opdracht OO1.52 Rechthoek

Tips

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