CSCI 200 - Fall 2024
Foundational Programming Concepts & Design

Lab 4C - SFML: Bob Ross

This lab is due by Friday, November 01, 2024, Before Class.
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.

Jump To: Rubric Submission


Concepts


For this assignment, you have the opportunity to play with the power that SFML (a special framework called Simple and Fast Multimedia Library) offers.


SFML


SFML is a multimedia Application Programming Interface (API) written in C++ with bindings for various programming languages, including Java, Python, and Ruby. SFML provides an easy way to write code that utilizes graphics, sound effects, and/or networking. SFML is the chosen platform for many cool games, including the Atom Zombie Smasher. You can check out everything SFML has to offer by reading the SFML 2.6.1 documentation.


Setup


The first step is to download the source code from SFML from the SFML Download Page. Be sure to download the zip for the Source Code and not an OS specific package. This is at the bottom of the page. Once downloaded, unzip the package.

Next, download the cross-platform Makefile package. Once downloaded, unzip the package and place the contents inside the SFML-2.6.1 folder from the above step alongside the readme.md file.

Now in a terminal, navigate into the SFML-2.6.1 folder and type make.

This Makefile will build each of the necessary libraries. If you receive errors during this step, please post to the corresponding post on Ed matching your operating system. YMMV in this process but we are here to help!

Once successfully built, you'll now need to copy the library files to your installation. First, you'll need to copy the include/ headers that declare all the classes within the library. Next, you'll need to copy the precompiled library files. Finally, you'll need to copy the runtime files. Where each of these go will depend on operating system:


Instructions


Download the SFML Template. This will create an empty window to start working with. First, take a look at the main.cpp file provided. In class, we discussed each of the commands shown (e.g., creation of the window object and the polling for events); ask questions if there is any confusion.

Second, we also saw the development of a smiley face in class today. A few key lines of code covered follow:

// Draw a circle object called face and color it yellow
CircleShape face;
face.setPosition( 15, 15 );
face.setRadius( 300 );
face.setFillColor( Color::Yellow );
window.draw( face );
        
// Draw a rectangle object called eye and color it blue
RectangleShape eye;
eye.setSize( Vector2f( 45, 150 ) );
eye.setPosition( 200, 150 );
eye.setFillColor( Color(0, 0, 255));
window.draw( eye );
         
// Draw a text object called label
// place in file loading section
Font myFont;
if( !myFont.loadFromFile( "data/arial.ttf" ) )
    return -1;
// place in drawing section
Text label;
label.setFont( myFont );
label.setString( "Hello World!" );
label.setPosition( 250, 520 );
label.setFillColor( Color::Black );
window.draw( label ); 

Your job is to draw something in SFML. What you draw can be anything you want EXCEPT a smiley face (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!


Grading Rubric


Your submission will be graded according to the following rubric:

PointsRequirement Description
0.70Fully meets specifications
0.15Submitted correctly by Friday, November 01, 2024, Before Class
0.15Best Practices and Style Guide followed
1.00Total Points


Lab Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.

Zip together your main.cpp, Makefile, data/* file(s) and name the zip file L4C.zip. Upload this zip file to Canvas under L4C.

This lab is due by Friday, November 01, 2024, Before Class.
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.