CSCI 261 - Programming Concepts (C++)Spring 2017 - Lab 09Quick Links: Blackboard | Canvas | CS @ Mines | Cloud9 | Piazza | zyBooks |
|
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |
This lab is due by April
03, 2016 11:59pm.
ConceptsFor 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 requires
graphics and/or sound effects. 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 documentation.
Before you Begin
For this specific lab you should download this project template
that has initial code and other resource files for you to get started.
This file should work with Visual Studio 2015 (on campus or on your
home computer). If you are not using Visual Studio (e.g. CodeBlocks,
XCode, Eclipse, etc.), then it is your responsibility to install SFML
for your chosen IDE. We will be grading these SFML assignments against
Visual Studio so be sure your code works with the template provided on
the lab computers.
Start the extraction process now, and then read the rest of these instructions (as the extraction process might take some time). Say what? How do I "extract"? First, save the file linked above to your Z drive Note: we will always assume you are working on a Mines computer. It is your responsibility to modify these instructions if not.
After you've downloaded the zip file, you need to extract the contents.
(We always use Windows Explorer to move and extract contents of a zip
file.) You can extract the contents of the zip file anywhere onto your
Z drive, but it must be on your Z drive (might as well put it
into your CSCI261 folder).
The next step is the most important in the process ... please be careful! ![]() Open and Run the Project
Instructions
First, take a look at the
main.cpp
file provided in the SFML template. 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.
The complete code is available here. A few key lines of
code covered follow:
// 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 ); // Draw a text object called label Font myFont; if( !myFont.loadFromFile( "data\\arial.ttf" ) ) return -1; Text label; label.setFont( myFont ); label.setString( "Hello World!" ); label.setPosition( 250, 520 ); label.setColor( 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!
Possible Extra CreditYou can earn 2 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 loop:
while (window.isOpen()) {
// ADD SEVERAL DRAW COMMANDS HERE // Apply all the draws to the screen window.display(); } To create an animation, you only need
to change the draw commands a small amount that are executed on a given
loop. Try it!
Lab Submission
You will submit your solution to this lab with the rest of Week09.
Detailed instructions for doing this are posted in Assignment 09.
Remember your smiley face solution for Assignment
01? You've sure come a long way since then! Do you recall how we
had a prize for the best smiley face
submitted in all sections (a Free HW)? That was cool. Let's do this
again for Lab09. That is, we'll have a prize for the best Lab09
submitted in all sections. Good luck!
This lab is due by April
03, 2016 11:59pm.
| |
Last Updated: 01/01/70 00:00
|