Basic SFML Moving a Sprite
|
|
- Audrey Hoover
- 6 years ago
- Views:
Transcription
1 Basic SFML Moving a Sprite This sample program is a basic SFML program allowing the user to move a sprite around a screen by using the keyboard. 1. Download the zip file associated with this lecture. This file is named graphics.zip and it contains a folder with two images inside the folder. 2. Create a new project in either Visual Studio or CodeBlock and name it movesprite 3. Visual Studio unzip the graphics.zip file in the project folder. This is the folder containing the project file movesprite.vcxproj. 4. CodeBlocks unzip the graphics.zip file in the project folder. This is the folder containing the project file movesprite.cbp. 5. Enter the following code: #include <SFML/Graphics.hpp> using namespace sf; # using stdafx.h for Visual Studio int main() // set framerate const unsigned int FPS = 60; // setup screen VideoMode vm(1024,768); RenderWindow window(vm, "SFML works!"); window.setframeratelimit(fps); // create textures Texture backt, carrott; backt.loadfromfile("graphics/background1.png"); carrott.loadfromfile("graphics/carrot.png"); // create sprites from textures Sprite bbb(backt); Sprite car(carrott); car.setorigin(carrott.getsize().x/2, carrott.getsize().y/2); float carspeed = 1.0f; // draw background bbb.setposition(0,0); // position carrot on screen in random position srand( (int)time(0)); int xpos =(int)(rand()%window.getsize().x); int ypos = (int)(rand()%window.getsize().y); while(xpos-car.getorigin().x<0 xpos+car.getorigin().x>window.getsize().x) xpos = (int)(rand()%window.getsize().x); while(ypos-car.getorigin().y<0 ypos+car.getorigin().y>window.getsize().y) ypos = (int)(rand()%window.getsize().y); car.setposition(xpos,ypos); Event evt;
2 while (window.isopen()) while(window.pollevent(evt)) if(evt.type==event::closed) window.close(); // check keyboard and move carrot if(keyboard::iskeypressed(keyboard::left)) car.move(-5.0f,0.0f); if(keyboard::iskeypressed(keyboard::right)) car.move(5.0f,0.0f); if(keyboard::iskeypressed(keyboard::up)) car.move(0.0f,-5.0f); if(keyboard::iskeypressed(keyboard::down)) car.move(0.0f,5.0f); window.clear(); window.draw(bbb); window.draw(car); window.display(); return 0; This code includes the following sections: A. Setup B. Initial Position C. Game Loop
3 Setup In this section the window is defined, the framerate capped, and the images are loaded. A const value named FPS is set to 60. This is then used (line 12) to set the window framerate. A video mode named vm is defined so the window will have the size 1024 X and 768 Y. This video mode is then used to create a RenderWindow (line 11) and the window then has it s framerate capped (12). Two texture object are then defined (backt, carrot) and each is loaded from the external file. Notice how the path name in the loadfromfile() method refers to the graphics folder in the project area. Sprites can only be defined once textures are loaded. Multiple sprites can share the same texture. The sprites are both defined and loaded with their associated textures on lines 20/21. The origin of a Sprite is the position in the sprite where drawing will start. The origin is also how the sprite will be positioned on the screen. In this case the Sprite car is setting its own Origin by dividing the size of the texture by 2 (Line 22). Notice how the texture.getsize() method returns a vector and not a specific number. The getsize() method returns an object of the type Vector2u which is a pair of unsigned integers that can be accessed with x and y. For example, in line 22 when the width of the sprite was accessed you could have written: Vector2u vsize = carrott.getsize(); car.setorigin(vsize.x/2, vsize.y/2); The sprite movement speed is then set to 1.0f in line 23. Finally, the background image is set to the upper left corner of the screen by using the statement in line 26.
4 Initial Position The next tasks is to set the carrot image on the screen in a random position. This entails getting a random pair of x/y numbers and using them in a setposition(x,y) statement. However, your program wants to make sure that the carrot image does not appear partially off the screen. Since the drawing point of the carrot image is the center of the image we want to make sure that it is not randomly drawn off the screen. This drawing logic is: I. Generate a pair of values for X and Y that is > 0 and less than the width or height of the window. II. Fixup the x/y values to prevent the carrot being drawn partially off the screen. III. Position the carrot. In order to create a pair of X/Y values that are inside the game window you would use the code: First, the random generator Seed is set. This is a value that ensures a more random result and it is done on line 29. The current time in milliseconds is used as the seed and it is returned by using the command (int) time(0) Once the seed has been set the actual values of xpos and ypos are generated by returning a random number with rand() and dividing this number by the window size and returning the remainder (lines 30,31). This ensures that the value of xpos and ypos can never be larger than the window size because the remainder of dividing a number into another number can never be larger than the original number (100%51 is 49). One you have a pair of random numbers for the x/y positions, you must fixup these numbers so they keep the sprite inside the boundary of the window. This is done by checking the position values and generating new ones if the sprite position is off screen to the left or right. In order for the sprite to be offscreen to the left the xpos the sprite width/2 must be zero or less. The value of getorigin().x is the center point of the sprite and represents the width divided by 2. Same with the height. The while() statement keeps generating xpos and ypos values as long as the value is either off to the left or off to the right (xpos minus half the width must be greater than 0 and xpos plus half the width must be less than the window width. Finally, the carrot sprite is set in position with setposition(xpos,ypos).
5 Game Loop The game loop is where everything happens First, an event object is defined in line 41. The game loop starts on line 43. While the window flag returned by isopen() is true then the game loop continues. On lines 45 to 49 the queue of Events returned by the Window is checked. This is done by retrieving the event object from the pollevent() method into the Event object evt. Then, if the event object is a Closed event then the window is closed(). Below the Event loop are a series of checks on the keyboard. These are written to check the Keyboard object and are written in the format: if( Keyboard::isKeyPressed ( Keyboard:: Left) ) The Keyboard class has a static method named iskeypressed() that, when passed a Keyboard value (Keyboard::Left) returns a boolean value as long as this key is being pressed. If the key is being pressed then the sprite move() method is used:
6 car.move( vx, vy); This move method does not set the position of the sprite but adds a number to the x/y values and then calls a setposition(). If you were to write your own move command it would look like: public void MoveSprite( Sprite s, float movex, float movey) float xpos = s.getposition().x; float ypos = s.getposition().y; xpos += movex; ypos += movey; s.setposition( xpos, ypos ); You would pass either positive or negative values to this method. This is what is being implemented with the move() command. Finally, the window is cleared and the two sprites are drawn. Make sure that the background is always drawn first otherwise it will draw over any other graphic object.
Fixed Rate Clocks. The logic for this code is:
Fixed Rate Clocks In the previous lecture we learned how to create a game using the delta time between frames by using the Clock and Time objects in SFML. Basically, the logic is: 1. Set a movement speed
More informationCreating an Animated Image in SFML Creating Packed Images in SFML
Creating an Animated Image in SFML Creating Packed Images in SFML 1. Download the file names spritesheettools.zip and unzip this folder. It will be named spritesheettools 2. Inside this folder you will
More information제 16 장 SFML 로작성해보는 프로젝트 II 1. 상속을사용하여게임에필요한클래스를설계할수있다.
제 16 장 SFML 로작성해보는 프로젝트 II 1. 상속을사용하여게임에필요한클래스를설계할수있다. 이번장에서만들어볼프로그램 소스 step #1 #include using namespace std; using namespace sf; int main() RenderWindow window(videomode(800, 600),
More information2D Graphics with SFML
2D Graphics with SFML Simple and Fast Multimedia Library Getting Started git clone https://github.com/sfml/sfml.git cmake. [options] cmake --build. --target install [options] conan install sfml/2.5.1@bincrafters/stable
More informationCS 101 Randomness. Lecture 21
CS 101 Randomness Lecture 21 1 Randomness In most programming languages (Processing included) there are ways to generate random numbers 2 Randomness In most programming languages (Processing included)
More informationGRAPHICS PROGRAMMING. LAB #3 Starting a Simple Vector Animation
GRAPHICS PROGRAMMING LAB #3 Starting a Simple Vector Animation Introduction: In previous classes we have talked about the difference between vector and bitmap images and vector and bitmap animations. In
More informationICS3C/4C/3U/4U Unit 2 Workbook Selection: If Statement
Selection: If Statement Selection allows a computer to do different things based on the situation. The if statement checks if something is true and then runs the appropriate code. We will start learning
More informationSFML and conventional make files
Dr. Edgar Huckert 08-2017 V1.0 SFML and conventional make files I often write music programs: MIDI editors, converters and music notation editors. Normally I use C++ (occasionally also D) with wxwidgets.
More informationCOMP Summer 2015 (A01) Jim (James) Young jimyoung.ca
COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca order of operations with the explicit cast! int integervariable = (int)0.5*3.0; Casts happen first! the cast converts the
More informationPick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1
Conditionals Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary CS105 04 Conditionals 1 Pick a number CS105 04 Conditionals 2 Boolean Expressions An expression that
More informationCSci 1113, Fall 2015 Lab Exercise 11 (Week 13): Discrete Event Simulation. Warm-up. Stretch
CSci 1113, Fall 2015 Lab Exercise 11 (Week 13): Discrete Event Simulation It's time to put all of your C++ knowledge to use to implement a substantial program. In this lab exercise you will construct a
More informationFinal Exam Winter 2013
Final Exam Winter 2013 1. Which modification to the following program makes it so that the display shows just a single circle at the location of the mouse. The circle should move to follow the mouse but
More informationWhat is a variable? A named locajon in the computer s memory. A variable stores values
Chapter 4 Summary/review coordinate system basic drawing commands and their parameters (rect, line, ellipse,background, stroke, fill) color model - RGB + alpha Processing IDE - entering/saving/running
More information1 Getting started with Processing
cis3.5, spring 2009, lab II.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For
More informationCreating a Role Playing Game with XNA Game Studio 3.0 Part 7 Adding Sprites
Creating a Role Playing Game with XNA Game Studio 3.0 Part 7 Adding Sprites To follow along with this tutorial you will have to have read the previous tutorials to understand much of what it going on.
More informationWhat is a variable? a named location in the computer s memory. mousex mousey. width height. fontcolor. username
What is a variable? a named location in the computer s memory mousex mousey width height fontcolor username Variables store/remember values can be changed must be declared to store a particular kind of
More informationObject-Oriented Programming in Processing
Object-Oriented Programming in Processing Object-Oriented Programming We ve (kinda) been doing this since Day 1: Python is a deeply object oriented language Most of the data types we were using (strings,
More informationBasic Computer Programming (Processing)
Contents 1. Basic Concepts (Page 2) 2. Processing (Page 2) 3. Statements and Comments (Page 6) 4. Variables (Page 7) 5. Setup and Draw (Page 8) 6. Data Types (Page 9) 7. Mouse Function (Page 10) 8. Keyboard
More informationChapter 5. Condi.onals
Chapter 5 Condi.onals Making Decisions If you wish to defrost, press the defrost bu=on; otherwise press the full power bu=on. Let the dough rise in a warm place un.l it has doubled in size. If the ball
More informationRecall that creating or declaring a variable can be done as follows:
Lesson 2: & Conditionals Recall that creating or declaring a variable can be done as follows:! float radius = 20;! int counter = 5;! string name = Mr. Nickel ;! boolean ispressed = true;! char grade =
More informationGame Programming with. presented by Nathan Baur
Game Programming with presented by Nathan Baur What is libgdx? Free, open source cross-platform game library Supports Desktop, Android, HTML5, and experimental ios support available with MonoTouch license
More informationIntroduction to Programming EC-105. Lecture 2
Introduction to Programming EC-105 Lecture 2 Input and Output A data stream is a sequence of data - Typically in the form of characters or numbers An input stream is data for the program to use - Typically
More informationHow to Program a Primitive Twin-Stick Shooter in Monogame 3.4
How to Program a Primitive Twin-Stick Shooter in Monogame 3.4 This is a tutorial for making a basic twin-stick style shooter in C# using Monogame 3.4 and Microsoft Visual Studio. This guide will demonstrate
More informationXNA 4.0 RPG Tutorials. Part 5. The Tile Engine - Part 2
XNA 4.0 RPG Tutorials Part 5 The Tile Engine - Part 2 I'm writing these tutorials for the new XNA 4.0 framework. The tutorials will make more sense if they are read in order. You can find the list of tutorials
More informationCS 150 Lab 10 Functions and Random Numbers
CS 150 Lab 10 Functions and Random Numbers The objective of today s lab is to implement functions and random numbers in a simple game. Be sure your output looks exactly like the specified output. Be sure
More informationCS 106 Winter Lab 03: Input and Output
CS 106 Winter 2019 Lab 03: Input and Output Due: Wednesday, January 23th, 11:59pm Summary This lab will allow you to practice input and output. Each question is on a separate page. SAVE each sketch as
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More informationSession 5.1. Writing Text
1 Session 5.1 Writing Text Chapter 5.1: Writing Text 2 Session Overview Show how fonts are managed in computers Discover the difference between bitmap fonts and vector fonts Find out how to create font
More informationBuilding on the foundation. Now that we know a little about cout cin math operators boolean operators making decisions using if statements
Chapter 5 Looping Building on the foundation Now that we know a little about cout cin math operators boolean operators making decisions using if statements Advantages of Computers Computers are really
More informationChapter Four: Loops II
Chapter Four: Loops II Slides by Evan Gallagher & Nikolay Kirov Chapter Goals To understand nested loops To implement programs that read and process data sets To use a computer for simulations Processing
More informationCSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction
CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images
More informationDanmaku Mono Documentation
Danmaku Mono Documentation Release 0.01b UltimaOmega February 21, 2017 Miscellaneous Functions 1 Miscellaneous Functions 3 1.1 GetKeyState(keytocheck)........................................ 3 1.2 SetKeyState(key,
More informationCreating and Triggering Animations
Creating and Triggering Animations 1. Download the zip file containing BraidGraphics and unzip. 2. Create a new Unity project names TestAnimation and set the 2D option. 3. Create the following folders
More information2. The object-oriented paradigm
2. The object-oriented paradigm Plan for this section: Look at things we have to be able to do with a programming language Look at Java and how it is done there Note: I will make a lot of use of the fact
More informationC++ 프로그래밍실습. Visual Studio Smart Computing Laboratory
C++ 프로그래밍실습 Visual Studio 2015 Templates & STL Contents Exercise Practice1 Templates & STL Practice 1-1 Template Classes #include using namespace std; template class Point { private:
More informationBasic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable
Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is
More informationExpressions and Casting
Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence
More informationCS 101 Functions. Lecture 15
CS 101 Functions Lecture 15 1 Key Processing language features so-far Basic color/shapes drawing Variables For-loops If-statements 2 Functions In the next few days, we ll be talking about Functions A Function
More informationFundamentals of Programming CS-110. Lecture 2
Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout
More information+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.
+ Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create
More informationint fnvgetconfig(handle h, UINT32 id, const void *cfg, size_t sz);... 4
RP-VL-UTIL-V1 Developer s Guide [ Contents ] 1. Introduction... 1 2. Building Environment... 1 3. Operating Environment... 1 4. Function Explanation... 2 4.1. Common API for Transmitting and Receiving...
More informationJava. Representing Data. Representing data. Primitive data types
Computer Science Representing Data Java 02/23/2010 CPSC 449 161 Unless otherwise noted, all artwork and illustrations by either Rob Kremer or Jörg Denzinger (course instructors) Representing data Manipulating
More informationCS 101 Computer Science I Fall Instructor Muller. stddraw API. (DRAFT of 1/15/2013)
CS 101 Computer Science I Fall 2013 Instructor Muller stddraw API (DRAFT of 1/15/2013) This document describes the application programmer interface (API) for the stddraw library. An API describes the set
More informationCISC 1600, Lab 2.3: Processing animation, objects, and arrays
CISC 1600, Lab 2.3: Processing animation, objects, and arrays Prof Michael Mandel 1 Getting set up For this lab, we will again be using Sketchpad. sketchpad.cc in your browser and log in. Go to http://cisc1600.
More informationInput and Expressions Chapter 3 Slides #4
Input and Expressions Chapter 3 Slides #4 Topics 1) How can we read data from the keyboard? 2) How can we calculate values? 3) How can we manage the type of a value? 4) How can we round or get random numbers?
More informationChapter 8. Classes and Objects
Chapter 8 Classes and Objects Data Abstrac4on In Java there are three types of data values: primi4ve data values (int, float, boolean, etc.) arrays (actually a special type of object) objects Objects in
More informationCSci 1113, Fall 2018 Lab Exercise 11 (Week 13): Graphics. Warm-up
CSci 1113, Fall 2018 Lab Exercise 11 (Week 13): Graphics It's time to put all of your C++ knowledge to use to implement a substantial program. In this lab exercise you will construct a graphical game that
More informationLECTURE 4. Announcements
LECTURE 4 Announcements Retries Email your grader email your grader email your grader email your grader email your grader email your grader email your grader email your grader email your grader email your
More informationTopic 2: C++ Programming fundamentals
Topic 2: C++ Programming fundamentals Learning Outcomes Upon successful completion of this topic you will be able to: describe basic elements of C++ programming language compile a program identify and
More informationCISC 1600 Lecture 3.1 Introduction to Processing
CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists
More informationIntroduction to Computers and Programming. Numeric Values
Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 5 Reading: B pp. 47-71 Sept 1 003 Numeric Values Storing the value of 5 10 using ASCII: 00110010 00110101 Binary notation: 00000000
More informationCISC 1600 Lecture 2.2 Interactivity&animation in Processing
CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap
More informationInteraction Design A.A. 2017/2018
Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 8 Loops and Arrays in Processing Francesco Leotta, Andrea Marrella
More informationBGI Graphics Engine Tutorial
BGI Graphics Engine Tutorial Tutor: Anton Gerdelan Computer game program layout Computer games (and other graphical programs) have a recognisable program structure: #include library files Global variables
More informationWe will start our journey into Processing with creating static images using commands available in Processing:
Processing Notes Chapter 1: Starting Out We will start our journey into Processing with creating static images using commands available in Processing: rect( ) line ( ) ellipse() triangle() NOTE: to find
More informationDigiPen Institute of Technology
DigiPen Institute of Technology Presents Session Six: Dynamic Sprites Creation DigiPen Institute of Technology 5001 150th Ave NE, Redmond, WA 98052 Phone: (425) 558-0299 www.digipen.edu 2005 DigiPen (USA)
More informationChapter Four: Loops. Slides by Evan Gallagher. C++ for Everyone by Cay Horstmann Copyright 2012 by John Wiley & Sons. All rights reserved
Chapter Four: Loops Slides by Evan Gallagher The Three Loops in C++ C++ has these three looping statements: while for do The while Loop while (condition) { statements } The condition is some kind of test
More informationProcessing/Java Syntax. Classes, objects, arrays, and ArrayLists
Processing/Java Syntax Classes, objects, arrays, and ArrayLists 1 Processing and Java Java is relentlessly object-oriented Among other things, this means that all methods must occur within classes Processing
More informationTutorial 2 Part B: The View Matrix & Frame Rates
Tutorial 2 Part B: The View Matrix & Frame Rates Summary Now that you can move your objects around in world space, you re probably wondering how to move your viewpoint around, too. This tutorial will show
More informationICS 4U. Introduction to Programming in Java. Chapter 10 Notes
ICS 4U Introduction to Programming in Java Chapter 10 Notes Classes and Inheritance In Java all programs are classes, but not all classes are programs. A standalone application is a class that contains
More informationMathematical Foundations of Animation and Computer Graphics Detailed Instructions for Creating the Segment Class and Skeleton Class Marist School
Mathematical Foundations of Animation and Computer Graphics Detailed Instructions for Creating the Segment Class and Skeleton Class Marist School Description: These directions will work through the code
More informationPhotogram. Programmable Photoshop Language Language Reference Manual. ( ), Group Leader. (
Photogram Programmable Photoshop Language Language Reference Manual Ohan Oda Neesha Subramaniam Richard Ng Seikwon Kim ( oo2116@columbia.edu ), Group Leader ( ns2295@columbia.edu ) ( rjn2003@columbia.edu
More informationProgramming of Graphics
Peter Mileff PhD Programming of Graphics Introduction to OpenGL University of Miskolc Department of Information Technology OpenGL libraries GL (Graphics Library): Library of 2D, 3D drawing primitives and
More information1. Complete these exercises to practice creating user functions in small sketches.
Lab 6 Due: Fri, Nov 4, 9 AM Consult the Standard Lab Instructions on LEARN for explanations of Lab Days ( D1, D2, D3 ), the Processing Language and IDE, and Saving and Submitting. Rules: Do not use the
More information[ the academy_of_code] Senior Beginners
[ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell
More informationIntroduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur
Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture - 23 Introduction to Arduino- II Hi. Now, we will continue
More informationGAME:IT Advanced. C# XNA Bouncing Ball First Game Part 1
GAME:IT Advanced C# XNA Bouncing Ball First Game Part 1 Objectives By the end of this lesson, you will have learned about and will be able to apply the following XNA Game Studio 4.0 concepts. Intro XNA
More informationIn this lecture we will briefly examine a few new controls, introduce the concept of scope, random numbers, and drawing simple graphics.
Additional Controls, Scope, Random Numbers, and Graphics CS109 In this lecture we will briefly examine a few new controls, introduce the concept of scope, random numbers, and drawing simple graphics. Combo
More informationCISC 1600 Lecture 2.2 Interactivity&animation in Processing
CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap
More informationCMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts
CMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts The goal of this Python programming assignment is to write your own code inside a provided program framework, with some new graphical
More informationName CMPS 5J Final March 17, 2010 This is a closed notes, closed book exam. Each problem is worth 1 point unless indicated otherwise.
Name CMPS 5J Final March 17, 2010 This is a closed notes, closed book exam. Each problem is worth 1 point unless indicated otherwise. There are 21 problems and 25 points total. There are multiple versions
More informationComputer Labs: Lab 5 & Sprites
Computer Labs: Lab 5 & Sprites 2 o MIEIC Pedro F. Souto (pfs@fe.up.pt) November 17, 2017 Lab5: Video Card in Graphics Mode - 2nd Lab Class Write a set of functions (tentative): int video_test_xpm(char
More informationAn Example of a Class Frequency Histogram. An Example of a Class Frequency Table. Freq
Section A: uency Histograms for Discrete Quantitative Data The data in a uency Table can be made more visual by creating a graph of the classes and their frequencies. One type of graph used for this purpose
More informationCST112 Variables Page 1
CST112 Variables Page 1 1 3 4 5 6 7 8 Processing: Variables, Declarations and Types CST112 The Integer Types A whole positive or negative number with no decimal positions May include a sign, e.g. 10, 125,
More informationName CMPS 5J Final March 17, 2009 This is a closed notes, closed book exam.
Name CMPS 5J Final March 17, 2009 This is a closed notes, closed book exam. There are 21 problems and 50 points total. The last 5 problems ask you to write short programs or code fragments. There are multiple
More informationSolving a 2D Maze. const int WIDTH = 10; const int HEIGHT = 10;
Solving a 2D Maze Let s use a 2D array to represent a maze. Let s start with a 10x10 array of char. The array of char can hold either X for a wall, for a blank, and E for the exit. Initially we can hard-code
More informationEvents. Events and the Event Loop Animation Double Buffering. 1.5 Events 1
Events Events and the Event Loop Animation Double Buffering 1.5 Events 1 Human vs. System User Interactive System perceive present seconds milliseconds or faster express translate 1.5 Events 2 Event Driven
More informationPixelSurface a dynamic world of pixels for Unity
PixelSurface a dynamic world of pixels for Unity Oct 19, 2015 Joe Strout joe@luminaryapps.com Overview PixelSurface is a small class library for Unity that lets you manipulate 2D graphics on the level
More informationStructured Programming Using C++ Lecture 10 : Graphics Programming with the Dark GDK Library. Dr. Amal Khalifa. Lecture Contents:
Structured Programming Using C++ Lecture 10 : Graphics Programming with the Dark GDK Library Dr. Amal Khalifa Lecture Contents: the Dark GDK Library The Screen Coordinate System Basic Graphics Shapes Colors
More informationCS 170 Java Programming 1. Week 13: Classes, Testing, Debugging
CS 170 Java Programming 1 Week 13: Classes, Testing, Debugging What s the Plan? Short lecture for makeup exams Topic 1: A Little Review How to create your own user-defined classes Defining instance variables,
More informationIntroduction to Game Programming Lesson 4 Lecture Notes
Introduction to Game Programming Lesson 4 Lecture Notes Learning Objectives: Following this lecture, the student should be able to: Define frame rate List the factors that affect the amount of time a game
More informationThe Projection Matrix
The Projection Matrix Lecture 8 Robb T. Koether Hampden-Sydney College Fri, Sep 11, 2015 Robb T. Koether (Hampden-Sydney College) The Projection Matrix Fri, Sep 11, 2015 1 / 43 Outline 1 Coordinate Systems
More informationAssignment #6 2D Vector Field Visualization Arrow Plot and LIC
Assignment #6 2D Vector Field Visualization Arrow Plot and LIC Due Oct.15th before midnight Goal: In this assignment, you will be asked to implement two visualization techniques for 2D steady (time independent)
More informationVariables. location where in memory is the information stored type what sort of information is stored in that memory
Variables Processing, like many programming languages, uses variables to store information Variables are stored in computer memory with certain attributes location where in memory is the information stored
More informationLineup. Introduction. What you will need. Import your costumes. What you will make. What you will learn. Hardware. Software
Raspberry Pi Projects Lineup Introduction In this project you will be making a game using Scratch 2.0. The game will involve nding a stamped sprite on the stage, hidden amongst a huge group of other stamps.
More informationExercise 0.1 (Review from lectures no submission required)
CSCI 2110- Data Structures and Algorithms Laboratory No. 1 Week of September 10, 2018 Due: Saturday, September 15, 2018, 11.55 PM (five minutes to midnight) Review of Object-Oriented Programming Concepts
More informationDiscrete-Event Simulation:
Discrete-Event Simulation: A First Course Section 2.2: Lehmer Random Number Generators: Implementation Section 2.2: Discrete-Event Simulation c 2006 Pearson Ed., Inc. 0-13-142917-5 Section 2.2: Lehmer
More informationtypedef Labeling<unsigned char,short> LabelingBS; typedef Labeling<unsigned char,short>::regioninfo RegionInfoBS;
2005 7 19 1 ( ) Labeling 2 C++ STL(Standard Template Library) g++ (GCC) 3.3.2 3 3.1 Labeling SrcT DstT SrcT: unsigned char, shoft DstT: short typedef 1. unsigned char, short typedef Labeling
More informationToday. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed
CS 150 Introduction to Computer Science I Data Types Today Last we covered o main function o cout object o How data that is used by a program can be declared and stored Today we will o Investigate the
More informationElements of C in C++ data types if else statement for loops. random numbers rolling a die
Elements of C in C++ 1 Types and Control Statements data types if else statement for loops 2 Simulations random numbers rolling a die 3 Functions and Pointers defining a function call by value and call
More informationXNA (2D) Tutorial. Pong IAT410
XNA (2D) Tutorial Pong IAT410 Creating a new project 1. From the Start Menu, click All Programs, then the Microsoft XNA Game Studio Express folder, and finally XNA Game Studio Express. 2. When the Start
More informationLab Instructor : Jean Lai
Lab Instructor : Jean Lai Group related statements to perform a specific task. Structure the program (No duplicate codes!) Must be declared before used. Can be invoked (called) as any number of times.
More informationSummary of basic C++-commands
Summary of basic C++-commands K. Vollmayr-Lee, O. Ippisch April 13, 2010 1 Compiling To compile a C++-program, you can use either g++ or c++. g++ -o executable_filename.out sourcefilename.cc c++ -o executable_filename.out
More informationExpressions and Casting. Data Manipulation. Simple Program 11/5/2013
Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence
More informationProcessing Notes. Chapter 14: Arrays
Processing Notes Chapter 14: Arrays So far when ever we want to manage more than a few objects things get messy. Even when we started using classes, handling a lot of objects is messy. Consider the examples
More informationEP486 Microcontroller Applications
EP486 Microcontroller Applications Topic 2 Processing Department of Engineering Physics University of Gaziantep Sep 2013 Sayfa 1 Processing is a programming language, development environment, and online
More informationTutorial: Creating a Gem with code
Tutorial: Creating a Gem with code This tutorial walks you through the steps to create a simple Gem with code, including using the Project Configurator to create an empty Gem, building the Gem, and drawing
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All for repetition statement do while repetition statement switch multiple-selection statement break statement continue statement Logical
More informationOld 257 Exam #2s for Practice
Old Exam #2s 257/757 Exploring Programming with Graphics Page 1 Old 257 Exam #2s for Practice Exams will be taken on Thursday March 27 in the cluster. You will have the entire class time to do the exam.
More informationCMPSCI 119 LAB #2 Anime Eyes Professor William T. Verts
CMPSCI 119 LAB #2 Anime Eyes Professor William T. Verts The goal of this Python programming assignment is to write your own code inside a provided program framework, with some new graphical and mathematical
More information