1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 22 Game Graphics.

Slides:



Advertisements
Similar presentations
Games in Python – the easy way
Advertisements

Sprites A sprite is a 2D image or animation that is integrated into a larger scene. Originally, sprites were created by special hardware that would super-impose.
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
Scratch Programming Session 6 of 10 If-then-else statements interactions Final projects specifications.
Announcements At the end of your project, you’ll be given an opportunity to make a standalone (.exe) version of your project. For this to work, you’ll.
INTRODUCTION TO SCRATCH. About Me Resources Scratch Website Learn Scratch Washington-Lee Computer.
2D Physics and Camera Systems For CSE 3902 By: Matt Boggus.
2 What is pyGame? A set of Python modules to make it easier to write games. –home page: –documentation:
Escape A sticky man adventure using TKINTER python module By: Channing Burgess.
Guide to Programming with Python
I210 review (for final exam) Fall 2011, IUB. What’s in the Final Exam Multiple Choice (5) Short Answer (5) Program Completion (3) Note: A single-sided.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
CATCH SCRATCH! Programming from Scratch. Remember Scratch?
Introduction to TouchDevelop
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 23 Game Graphics II.
 graphic organizers in the form of illustrations or images displayed in sequence for the purpose of pre-visualizing a motion picture, animation, motion.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)
Lecture 4. Greenfoot 1 Pablo Romero, Department of Informatics Greenfoot Programming simulations and games in Java.
Programming Video Games
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
Guide to Programming with Python Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
Computer Programming Modeling a Passive Solar Home.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 25 Game Graphics--Text and Animation.
The Accumulator Pattern Summing: Add up (“accumulate”), e.g. 1 2 plus 2 2 plus 3 2 plus … plus Variation: Form a product (instead of sum), e.g.
CSE 190 M Flash Sessions Session 2 Alex Miller, Spring 2011.
7.2 Areas in the Plane. How can we find the area between these two curves?
By JerryDean Smith Chad Adams Karl Mullner.  The rectangle needs to be a ogre.ManualObject -this is done to create the rectangle and gives it special.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
PyGame - Unit 2 PyGame Unit – – Animation.
GAME:IT Junior Paddle Ball Objectives: Review skills from Introduction Create a background Add simple object control (up and down) Add how to create a.
PyGame - Unit 4 PyGame Unit – Object Oriented Programming OOP.
Graphics in Python On entry: Run Python 2.78 from N: drive/computing and ICT VLE: Computing home page - check your feedback Success criteria: ●Understands.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
5. Animation Let’s Learn Saengthong School, June – August 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
Susan Ibach | Technical Evangelist Sage Franch | Technical Evangelist.
School of Computer Science Space School 2015 Programming a Lunar Lander Game.
13. Sprites. Outline 1.Game Things in Pygame (again) 2.The Pygame sprite Module 3.The Sprite Class 4.Groups of Sprites 5.Types of Collision Detection.
Sprites (Images) and Sounds
Sound and more Animations
Graphical Output Basic Images.
MOM! Phineas and Ferb are … Aims:
A look ahead: At the end of your project, you’ll be given an opportunity to make a standalone (.exe) version of your project. For this to work, you’ll.
Adapted from slides by Marty Stepp and Stuart Reges
Scratch Unit Overview We are going to look at computer programming and how to create your very own computer game The piece of software we will be using.
11. Animation Let's Learn Python and Pygame
Python: Simple Graphics and Event-driven Programming
9. Drawing Let's Learn Python and Pygame
Java Programming: Guided Learning with Early Objects
Catapult 2014 Session 10.
CSc 110, Spring 2017 Lecture 6: Parameters (cont.) and Graphics
Introduction to Object-Oriented Programming
Let’s make a shape…. Move!
13. Sprites Let's Learn Python and Pygame
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
WICS - Flappy Anteater Python Tutorial
Tank Game Part 6 of 6.
Let’s Learn 7. Sprites Saengthong School, June – August 2016
11. Animation.
MTA-4201 Game Programming Chapter 8 : Scrolling Background & Font
The coordinate system Susan Ibach | Technical Evangelist
Graphics Reading: Supplement 3G
Chapter 7 The Game Loop and Animation
CoE Software Lab II , Semester 2, Sprites.
Presentation transcript:

1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 22 Game Graphics

2 Packages Packages have libraries of Python code that we can use with our programs. We will use two packages to create simple games: Pygames: The pygames package has many useful classes to make simple games. Livewires: The livewires package was created by educators to make the pygames package easier to use.

3 Creating a Graphics Screen We can use the livewires package to create a graphics screen with a background. Example: from livewires import games#import the games package #Create the graphics screen games.init(screen_width = 640, screen_height = 480, fps = 50) #Add a background image to the screen #First load in an image, then bind it to the background wall_image = games.load_image("wall.jpg", transparent = False) games.screen.background = wall_image #Start the main event loop games.screen.mainloop( )

4 Adding a sprite Sprites are images that move around the graphics screen. To add a sprite, first load in the image, then create a sprite with the image. Finally, add the sprite to the screen. Example: pizza_image = games.load_image("pizza.bmp") the_pizza = games.Sprite(image = pizza_image, x = 320, y = 240) games.screen.add(the_pizza) Note: The coordinate system for the graphics window has (0, 0) at the top left corner. The y coordinate increases as you move downward in the window.

5 Moving a Sprite A sprite can be moved by setting the horizontal or vertical displacement variables (dx and dy) to a non-zero value. With each iteration of the mainloop( ), the sprite's position by the amount given by dx and dy. Example: the_pizza = games.Sprite(image = pizza_image, x = 320, y = 240, dx = 1, dy = 1) This will move the sprite down and to the right. Note: We can also express the initial position as a function of the screen width and height: x = games.screen.width/2, y = games.screen.height/2 The above values will position the sprite in the middle of the screen.

6 Class Inheritance In python, we can create new classes from existing classes using inheritance. The new class inherits everything from the existing class. We can add new methods and properties, or modify methods from the existing class. The new class is called the child or subclass. The existing class is called the parent or superclass.

7 Creating a Pizza class To generate a more complex motion for our sprite, we will create a new class that will inherit from the Sprite class. The new class will define an update function that will move the pizza in a more complex pattern. class Pizza(games.Sprite): """A bouncing pizza""" def update(self): if self.right > games.screen.width or self.left < 0: self.dx = -self.dx if self.bottom > games.screen.height or self.top < 0: self.dy = - self.dy