CSCI 261 - Programming Concepts - Spring 2022

Lab 7A - SFML Drawing

This lab is due by Thursday, May 05, 2022, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.


SFML


Your job is to draw something in SFML. What you draw can be anything you want (e.g., a tree, a bike, a dog, a word using rectangles/circles, etc.). For full credit, you must draw at least five shapes. Be creative and have fun!

Examples of how to draw circles and rectangles are shown below. There is also the possibility to display a ConvexShape to connect a series of points. It's also possible to display text or images. Refer to the SFML Documentation to draw more complex things.

// Draw a circle object called star and color it yellow
CircleShape star;
star.setPosition( 15, 15 );
star.setRadius(300 );
star.setFillColor( Color::Yellow );
window.draw( star);
        
// Draw a rectangle object called rect and color it blue
RectangleShape rect;
rect.setSize( Vector2f( 45, 150 ) );
rect.setPosition( 200, 150 );
rect.setFillColor( Color(0, 0, 255));
window.draw( rect );

Possible Extra Credit


You can earn 5 points of extra credit if the item you draw actually moves (yes, is animated - awesome!). Animation in SFML is actually easier than you might think. As you know, you add all your draw commands in the window draw loop:

while (window.isOpen()) {
    // ADD SEVERAL DRAW COMMANDS HERE
         
    // Apply all the draws to the screen
    window.display();
} 

To create an animation, instead of hardcoding in constant values you only need to change the draw commands a small amount that are executed on a given loop. Try it!


Lab Submission


Submit your main.cpp and any additional file(s).

You will submit your solution to this lab with the rest of Set7. Detailed instructions for doing this are posted in Assignment 7.


This lab is due by Thursday, May 05, 2022, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.