CHAPTER 3 (P.49-53) Importing modules + pygame intro.

Slides:



Advertisements
Similar presentations
Games in Python – the easy way
Advertisements

Introduction to Computer Graphics Raster Vs. Vector COMMUNICATION TECHNOLOGY.
sample text 14pt Helvetica Instructions 1.Use mouse to select an object (icon, arrow or sample text box) 2.Copy the object (Edit > Copy) then paste.
CHAPTER 3 (P.49-53) Importing modules + pygame intro.
L.Ghadah R. Hadba CT1514-L1.  Computer Graphics :refers to processing of creating a new image from Geometry, Lighting parameters, Materials and Textures.Using.
Raster graphics. Colour depth 01 1 bit pr pixel = 2 combinations (2 1 ): 2 bits pr pixel = 4 combinations (2 2 ): bits pr pixel = 16 combinations(2.
Raster Graphics vs. Vector Graphics
Graphics. Image format's GIF Format: Use a maximum of 256 colors, and are recommendable for big areas of one color or non- continuous images. They are.
Multimedia for the Web: Creating Digital Excitement Multimedia Element -- Graphics.
OpenCV Stacy O’Malley CS-590 Summer, What is OpenCV? Open source library of functions relating to computer vision. Cross-platform (Linux, OS X,
Digital Still Images ETT June Multimedia Assets Still Images Audio Video.
Informationsteknologi Tuesday, November 6, 2007Computer Graphics - Class 41 Today’s class Input and interaction.
Introduction to Computer Graphics
CHAPTER 2 Input & Output Prepared by: Mrs.sara salih 1.
2 What is pyGame? A set of Python modules to make it easier to write games. –home page: –documentation:
Guide to Programming with Python
Python Programming Fundamentals
SDL Programming Introduction. Initialization 2  The first thing you must do is initialize SDL  int SDL_Init( SDL_INIT_EVERYTHING )  This will return.
Multimedia Specification Design and Production 2012 / Semester 1 / L4 Lecturer: Dr. Nikos Gazepidis
Module Code: CU0001NI Technical Information on Digital Images Week -2.
Introduction to Programming Workshop 1 PHYS1101 Discovery Skills in Physics Dr. Nigel Dipper Room 125d
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
File Name Extensions Computer Applications 7th grade.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
University of Sunderland CDM105 Session 6 Dreamweaver and Multimedia Fireworks MX 2004 Creating Menus and Button images.
Computer Science 111 Fundamentals of Programming I Introduction to Graphics.
Programming Video Games
File Formats and Vector Graphics. File Types Images and data are stored in files. Each software application uses different native file types and file.
By Courtney Field Creative digital graphics. Types of graphics and examples There are a number of different types of graphics file formats. Each type.
Color and Images. Color The natural colors we see and the colors we see on computer monitors are different. CMYK -natural RGB -monitor.
Project Two Adding Web Pages, Links, and Images Define and set a home page Add pages to a Web site Describe Dreamweaver's image accessibility features.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Website Design, Development and Maintenance ONLY TAKE DOWN NOTES ON INDICATED SLIDES.
REFERENCE: CHAPTER 1 High-level languages + Python.
Lesson 5 MULTIMEDIA. Multimedia on the Web has expanded rapidly as broadband connections have allowed users to connect at faster speeds. Almost all Web.
Screen Basic color – RGB Print Basic Color - CMYK R – Read G – Green B - Blue Total Color combination: 256x256x256=16,777,216 Total Printing Color.
Let’s Learn 3. Modules Saenthong School, January – February 2016
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
PyGame - Unit 2 PyGame Unit – – Animation.
1 MIT 5316 Web-Based Computing Lecture 1. 2 Welcome Introduction Syllabus.
3. Drawing Let’s Learn Saengthong School, June – August 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
2D Graphics CMT3311. This covers... How to make a transparent sprite How to add a sprite to your project and draw it Properties of sprites and how to.
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
2.01 Understand Digital Raster Graphics
2.01 Understand Digital Raster Graphics
Sprites (Images) and Sounds
Unit 20 – Computer Game Platforms & Technology – Software Technology
Development Environment
Digital Illustration Chapter 6 File format.
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.
Introduction to Graphics
PYGAME.
Let’s Learn 2. Installing Pygame
8. Installing Pygame
9. Drawing.
2.01 Understand Digital Raster Graphics
Chapter 3 Image Files © 2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
9. Drawing Let's Learn Python and Pygame
A lap around DirectX game development tools
Importing modules + pygame intro
2.01 Understand Digital Raster Graphics
8. Starting Pygame Let's Learn Python and Pygame
WICS - Flappy Anteater Python Tutorial
PLACE YOUR TITLE HERE **Poster Author(s) Go Here
Working with Symbols and Interactivity
2.01 Understand Digital Raster Graphics
Lesson 5: Multimedia on the Web
L L Line CSE 420 Computer Games Lecture #6 Game Foundations.
Presentation transcript:

CHAPTER 3 (P.49-53) Importing modules + pygame intro

modules core language vs modules.  millions of modules.  Networking  Graphics  computer vision …… To use these, you need to import them (usually at the top of your script) import math import pygame

modules, cont. Sources of modules: 1. shipped with python distribution 2. downloaded modules 3. Modules that you write yourself. Accessing module contents: module_name.item_in_the_module. Example

random Module random.randint(low_num, high_num) random.uniform(low_num, high_num) random.gauss(center_num, std_dev) A "rookie" mistake:  Often, people see a line like this: x = random.randint(5, 10)  And think we're making x a variable which changes all the time – we're not.  x gets its value (which will be different on each run)  But…it never changes, until we assign a new value to it. print(x)# Let's say it was 7 this time print(x)# still 7 print(x)# STILL 7 …

time module time.sleep(num_seconds) time.time()  Example use

Reference:

What is it? A multimedia python library  Window Management  Graphics  geometric shapes  bitmaps (sprites)  Input  Mouse  Keyboard  Gamepad / Joystick  Sound  SoundFX  Music

How to get it (at home)  Make sure you have 32-bit python installed.  Download the matching pygame version If you got it from our ssugames webpage, you're good. Try this at the prompt: >>> import pygame  If no errors, you’re all set!

Overview Pygame (sub-)module organization  Connection to documentation Pygame <= SDL <= [DirectX / OpenGL / …]

Surfaces A 2d array of (RGB) pixels  An image (sprite)  Rendered (at run-time) text  A mini-map  A HUD  An interface to the window’s contents.  In pygame, Surfaces are objects.  Look up the methods in the “Surfaces” section of pygame docs. Double Buffering  Monitor refreshes  Life without D.B.  D.B. in pygame

Examples [Basic window] [Drawing]  [Look at the pygame docs]

Sprites / Images Images (in pygame) are Surface objects File formats loadable by pygame:  JPG, BMP, PCX, TGA, TIF, PBM, PGM, XPM  GIF, PNG # Support transparency Loading: s = pygame.image.load("img.jpg") s = pygame.image.load("sprites\\img.jpg") s = pygame.image.load("..\\..\\media\\img.jpg") s = pygame.image.load("c:\\game\\img.jpg") s = pygame.image.load("/usr/bin/img.jpg") import os print(os.sep) # '\\' on Windows, '/' on *nix

Sprites / Images, cont. Converting:  Color / bit encoding…  Why it's good to convert…  Command: s = pygame.image.load("img.jpg") s = s.convert() t = pygame.image.load("img2.png").convert_alpha()

Blitting Copies contents of one (part of) a surface to another. screen (600x600) ant_img (150x180) screen.blit(ant_img, (20,100)) dest_surf.blit(src_surf, pos) screen.blit(ant_img, (100,0), (75,0,50,100)) dest_surf.blit(src_surf, pos, src_rect) (75,0) (20,100) (100,0)

Transforming surfaces pygame.transform.scale(orig_surf, (new_width, new_height)) pygame.transform.rotate(orig_surf, degrees) Returns a new surface  Must be blitted to screen to be seen Original surface is unchanged! [Example] Rotating "in-place"

Fonts Rendering text in pygame  As opposed to the print statement Two steps: 1. Create a font object (just done once) a. From a.ttf file b. From a built-in font 2. Render text  Creates a new surface  …which must be blitted to the screen. [Example]