CSCI 200 - Spring 2025
Foundational Programming Concepts & Design

Lab 4C - SFML: Bob Ross

This lab is due by Friday, March 28, 2025, 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.2 documentation.


Setup


Based on your operating system and compiler version that you are using, the installation process will vary. Use the following links to jump to the appropriate section.

Windows with class MinGW provided in L0

Attempting to build SFML from source will fail due to the versions of the prepackaged dependencies included with the SFML source code. We have patched these dependencies provided the prebuilt SFML library files. Download the Prebuilt SFML Library Package and extract on your machine. Next, you'll need to copy the precompiled library and runtime files:

  1. Find your MinGW installation folder (likely C:/mingw64 or similar). Copy the entire SFML folder from ~/SFML_Package/include to the ~/mingw64/x86_64-w64-mingw32/include folder contained within the MinGW folder (if the x86_64-w64-mingw32 folder does not exist, then place the SFML folder inside of the include folder in ~/mingw64/include. You should now have the location ~/include/SFML/ inside of MinGW.
  2. Find your MinGW installation folder (likely C:/mingw64 or similar). Copy the five libsfml-*.a files from ~/SFML_Package/lib to the ~/mingw64/lib folder contained within the MinGW folder.
  3. Find your MinGW installation folder (likely C:/mingw64 or similar). Copy the five sfml-*.dll files from ~/SFML_Package/bin to the ~/mingw64/bin folder contained within the MinGW folder so they reside alongside the g++ program.

Proceed down to the Instructions portion of the lab.

Windows with a different version of MinGW

macOS

The first step is to download the source code from SFML from the SFML v2.6.2 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.2 folder from the above step alongside the readme.md file.

Now in a terminal, navigate into the SFML-2.6.2 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:

Proceed down to the Instructions portion of the lab.

Linux

Attention Linux users: you are encouraged to get SFML from your distro specific package manager. If you're running Linux, then we trust/hope you know what you're doing and why. Proceed down to the Instructions portion of the lab.


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 using at least five shape objects. 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, March 28, 2025, 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, March 28, 2025, 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.