CSCI 261 - Programming Concepts (C++)Summer 2018 - Lab 9A - PicassoQuick Links: Canvas | CS @ Mines | Piazza | zyBooks |
|
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |
This lab is due by Tuesday, June 19, 2018, 11:59 PM. 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 2.5.0 documentation.
Instructions
First, take a look at the
main.cpp
file provided in the provided SFML template.
Be sure to start with the template as it will automatically link against the SFML
library for you. 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 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.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!
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!
Remember your smiley face solution for Assignment
1? 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 debug duck)? That was cool. Let's do this
again for Lab9A. That is, we'll have a prize for the best Lab9A
submitted in all sections. Good luck!
Lab SubmissionYou will submit your solution to this lab with the rest of Set9. Detailed instructions for doing this are posted in Assignment 9. This lab is due by Tuesday, June 19, 2018, 11:59 PM. | |
Last Updated: 06/11/18 22:26
|