Catapult 2016.

Slides:



Advertisements
Similar presentations
Games in Python – the easy way
Advertisements

2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
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.
Week 9 Writing Games with Pygame Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise noted,
Week 10 Writing Games with Pygame Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise.
2 What is pyGame? A set of Python modules to make it easier to write games. –home page: –documentation:
Pygame Dick Steflik.
Guide to Programming with Python
Unit 9 pyGame Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except where otherwise noted, this.
Week 10 Writing Games with Pygame, continued Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
Meet Pygame Noah Kantrowitz June 8, The Basics Cross-platform Based on SDL (don’t quote me on that) Handle input (keyboard, mouse) and output (graphics,
User Input and Collisions COSC 315 Fall 2014 Bridget M. Blodgett.
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.
Java Graphics. Review 3 kinds of elements in components API? Layout managers Events Extend vs. Implement.
XNA An Introduction. What XNA is… Microsoft® XNA™ is composed of industry- leading software, services, resources, and communities focused on enabling.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
Game Maker – Getting Started What is Game Maker?.
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
1 Frisbee Physics Simulation Charles George Advisor: Brian Postow 03/05/05.
Video Games Writing Games with Pygame Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
PyGame - Unit 2 PyGame Unit – – Animation.
GAME:IT Paddle Ball Objectives: Review skills from Introduction Create a background Add simple object control (up and down) Add how to create a simple.
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.
Intro to Pygame Lecture 05. What is Pygame? It is a set of Python modules designed for writing games. It makes writing games possible for beginners. import.
11. Skier Let’s Learn Saengthong School, June – August 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
3. Drawing Let’s Learn Saengthong School, June – August 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
9. Media (sound effects, music, video) Let’s Learn Saengthong School, June – August 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
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.
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.
Sound and more Animations
GUI in Python Ismail Abumuhfouz.
MOM! Phineas and Ferb are … Aims:
Pixels, Colors and Shapes
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.
15. Media (sound effects, music, video)
Scratch for Interactivity
Animations.
Part II Reference:
PYGAME.
Let’s Learn 2. Installing Pygame
8. Installing Pygame
Keyboard Input.
9. Drawing.
Game Loops + Part II Reference:
Graphical Output Graphical Text.
10. User Input.
11. Animation Let's Learn Python and Pygame

9. Drawing Let's Learn Python and Pygame
Catapult 2014 Session 10.
Basic Graphics Drawing Shapes 1.
EEL 3705 / 3705L Digital Logic Design
13. Sprites Let's Learn Python and Pygame
8. Starting Pygame Let's Learn Python and Pygame
10. User Input Let's Learn Python and Pygame
14. Pong.
WICS - Flappy Anteater Python Tutorial
Game Loop Update & Draw.
Let’s Learn 7. Sprites Saengthong School, June – August 2016
14. Pong Let's Learn Python and Pygame
Simple Graphics Package
11. Animation.
L L Line CSE 420 Computer Games Lecture #6 Game Foundations.
CoE Software Lab II , Semester 2, Pong.
CoE Software Lab II 1. Pygame Intro , Semester 2,
Chapter 7 The Game Loop and Animation
CoE Software Lab II , Semester 2, Sprites.
Presentation transcript:

Catapult 2016

Pygame Pygame is a library designed for programming games using 2D graphics. Compared to zellegraphics, it has: much better mouse and keyboard input much faster drawing commands better image support collision-detection sound

Surfaces In Pygame many drawn objects are Surfaces Pygame draws the Surfaces as layers on top of each other. Different surfaces are able to detect collisions with one another based on a “rectangle” that bounds it Pygame.draw draws things ON TOP of a given surface, it does not create a new surface.

Surfaces (cont.)

Moving objects on screen is much different With zellegraphics, you could do things like circle. Move(dx, dy) In Pygame, you repeatedly: Change the coordinates of your object Blank out the screen Redraw your item(s) in the new location cause them to display This is done in the event loop (next slide)

Event Loop In an infinite loop, get input from the user, using it to change the state of your object (like the location) other code that affects objects (like collisions) blank out the screen redraw your item(s) in the new location cause everything to display

Event Loop (cont.) while True: events = pygame.event.get() for event in events: if event.type = QUIT: …

Colors Zellegraphics had built in colors: “red”, “blue”, etc. pygame.Color(color_name) Red = [255, 0, 0] Blue = [0, 0, 255] Lime Green = [50, 205, 50]

Pygame Documentation http://www.pygame.org/docs

Caution 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, all pygame fonts that you use should be SysFonts (created using pygame.font.SysFont) and the pygame default font should not be used [i.e. don’t use pygame.font.SysFont(None, 12)] pygame.time keeps time in milliseconds not seconds

Demos Snow Controllable Ball Moving Smilies (Take 2)

Things to Remember import pygame from pygame.locals import * pygame.init() Must have event loop pygame.display.update() pygame.display.flip() pygame.quit() Flip – updates full display Surface to the screen Update – updates portions of the display