-
Notifications
You must be signed in to change notification settings - Fork 5
/
vampirepizza_chapter4.py
85 lines (58 loc) · 1.92 KB
/
vampirepizza_chapter4.py
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
78
79
80
81
82
83
84
85
#Set-up Game
#import libraries
import pygame
from pygame import *
#initialize pygame
pygame.init()
#-----------------------------
#Define constant variables
#Define the parameters of the game window
WINDOW_WIDTH = 1100
WINDOW_HEIGHT = 600
WINDOW_RES = (WINDOW_WIDTH, WINDOW_HEIGHT)
# Define the parameters of each tile
WIDTH = 100
HEIGHT = 100
# Define some colors
WHITE = (255, 255, 255)
#--------------------------------------------------------------
#Load Assets
#create window
GAME_WINDOW = display.set_mode(WINDOW_RES)
display.set_caption('Vampire Pizza')
#set up enemy imgage
pizza_img = image.load('vampire.png')
pizza_surf = Surface.convert(pizza_img)
VAMPIRE_PIZZA = transform.scale(pizza_surf, (WIDTH, HEIGHT))
#set up background image
background_img = image.load('restaurant.jpg')
background_surf = Surface.convert(background_img)
BACKGROUND = transform.scale(background_surf, (WINDOW_RES))
#--------------------------------------------------------------
# Initialize and draw Background Grid
# Populate the grid
tile_color = WHITE
for row in range(6):
for column in range(11):
draw.rect(BACKGROUND, tile_color, (WIDTH * column, HEIGHT * row, WIDTH, HEIGHT), 1)
GAME_WINDOW.blit(BACKGROUND, (0,0))
#--------------------------------------------------------------------------------------------------------------------------------------
#Start Main Game Loop
#Game Loop
running = True
while running:
#------------------------------------------
#Check for events
#checking for and handling events
for event in pygame.event.get():
#exit loop on quit
if event.type == QUIT:
running = False
#Display the vampire pizza
GAME_WINDOW.blit(VAMPIRE_PIZZA, (900,400))
display.update()
#Close Main Game Loop
#------------------------------------------------------------------------------------------------------------------------
#End of game loop
#Clean-up Game
pygame.quit()