Files
2018-04-11 00:32:18 -07:00

50 lines
1.4 KiB
Plaintext

// In this assignment I used SFML a simple multimedia framework for C++ and other languages
// It can be found at https://www.sfml-dev.org
// It's lience is found here https://www.sfml-dev.org/license.php
// I am using the library well within the confines of it's license
// import the standard library for VC++
#include "stdafx.h"
// import the SFML graphics library
#include <SFML/Graphics.hpp>
int main()
{
// initialize a render window 200 by 200 pixels
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
// create a shape using sfml's convexshape class
sf::ConvexShape convex;
// set it's color to green
convex.setFillColor(sf::Color::Green);
// give the shape 3 points
convex.setPointCount(3);
// Set the point coordinates as per the assignment
convex.setPoint(0, sf::Vector2f(50, 20));
convex.setPoint(1, sf::Vector2f(30, 60));
convex.setPoint(2, sf::Vector2f(70, 60));
// loop to render the shape on the window
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
// these 3 commands are what draw the triangle to the screen in the loop
window.clear();
window.draw(convex);
window.display();
}
// the main function returns 0 to indicate to the OS that it has exited successfully.
return 0;
}