-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpymod.py
More file actions
77 lines (62 loc) · 1.93 KB
/
pymod.py
File metadata and controls
77 lines (62 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import pygame
from pygame.locals import *
import sys
"""
def screensize(a,b):
screen=pygame.display.set_mode(a,b)
return screen
if _name_ == "_main_":
screensize(a,b)
"""
# Define our square object and call super to
# give it all the properties and methods of pygame.sprite.Sprite
# Define the class for our square objects
class Square(pygame.sprite.Sprite):
def __init__(self):
super(Square, self).__init__()
# Define the dimension of the surface
# Here we are making squares of side 25px
self.surf = pygame.Surface((25, 25))
# Define the color of the surface using RGB color coding.
self.surf.fill((0, 200, 255))
self.rect = self.surf.get_rect()
class Circle(pygame.sprite.cir):
def _init_(self):
super(cir,self)._init_()
self.surf = pygame.Surface((10,10))
self.surf.fill((255,255,255))
self.
# initialize pygame
pygame.init()
# Define the dimensions of screen object
screen = pygame.display.set_mode((800, 600))
player = Circle()
# instantiate all square objects
square1 = Square()
square2 = Square()
square3 = Square()
square4 = Square()
# Variable to keep our game loop running
gameOn = True
# Our game loop
while gameOn:
# for loop through the event queue
for event in pygame.event.get():
# Check for KEYDOWN event
if event.type == KEYDOWN:
if event.key
# If the Backspace key has been pressed set
# running to false to exit the main loop
if event.key == K_BACKSPACE:
gameOn = False
# Check for QUIT event
elif event.type == QUIT:
gameOn = False
# Define where the squares will appear on the screen
# Use blit to draw them on the screen surface
screen.blit(square1.surf, (40, 40))
screen.blit(square2.surf, (40, 530))
screen.blit(square3.surf, (730, 40))
screen.blit(square4.surf, (730, 530))
# Update the display using flip
pygame.display.flip()