CoE Software Lab II 1. Pygame Intro , Semester 2,

Slides:



Advertisements
Similar presentations
Games in Python – the easy way
Advertisements

CHAPTER 3 (P.49-53) Importing modules + pygame intro.
CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
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.
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.
GameMaker.  A lot of Different Definitions  Easier to Say What is NOT a Game  Movie is Not a Game  No Active Participation  Final Outcome is Fixed.
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.
VIDEO GAME PROGRAMMING Video Game Programming Level One – Breakout INSTRUCTOR Big Dan Teague TEACHER’S ASSISTANT Delmar O'Donnell.
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,
Timer, Animation Responding to Mouse & Keyboard Lab 7 7 McGraw-Hill© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Scratch Programming Lesson 4 Question asking and answering.
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
11 General Game Programming Approach. The program is event-driven The program is event-driven –Messages = events –So as all windows system (for example.
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.
Section 2B. Objectives List two reasons why some people prefer alternative methods of input over a standard keyboard or mouse. List three categories of.
CompSci 44.1 Game Package Introduction to Jam’s Video Game Package.
Game Maker Evil Clutches.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
Implement User Input Windows Development Fundamentals LESSON 2.4A.
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
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
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.
Sprites (Images) and Sounds
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.
Animations.
Part II Reference:
PYGAME.
WITH PYGAME ON THE RASPBERRY PI
Let’s Learn 2. Installing Pygame
8. Installing Pygame
Introduction to Event-Driven Programming
Keyboard Input.
9. Drawing.
Game Loops + Part II Reference:
10. User Input.
11. Animation Let's Learn Python and Pygame

9. Drawing Let's Learn Python and Pygame
Catapult 2014 Session 10.
Let’s Learn 10. Invaders Saengthong School, June – August 2016
13. Sprites Let's Learn Python and Pygame
Lesson 17: Building an App: Canvas Painter
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 , Semester 2, Pong.
CoE Software Lab II , Semester 2, Sprites.
05 | Capturing User Input Michael “Mickey” MacDonald | Indie Game Developer Bryan Griffiths | Software Engineer/Game Developer.
Presentation transcript:

CoE Software Lab II 1. Pygame Intro 240-203, Semester 2, 2018-2019 Who I am: Andrew Davison WiG Lab ad@fivedots.coe.psu.ac.th

1. What is Pygame? A set of modules for writing games home page: http://pygame.org/ documentation: http://pygame.org/docs/ pyGame helps you with: 2D graphics (and 3D) images, sounds, music, (video) user input (events) from keyboard, mouse, gamepad support for game things sprites, collision detection, etc.

Game Things in Pygame sprites: moving game characters / objects collision detection: which sprites are touching? event: a user action (e.g. mouse or key press), or computer change (e.g. clock tick) game loop: read new events update sprites and game state redraw game

2. Run pygameSimple.py A pygame game window

3. pygameSimple.py Explained EVERY game program adds to this one. Make sure you understand it. import pygame from pygame.locals import * pygame.init() screenSize = (640, 480) screen = pygame.display.set_mode(screenSize) screen.fill((255,255,255)) # white background pygame.display.set_caption("Hello, World!") # set title bar clock = pygame.time.Clock() :

running = True while running: # game loop clock.tick(30) # set loop speed # handle events for event in pygame.event.get(): if event.type == QUIT: #user clicks close box running = False # update game state (nothing yet) # redraw game pygame.display.update() pygame.quit()

4. Events An event is a user action (e.g. mouse or key press), or a computer change (e.g. clock tick). a bit like "messages" sent to Pygame from the user and computer handle events update game state redraw game

The "quit" event for event in pygame.event.get(): if event.type == QUIT: # user clicks close box running = False When running is false, the game loop ends, and Pygame quits.

Quit by Also Typing <Esc> for event in pygame.event.get(): if event.type == QUIT: # user clicks close box running = False if (event.type == KEYUP and event.key == K_ESCAPE): # user clicks <ESC> key

Keyboard Events KEYDOWN is sent when a key is pressed KEYUP is sent when a key is released Each key has a constant that begins with K_: alphabet keys are K_a through K_z Others: K_SPACE, K_RETURN, K_ESCAPE, etc. For a complete list see http://www.pygame.org/docs/ref/key.html