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.

Slides:



Advertisements
Similar presentations
Games in Python – the easy way
Advertisements

Lists (also called Arrays) A list is an example of a collection: a data type that is capable of storing other data types. foods = ["spam", "eggs", "sausage",
Green Screen. Objectives: 2. Understand what the difference is between a Luma key and a Chroma key. By the end of todays lesson students will: 3. Understand.
© red ©
Colors – part 3 K1066BI – Graphical Design Teppo Räisänen
Notes Over 12.5 Probability of Independent Events 1. You are playing a game with 2 numbered cubes. Find the probability of rolling a sum of 8 on the first.
2 What is pyGame? A set of Python modules to make it easier to write games. –home page: –documentation:
Pygame Dick Steflik.
This presentation will cover your LCD screen with several solid colors, one at a time. This makes it fairly easy to see stuck (always on or off) pixels.
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,
Computer Science 112 Fundamentals of Programming II Graphics Programming.
Hello, little turtles. Hello, little turtles! There are many modules in Python that provide very powerful feature that we can use in our own program.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
CONTROL SYSTEMS Control Systems A command is a directive that performs a specific task An argument is a variable that can be used by the function reveiving.
Processing Workshop. What is processing? “Processing is an open source programming language and environment for people who want to program images, animation,
ITEC 109 Multimedia Lecture Lecture 23. Photo manipulation Review Lists / Arrays.
CRE Programming Club - Class 5 Robert Eckstein and Robert Heard.
RGB lesson Mrs Ras. Open illustrator File > new change color mode to RGB.
PART TWO Electronic Color & RGB values 1. Electronic Color Computer Monitors: Use light in 3 colors to create images on the screen Monitors use RED, GREEN,
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
PyGame - Unit 2 PyGame Unit – – Animation.
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.
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
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:
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)
Catapult 2016.
Animations.
PYGAME.
WITH PYGAME ON THE RASPBERRY PI
Let’s Learn 2. Installing Pygame
Sorting and Grouping.
8. Installing Pygame
9. Drawing.
South African Flag The South African flag contains the most colours of any national flag. Can you colour it in here? RED WHITE YELLOW WHITE BLACK GREEN.
10. User Input.
11. Animation Let's Learn Python and Pygame

9. Drawing Let's Learn Python and Pygame
Let’s Learn 10. Invaders Saengthong School, June – August 2016
Basic Graphics Drawing Shapes 1.
13. Sprites Let's Learn Python and Pygame
CSc 110, Spring 2018 Lecture 9: Parameters, Graphics and Random
8. Starting Pygame Let's Learn Python and Pygame
10. User Input Let's Learn Python and Pygame
14. Pong.
Colours.
WICS - Flappy Anteater Python Tutorial
16. Invaders.
What employers and colleges expect you to have.
UNIT3 Colour.
Let’s Learn 7. Sprites Saengthong School, June – August 2016
14. Pong Let's Learn Python and Pygame
11. Animation.
12.4 p 471 a) double[] number = {1.05, 2.05, 3.05, 4.05, 5.05};
What Color is it?.
BSI Symbols for Graphic Communication
LEARNING STRATEGIES: TRUE COLOURS The True Colours Test.
LEARNING STRATEGIES: TRUE COLOURS The True Colours Test.
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,
CoE Software Lab II , Semester 2, Sprites.
Presentation transcript:

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 pygame

Base Pygame Program import pygame pygame.init() size = (400,700) screen = pygame.display.set_mode(size) clock = pygame.time.Clock() while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True pygame.display.flip() clock.tick(30) pygame.quit() import pygame pygame.init() size = (400,700) screen = pygame.display.set_mode(size) clock = pygame.time.Clock() while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True pygame.display.flip() clock.tick(30) pygame.quit()

Initialization This is needed before you can use any of pygame’s features. import pygame pygame.init() import pygame pygame.init()

Screen Makes the window the game will be played in import pygame pygame.init() size = (400,700) screen = pygame.display.set_mode(size) import pygame pygame.init() size = (400,700) screen = pygame.display.set_mode(size)

Game Loop # Main Loop! while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True screen.fill(blue) pygame.display.flip() clock.tick(30) # Main Loop! while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True screen.fill(blue) pygame.display.flip() clock.tick(30)

Quitting This isn’t necessary, but it cleanly exits the program pygame.quit()

RGB Colours RGB is short for red, green, and blue Range from 0 to 255. white = (255,255,255) black = (0,0,0) red = (255,0,0) green = (0,255,0) blue = (0,0,255) white = (255,255,255) black = (0,0,0) red = (255,0,0) green = (0,255,0) blue = (0,0,255)

Normal Graphics

Pygame Graphics

Filling in the Background We usually need to fill the background in every loop screen.fill(blue)

Pygame drawing We can draw any kind of basic shapes in Python

How to Draw in Pygame We use the pygame.draw function pygame.draw.rect(Surface, color, Rect) pygame.draw.circle(Surface, color, pos, radius) pygame.draw.ellipse(Surface, color, Rect) pygame.draw.line(Surface, color, start_pos, end_pos, width) pygame.draw.rect(Surface, color, Rect) pygame.draw.circle(Surface, color, pos, radius) pygame.draw.ellipse(Surface, color, Rect) pygame.draw.line(Surface, color, start_pos, end_pos, width)

How Do I Remember All That Easy: go to the documentation