Delete main.py
parent
b1f96c318d
commit
210f06403b
59
main.py
59
main.py
|
@ -1,59 +0,0 @@
|
||||||
import pygame
|
|
||||||
import sys
|
|
||||||
import button
|
|
||||||
import random
|
|
||||||
|
|
||||||
def main():
|
|
||||||
pygame.init()
|
|
||||||
|
|
||||||
screen = pygame.display.set_mode((1000,700))
|
|
||||||
pygame.display.set_caption("Space game")
|
|
||||||
icon = pygame.image.load("icon.png")
|
|
||||||
pygame.display.set_icon(icon)
|
|
||||||
background = pygame.image.load("space.jpg")
|
|
||||||
background = pygame.transform.scale(background, (1000,700))
|
|
||||||
|
|
||||||
difficulty_img = pygame.image.load("difficulty.png")
|
|
||||||
|
|
||||||
#difficulty_button = button.Button(400, 410, difficulty_img, 1)
|
|
||||||
running = True
|
|
||||||
|
|
||||||
difficulty = 0
|
|
||||||
|
|
||||||
def reset_enemies(difficulty):
|
|
||||||
enemies = []
|
|
||||||
num_of_enemies = 4 + difficulty*2
|
|
||||||
for i in range(num_of_enemies):
|
|
||||||
direction_x = 0.4
|
|
||||||
|
|
||||||
if random.randint(0, 1):
|
|
||||||
direction_x *= -1
|
|
||||||
|
|
||||||
if difficulty > 1:
|
|
||||||
direction_y = random.randint(0, 40*difficulty)/1000
|
|
||||||
else:
|
|
||||||
direction_y = 0
|
|
||||||
|
|
||||||
enemies.append({
|
|
||||||
"X": random.randint(0, 930),
|
|
||||||
"Y": random.randint(0, 30),
|
|
||||||
"X_change": direction_x,
|
|
||||||
"Y_change": direction_y
|
|
||||||
})
|
|
||||||
return enemies
|
|
||||||
enemy_image = pygame.image.load("enemy.png")
|
|
||||||
enemies = reset_enemies(difficulty)
|
|
||||||
num_of_enemies = len(enemies)
|
|
||||||
|
|
||||||
while running:
|
|
||||||
for event in pygame.event.get():
|
|
||||||
if event.type == pygame.QUIT:
|
|
||||||
running = False
|
|
||||||
|
|
||||||
|
|
||||||
screen.blit(background, (0, 0))
|
|
||||||
|
|
||||||
pygame.display.flip()
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
|
||||||
main()
|
|
Loading…
Reference in New Issue