repl.it
@BrickBoston/

Attack Helicopter Simulator 2019

Pygame

Attack Helicopter Simulator 2019 is a fun game where you are an Attack Helicopter! W: Go Up S: Go Down A: Go Left D: Go Right Space: Shoot

fork
loading
Files
  • main.py
  • 250853_preview_40x30.png
  • 250853_preview.png
  • animated-helicopter-image-0037.gif
  • Character.jpg
  • downloader.jpg
  • GameOver.jpg
  • helipad_1.jpg
  • nohup.out
  • shot.mp3
  • starter.png
  • startup.png
main.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
print('©big shaq games mmxix')
import pygame
from pygame.locals import *
import sys
import random
from time import sleep
shoot_time = 1
ammo_clip = 60
clip_reload = 1
enemy_time = 180
dead = 0
score = 0

pygame.init()
#pygame.mixer.init()

right = False
left = False
up = False
down = False
x = 10
y = 0

Width = 800
Height = 600

gameDisplay = pygame.display.set_mode((Width, Height))

#sound = pygame.mixer.Sound("shot.mp3")
#pygame.mixer.music.load()

startup = pygame.image.load("starter.png")
gg = pygame.image.load("GameOver.jpg")
background = pygame.image.load("helipad_1.jpg")
charImg = pygame.image.load("animated-helicopter-image-0037.gif")
gameDisplay.blit(background, (0,0))
pygame.display.update()
bullet = pygame.image.load('250853_preview_40x30.png')
enemyphoto = pygame.image.load('Character.jpg')

clock = pygame.time.Clock()

all_players = pygame.sprite.Group()
bang = pygame.sprite.Group()
NME = pygame.sprite.Group()

class Player(pygame.sprite.Sprite):
  def __init__(self, x, y, image):
    pygame.sprite.Sprite.__init__(self)
    self.image = image
    self.rect = self.image.get_rect()
    self.rect.x = x
    self.rect.y = y
    self.health = 1
  def right(self):
    if self.rect.x < 800:
      self.rect.x += 3.5
  def left(self):
    if self.rect.x > 0:
      self.rect.x -= 3.5
  def up(self):
    if self.rect.y < 550:
      self.rect.y += 5
  def down(self):
    if self.rect.y > 0:
      self.rect.y -= 3
  def update(self):
    if self.health == 0:
        pygame.display.blit(gg,(0,0))
        pygame.display.update()

class Projectile(pygame.sprite.Sprite):
  def __init__(self, x, y, image):
    pygame.sprite.Sprite.__init__(self)
    self.image = image
    self.rect = self.image.get_rect()
    self.rect.x = x - 50
    self.rect.y = y - 60
  def update(self):
    if self.rect.x < 850:
      self.rect.x += 6


def updateWindow():
  gameDisplay.blit(background, (0,0))
  all_players.update()
  all_players.draw(gameDisplay)
  bang.update()
  bang.draw(gameDisplay)
  NME.update()
  NME.draw(gameDisplay)
  pygame.display.update()

def intro():
  g = False
  while not g:
    clock.tick(60)
    gameDisplay.blit(startup, (0,0))
    pygame.display.update()
    sleep(5)
    gameloop()
print("Wave 1")
def gameloop():
  shoot_time = 1
  ammo_clip = 60
  clip_reload = 1
  enemy_time = 180
  enemy_wave = 1
  enemy_wavetime = 1
  dead = 0
  waves = -1
  time = 0
  timeticks = 0
  kills = 0

  player1 = Player(100,200,charImg)
  all_players.add(player1)
  class enemy(pygame.sprite.Sprite):
    def __init__(self, x, y, image):
      pygame.sprite.Sprite.__init__(self)
      self.image = image
      self.rect = self.image.get_rect()
      self.rect.x = x
      self.rect.y = y
    def update(self):
      self.rect.x -= random.randrange(1,5)
      if player1.health > 0:
        if self.rect.x <0:
          self.rect.x = 800
          self.rect.y = random.randrange(0,600)
  for i in range(3):
    enemy1 = enemy(800,random.randrange(0,600),enemyphoto)
    NME.add(enemy1)
  crashed = False
  while not crashed:
    for event in pygame.event.get():
      if event.type == pygame.QUIT:
        pygame.quit()

    timeticks += 1
    time = timeticks / 60

    hits1 = pygame.sprite.groupcollide(NME, bang, True, True)
    for hit in hits1:
      kills += 1
    hits2 = pygame.sprite.groupcollide(NME, all_players, True, True)
    for hit in hits2:
      if player1.health > 0:
        player1.health -= 1
        print(" ")
        print(" ")
        print(" ")
        print(" ")
        print(" ")
        print(" ")
        print(" ")
        print(" ")
        print(" ")
        print(" ")
        print("Kills:", kills)
        print("Time:", time, "Seconds")
        print("Waves:", waves)

    shoot_time += 1
    enemy_wavetime += 1
    if enemy_wavetime == 240:
      enemy_wave += 1
      print("Wave",enemy_wave)
      enemy_wavetime = 0
    enemy_time += 1
    if player1.health > 0:
      if enemy_time > 90/enemy_wave:
        enemy_time=0
        waves += 1
        enemy1 = enemy(550,random.randrange(0,300),enemyphoto)
        NME.add(enemy1)

    keys = pygame.key.get_pressed()
    if keys[K_w]:
      player1.down()
    if keys[K_s]:
      player1.up()
    if keys[K_a]:
      player1.left()
    if keys[pygame.K_d]:
      player1.right()
    if keys[pygame.K_SPACE]:
      if shoot_time > 30:
        #pygame.mixer.Sound.play(sound)
        shoot_time=0
        bullet2 = Projectile(player1.rect.x+200, player1.rect.y+100, bullet)
        bang.add(bullet2)
    if keys[pygame.K_q]:
      pygame.quit()
      print(" ")
      print(" ")
      print(" ")
      print(" ")
      print(" ")
      print(" ")
      print(" ")
      print(" ")
      print(" ")
      print("Quit")
      print("Kills Before Quit:", kills)
      print("Time Before Quit:", time, "Seconds")
      print("Wave Before Quit:", waves)
      quit() 
    clock.tick(60)  
    updateWindow()
    if player1.health <= 0:
      gameDisplay.blit(gg, (0,0))
      pygame.display.update()
      game()
def game():
  g = False
  while not g:
    clock.tick(60)
    gameDisplay.blit(gg, (0,0))
    pygame.display.update()
intro()
gameloop()
pygame.init()
game()
?