Skip to content

Commit 350e139

Browse files
File commented and extra photos deleted
1 parent ead928c commit 350e139

File tree

14 files changed

+121
-87
lines changed

14 files changed

+121
-87
lines changed

__pycache__/game.cpython-37.pyc

-3.24 KB
Binary file not shown.

__pycache__/main.cpython-37.pyc

-5.99 KB
Binary file not shown.

coin2.jpg

-738 Bytes
Binary file not shown.

game.py

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
import random
2-
import pygame
3-
import math
4-
from time import sleep
5-
6-
# Intialize the pygame
1+
#Import necessary modules
2+
import os
3+
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" #Hide the starting intialize text
4+
import random #Get random values
5+
import pygame #Module for creating games
6+
import math #For applying math
7+
import time #To measure time
8+
9+
# Intialize pygame
710
pygame.init()
811

912
# create the screen
1013
screen = pygame.display.set_mode((480, 480))
1114

1215
# Background
1316
background = pygame.image.load('floor.png')
14-
coin = pygame.image.load('coin2.jpg')
17+
#Uranium
18+
uranium = pygame.image.load('uranium.png')
1519

20+
#Define color codes in RGB for text background and colour
1621
black = (0, 0, 0)
1722
white = (255, 255, 255)
1823

19-
mode = 0
20-
24+
#Define font size and write out the rules
2125
font = pygame.font.Font('freesansbold.ttf', 11)
22-
text1 = font.render('You have made it into the soviet factory. You are in the entrance room of the factory.', True, black, white)
23-
text2 = font.render('There is a hallway leading into the main room of the factory. ', True, black, white)
24-
text3 = font.render('You hold nothing but a silenced pistol.And of course, some general tools that ', True, black, white)
25-
text4 = font.render('can help on a stealth mission like this where you have to lurk ', True, black, white)
26-
27-
28-
29-
num = 0
26+
text1 = font.render('CONTROLS: ARROW KEYS TO MOVE AND SPACE TO SHOOT', True, black, white)
27+
text2 = font.render('OBJECTIVE: GET THE URANIUM AT THE END OF THE HALL', True, black, white)
3028

3129
pygame.display.set_caption("Perspectives") #Game title
32-
icon = pygame.image.load('hero.png') #Imgae icon
33-
pygame.display.set_icon(icon)
30+
icon = pygame.image.load('hero.png') #Image icon
31+
pygame.display.set_icon(icon) #Set icon
3432

3533
playerImg = pygame.image.load('hero.png') #Load in the image of the player
3634
playerX = 400 #Player starting coordinates
@@ -44,8 +42,9 @@
4442
enemyY = []
4543
enemyX_change = []
4644
enemyY_change = []
47-
num_of_enemies = 6
45+
num_of_enemies = 20
4846

47+
#Load in the bullet
4948
bulletImg = pygame.image.load('bullet.png')
5049
bulletX = 0
5150
bulletY = 480
@@ -60,7 +59,6 @@
6059
enemyX_change.append(1)
6160
enemyY_change.append(20)
6261

63-
wall = pygame.image.load('wall2.png') #Load image of wall behind which hero hides
6462

6563
def player(x, y): #define function to place hero in certain coordinates
6664
screen.blit(playerImg, (x, y)) #scree.blit places image on the screen
@@ -69,19 +67,29 @@ def player(x, y): #define function to place hero in certain coordinates
6967
def enemy(x, y, i): #define function to place enemy in certain coordinates
7068
screen.blit(enemyImg[i], (x, y))
7169

72-
def fire_bullet(x, y):
70+
def fire_bullet(x, y): #Define a function to fire the bullet
7371
global bullet_state
7472
bullet_state = "fire"
7573
screen.blit(bulletImg, (x + 16, y + 10))
7674

7775

78-
def isCollision(enemyX, enemyY, bulletX, bulletY):
79-
distance = math.sqrt(math.pow(enemyX - bulletX, 2) + (math.pow(enemyY - bulletY, 2)))
76+
def isCollision(enemyX, enemyY, bulletX, bulletY): #define a function to check for collision
77+
distance = math.sqrt(math.pow(enemyX - bulletX, 2) + (math.pow(enemyY - bulletY, 2))) #Formula for distance
8078
if distance < 27:
8179
return True
8280
else:
8381
return False
8482

83+
def game_over_text(): #Show losin text
84+
over_font = pygame.font.Font('freesansbold.ttf', 25)
85+
over_text = over_font.render("A SOVIET SOLDIER KILLED YOU", True, (255, 0, 0))
86+
screen.blit(over_text, (35, 250))
87+
88+
def you_won_text(): #Show winning text
89+
won_font = pygame.font.Font('freesansbold.ttf', 25)
90+
won_text = won_font.render("You won!", True, (255, 0, 0))
91+
screen.blit(won_text, (35, 250))
92+
8593
# Game Loop
8694
running = True
8795
while running:
@@ -90,7 +98,9 @@ def isCollision(enemyX, enemyY, bulletX, bulletY):
9098
screen.fill((0, 0, 0)) #Fill the screen with black
9199
# Background Image
92100
screen.blit(background, (0, 0)) #add background layer
93-
screen.blit(wall, (360, 370)) #add wall
101+
screen.blit(text1, (0, 450)) #Add the text
102+
screen.blit(text2, (0, 460))
103+
screen.blit(uranium, (240, 20)) #Add the uranium
94104

95105
for event in pygame.event.get(): #if user presses x then quit
96106
if event.type == pygame.QUIT:
@@ -107,7 +117,7 @@ def isCollision(enemyX, enemyY, bulletX, bulletY):
107117
if event.key == pygame.K_DOWN:
108118
playerY_change = 1 #Change the value of playerY_change
109119
if event.key == pygame.K_SPACE:
110-
if bullet_state is "ready":
120+
if bullet_state == "ready":
111121
# Get the current x cordinate of the player
112122
bulletX = playerX
113123
fire_bullet(bulletX, bulletY)
@@ -147,10 +157,12 @@ def isCollision(enemyX, enemyY, bulletX, bulletY):
147157
enemyX_change.append(1)
148158
enemyY_change.append(20)
149159

150-
collision = isCollision(enemyX[i], enemyY[i], bulletX, bulletY)
160+
collision = isCollision(enemyX[i], enemyY[i], bulletX, bulletY) #Use the collision method
151161
if collision:
152162
bulletY = 480
153163
bullet_state = "ready"
164+
165+
#Kill an enemy if it is shot
154166
del enemyX[i]
155167
del enemyY[i]
156168
del enemyX_change[i]
@@ -159,23 +171,45 @@ def isCollision(enemyX, enemyY, bulletX, bulletY):
159171
break
160172

161173

162-
enemyX[i] += enemyX_change[i]
174+
enemyX[i] += enemyX_change[i] #Defines a boundary for the enemies
163175
if enemyX[i] <= 0:
164-
enemyX_change[i] = 1
176+
enemyX_change[i] = 3
165177
enemyY[i] += enemyY_change[i]
166178
elif enemyX[i] >= 459:
167-
enemyX_change[i] = -1
179+
enemyX_change[i] = -3
168180
enemyY[i] += enemyY_change[i]
169181

170-
enemy(enemyX[i], enemyY[i], i)
171-
172-
if bulletY <= 0:
182+
if playerX <= enemyX[i]-3: #If a player comes near a soldier, then the soldier kills it
183+
if playerY <= 17:
184+
game_over_text()
185+
print("You lost")
186+
quit()
187+
else:
188+
pass
189+
else:
190+
pass
191+
192+
if playerX <= 240-3: #If a player is near the uranium, say tht they won
193+
if playerY <= 20-3:
194+
you_won_text()
195+
print("You won!")
196+
quit()
197+
else:
198+
pass
199+
else:
200+
pass
201+
202+
203+
204+
enemy(enemyX[i], enemyY[i], i) #Teleport enemy to position
205+
206+
if bulletY <= 0: #Fire bullets
173207
bulletY = 480
174208
bullet_state = "ready"
175209

176-
if bullet_state is "fire":
210+
if bullet_state == "fire":
177211
fire_bullet(bulletX, bulletY)
178212
bulletY -= bulletY_change
179213

180214
player(playerX, playerY) #place player in the desired position
181-
pygame.display.update() #update the screen
215+
pygame.display.update() #update the screen

images/Flag.png

-247 Bytes
Binary file not shown.
-9.85 KB
Binary file not shown.
-60.9 KB
Binary file not shown.

images/PST_Textures/demo.png

-257 KB
Binary file not shown.

images/PST_Textures/wall.png

-269 Bytes
Binary file not shown.

main.py

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
sleep(2)
66
def end():
77
print("After grabbing the uranium that the soviets desperately needed, you run out of the factory")
8-
sleep(2)
8+
sleep(5)
99
print('You make it out of the factory, barely alive. You have taken the uranium that the soviets needed for the missiles, and now they are powerless.')
10-
sleep(2)
10+
sleep(5)
1111
print("As you are making your way towards the helicopter, you notice Cory's wound getting worse, and you are having to support his weight more and more.")
12-
sleep(2)
12+
sleep(5)
1313
print(f"{name}: Cmon Cory! Stay awake! We're almost there!")
14-
sleep(2)
14+
sleep(5)
1515
print("Cory: I... I can make it... its just... just a leg wound...")
16-
sleep(3)
16+
sleep(5)
1717
print("You both know its not 'just' a leg wound. Thats a major artery that was hit,the first aid is starting to deteriorate, and he's going to bleed out if you don't make it back to base in time")
18-
sleep(2)
18+
sleep(5)
1919
print("As you both load on the helicopter, you breath a sigh of releif. It was done, and you made it out alive. The on board paremedic is giving Cory a tourniquet to stay alive and stop the bleeding.")
20-
sleep(3)
20+
sleep(5)
2121
print("You wonder, 'Why didn't I think of that...'")
22-
sleep(1)
22+
sleep(5)
2323
print("And now, you and Cory are considered heroes of America. Great Job!")
2424
loop = True
2525
while loop:
@@ -34,11 +34,11 @@ def end():
3434
else:
3535
loop = True
3636
print('Please choose a number 1 or 2')
37-
sleep(2)
37+
sleep(5)
3838
print("You have made it into the soviet factory. Next to you is your partner, Cory. He is from Oaklahoma, and has a deep country accent.")
39-
sleep(2)
39+
sleep(5)
4040
print("You are in the entrance room of the factory. There is a hallway leading into the main room of the factory.")
41-
sleep(2)
41+
sleep(5)
4242
print("Both of you hold nothing but silenced pistols and combat knifes. And of course, some general tools that ca help on a stealth mission like this.")
4343
sleep(2)
4444
print("You look back down at your dogtag. You read it back to yourself.")
@@ -47,83 +47,83 @@ def end():
4747
# CHOOSE YOUR NAME
4848
name = input("What is your name?\nInput: ")
4949
print(f"Cory: {name}! Quit spacing out! We got a mission, and we only have so much time before they find the bodies outside!")
50-
sleep(2)
50+
sleep(5)
5151
print(f"{name}: Right... the mission...")
52-
sleep(2)
52+
sleep(5)
5353
print(f"Cory: So how are we going to get past the couple of of guards they have in that hallway?")
54-
sleep(2)
54+
sleep(5)
5555
done = False
5656
# FIRST DECISION
5757
while done == False:
58-
choice1 = input("How are you going to sneak past the guards?\nA: Disquise as the dead guards outside.\nB: Take em out\nC: Toss a coin and lead them away\nD: Try to sneak past normally\nInput: ")
58+
choice1 = input("How are you going to sneak past the guards?\nA: Disquise as the dead guards outside.\nB: Take em out\nC: Toss a coin and lead them away\nD: Throw tear gas\nInput: ")
5959

6060
if choice1.lower() == "a":
6161
done = True
6262
print(f"{name}: We should take those guards outfits. We'll blend right in.")
63-
sleep(2)
63+
sleep(5)
6464
print("Cory: What if they ask us questions? I don't know any russian!")
65-
sleep(2)
65+
sleep(5)
6666
print(f"{name}: Damnit! Neither do I. We will just have to hope it all works out.")
67-
sleep(2)
67+
sleep(5)
6868
print("Cory: Ok...")
69-
sleep(2)
69+
sleep(5)
7070
print("After you both get dressed, you confidently walk through the hallway. But then the guards stop you")
71-
sleep(2)
71+
sleep(5)
7272
print("Guard: Почему ты оставил свой пост?")
73-
sleep(2)
73+
sleep(5)
7474
print("Cory looks at you. You look back. Neither of you know what to do, and if you try to tell Cory what to do, they will hear you speak english and you will surley die.")
75-
sleep(2)
75+
sleep(5)
7676
print('Finally, you shoot them both and dash to the storage conainer. There is bullet fire everywhere. Cory gets hit, so you apply first aid.')
7777
end()
7878
# DECISION 2A
7979
elif choice1.lower() == "b":
8080
print(f"{name}: I say we take out those commie bastards! We can each take out one with our gun.")
81-
sleep(2)
81+
sleep(5)
8282
print("Cory: Great idea! I take the left, you take the right.")
83-
sleep(2)
83+
sleep(5)
8484
print(f"{name}: 3... 2... 1... NOW!")
85-
sleep(4)
85+
sleep(5)
8686
print("You both go around the corner shoot your respective guard in the middle of the forehead before they can even blink.")
87-
sleep(2)
87+
sleep(5)
8888
print("As you drag the bodies away, you get a strange feeling... this mission was going really well so far. TOO well. The entrance you took was way too obvious, and those guards were perfectly lined up for a shot.")
89-
sleep(3)
89+
sleep(5)
9090
print(f"Then you realise.\nYou jump away from the corpse and scream\n{name}CORY GET AWAY! ITS A TR-")
91-
sleep(2)
91+
sleep(5)
9292
print("You were too late. The bombs went off and blew you across the room. It was a setup. The intel, the guards, it was all a setup. And now Cory paid the price.")
93-
sleep(2)
93+
sleep(5)
9494
print("YOU LOST.\nThe mission is a setup. Try to play the least obvious moves.")
9595
elif choice1.lower() == "c":
9696
print(f"{name}: Ok, I will toss this coin over and distract them, then we can sneak around them.")
97-
sleep(2)
97+
sleep(5)
9898
print("Cory: Won't they raise an alarm though?")
99-
sleep(2)
99+
sleep(5)
100100
print(f"{name}: How would they know it was us?")
101-
sleep(4)
101+
sleep(5)
102102
print("You toss the coin, and the guards follow it, wondering why there was a coin rolling across the ground. Luckily, you made sure it was a Russian coin.")
103-
sleep(2)
103+
sleep(5)
104104
print("You and Cory sneak behind the guards and behind a storage container in the main room. It worked! Now its time to see of the guards raise any suspicion.")
105-
sleep(3)
105+
sleep(5)
106106
print(f"A guard picks up the coin, but then notices some muddy footprints. That moron Cory had stepped in mud! The guard walks over and doesn't hesitate to shoot you both.")
107-
sleep(2)
107+
sleep(5)
108108
print("YOU LOST.\nThe guards aren't THAT stupid ya know...")
109109
elif choice1.lower() == "d":
110110
done = True
111111
print(f"{name}: Wear your masks, we will throw tear gas at them")
112-
sleep(1)
112+
sleep(5)
113113
print("Cory: Let me throw it")
114-
sleep(4)
114+
sleep(5)
115115
print(f"{name}: Lets run, get two guys and wear their uniform")
116-
sleep(1)
116+
sleep(5)
117117
print("Cory: Ok")
118-
sleep(4)
118+
sleep(5)
119119
print(f"{name}: I got a guy.")
120-
sleep(2)
120+
sleep(5)
121121
print("Cory: Ahhh")
122-
sleep(1)
122+
sleep(5)
123123
print(f"{name}: What happened?")
124-
sleep(2)
124+
sleep(5)
125125
print("Cory: Im bleeding, he hit me in the leg but I was able to get his uniform")
126-
sleep(3)
126+
sleep(5)
127127
print(f"{name}: Let's quickly apply first aid in that corner")
128128
sleep(5)
129129
print("Cory: That feels better")
@@ -134,19 +134,19 @@ def end():
134134

135135
def end():
136136
print("After grabbing the uranium that the soviets desperately needed, you run out of the factory")
137-
sleep(2)
137+
sleep(5)
138138
print('You make it out of the factory, barely alive. You have taken the uranium that the soviets needed for the missiles, and now they are powerless.')
139-
sleep(2)
139+
sleep(5)
140140
print("As you are making your way towards the helicopter, you notice Cory's wound getting worse, and you are having to support his weight more and more.")
141-
sleep(2)
141+
sleep(5)
142142
print(f"{name}: Cmon Cory! Stay awake! We're almost there!")
143-
sleep(2)
143+
sleep(5)
144144
print("Cory: I... I can make it... its just... just a leg wound...")
145-
sleep(3)
145+
sleep(5)
146146
print("You both know its not 'just' a leg wound. Thats a major artery that was hit,the first aid is starting to deteriorate, and he's going to bleed out if you don't make it back to base in time")
147-
sleep(2)
147+
sleep(5)
148148
print("As you both load on the helicopter, you breath a sigh of releif. It was done, and you made it out alive. The on board paremedic is giving Cory a tourniquet to stay alive and stop the bleeding.")
149-
sleep(3)
149+
sleep(5)
150150
print("You wonder, 'Why didn't I think of that...'")
151-
sleep(1)
152-
print("And now, you and Cory are considered heroes of America. Great Job!")
151+
sleep(5)
152+
print("And now, you and Cory are considered heroes of America. Great Job!")

0 commit comments

Comments
 (0)