Meet Pygame Noah Kantrowitz June 8, 2007. The Basics Cross-platform Based on SDL (don’t quote me on that) Handle input (keyboard, mouse) and output (graphics,

Slides:



Advertisements
Similar presentations
Games in Python – the easy way
Advertisements

Sprite-visual object (actor on the stage) Scripts- Tells actors (sprites) what to do.
Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
CHAPTER 3 (P.49-53) Importing modules + pygame intro.
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.
Graphing Linear Equations From the beginning. All the slides in this presentation are timed. You do not need to click the mouse or press any keys on the.
Hardware Specialised Devices
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
COMPUTER CONCEPTS Unit A: Computer and Internet Basics 1.
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.
PREPARED BY: RENATO R. DE VERA II
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Submitted by:- Alankar School:- UPS Sadholi Haria Block:- Rampur Maniharan Saharanpur.
COMPUTER PARTS AND COMPONENTS INPUT DEVICES
Computer Ports Mouse Port (Input).
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
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.
CHAPTER 3 (P.49-53) Importing modules + pygame intro.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
COMPUTER MAIN PARTS SANTIAGO OCAMPO MEJIA. HARDWARE  Or materials set of physical elements of a computer or a computer system.
Today we are learning to: Understand how actions and events control our game. Completing the catch the clown game – making a room – adding music Gather.
PowerPoint: POWERful or POINTless Dana Lane June 22, 2009.
COMPUTER PARTS SERGIO STIVEN LOPEZ ESCOB AR ESTUDIANTE CESDE.
Chapter 5 BIE2313 | Web design. ALL RIGHTS RESERVED No part of this document may be reproduced without written approval from Limkokwing University of.
Input Zhaohui Ning Aaron Cardwell Boonthanome Nouanesengsy.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
PyGame - Unit 2 PyGame Unit – – Animation.
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.
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.
(More) Event handling. Input and Windowed-OS’s Windowed OS’s (Windows, OSX, GUI-linux’s) send messages (events) when the user does something “on” the.
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
Section06: Sequences Chapter 4 and 5. General Description "Normal" variables x = 19 – The name "x" is associated with a single value Sequence variables:
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
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.
15. Media (sound effects, music, video)
Catapult 2016.
Part II Reference:
PYGAME.
Let’s Learn 2. Installing Pygame
8. Installing Pygame
Keyboard Input.
9. Drawing.
10. User Input.
11. Animation Let's Learn Python and Pygame
Catapult 2014 Session 10.
Importing modules + pygame intro
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.
16. Invaders.
Let’s Learn 7. Sprites Saengthong School, June – August 2016
14. Pong Let's Learn Python and Pygame
11. Animation.
L L Line CSE 420 Computer Games Lecture #6 Game Foundations.
CoE Software Lab II 1. Pygame Intro , Semester 2,
CoE Software Lab II , Semester 2, Sprites.
Presentation transcript:

Meet Pygame Noah Kantrowitz June 8, 2007

The Basics Cross-platform Based on SDL (don’t quote me on that) Handle input (keyboard, mouse) and output (graphics, audio)

Starting Up import pygame pygame.init() Cue music...

The Screen screen = pygame.display.set_mode((x, y)) screen = pygame.display.get_surface() pygame.display.flip() pygame.display.update(dirty)

Surfaces The basic element of graphics pygame.image.load(file).convert_alpha() vs.set_colorkey((r,g,b)) dest.blit(src, (x, y))

Formats Native support for the following: SVG will need to worked out Stay tuned... JPEGPNGGIFBMPPCX TGATIFLBMPBMXPM

The Loop while True:

The Loop while True:

Timing from pygame.time import Clock clock = Clock() delta = clock.tick(30)

The Loop while True:

Event Handling for evt in pygame.event.get(): if evt.type == pygame.QUIT: sys.exit()...

Event Handling Other types: QUITKEYUPKEYDOWN MOUSEMOTIONMOUSEBUTTONUPMOUSEBUTTONDOWN

Key Events evt.key == pygame.K_a See the Pygame documentation for the full list of key constants.

Mouse Events evt.pos evt.button (for the button events)

The Loop while True:

Sprites pygame.sprite.Sprite class Foo(Sprite): Must call superclass __init__().image,.rect

Groups pygame.sprite.Group RenderUpdates, OrderedUpdates.add(),.remove().update(*args) More on these in a moment

The Loop while True:

Drawing.draw(dest) Dirty updates pygame.draw.update(dirty)

Rects pygame.Rect(left,top,width,height) surf.get_rect() Always at (0,0) Attributes: topbottomleftrighttopleftbottomleft toprightbottomrightmidtopmidbottommidleftmidright centercenterxcenterysizewidthheight

Collisions Rect-based spritecollide(sprite,group,kill) spritecollideany(sprite,group) groupcollide(group1,group2,kill1,kill2)

Sound pygame.mixer.Sound(file).play(),.stop() pygame.mixer.music

Text Try to avoid it for now.

More? me.