Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Do you really want to delete this prezi?
Neither you, nor the coeditors you shared it with will be able to recover it again.
Make your likes visible on Facebook?
Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.
Transcript of Pygame
or more imports You need a window for your program. To do this, create a surface from pygame.display! BLIT, or bit block transfer, is how we put pictures on screen - basically copy them from one surface to another. Pygame makes this pretty easy! zoom in, and add details to these Frames import pygame
from pygame.locals import * myWindow=pygame.display.set_mode((640,480))
This creates a window 640 by 480
Use the myWindo object (or whatever you decide to call it, it's up to you) to then draw (blit) things onto the screen. myWindow is now the name of the window created with set_mode. First you need to load a picture to an off screen surface:
BUT, if you have a picture that has transparency, you need to add conver_alpha() on the end:
myPic=pygame.image.load('Wall.png').convert_alpha() Next, you need a Rect object, which holds the x and y position, as well as the width and height of an image:
Let's give the image a position on screen before we blit it:
myRect.top=120 And finally, let's copy (or blit) the image:
You need the last line to update the display on screen
otherwise no changes will be shown since your last update() So what? You might be thinking right now, so what? This just put's a picture at a spot on the screen. How does that make a video game? It doesn't really. Now you need to be clever and use loops to display things on screen - to draw a single screen made up of tiles like my dungeon game, or to draw a screen with a character on it that changes position based on what key you press or whatever. We'll look at these techniques next! This is the full code from our lesson so far:
from pygame.locals import *