-
Notifications
You must be signed in to change notification settings - Fork 1
/
GravityGame.py
39 lines (37 loc) · 1.29 KB
/
GravityGame.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
import pygame
import time
from MyWorld import MyWorld
from screens import winscreen,messagescreen
from inputs import HandleEvents
from global_defs import *
from colors import *
class GravityGame():
def __init__(self):
self.playerscolors = ColorCollection()
self.clock=pygame.time.Clock()
self.ThisWorld = MyWorld(self)
self.ThisWorld.makeworld(0)
def run(self):
while self.ThisWorld.done == False:
HandleEvents(self.ThisWorld)
self.ThisWorld.update()
for epl in self.ThisWorld.list_of_explosions:
pygame.sprite.spritecollide(epl, self.ThisWorld.players, True, pygame.sprite.collide_circle)
for p in self.ThisWorld.list_of_planets:
pygame.sprite.spritecollide(p, self.ThisWorld.list_of_bullets, True, pygame.sprite.collide_circle)
p.update()
self.ThisWorld.players.draw(background)
self.ThisWorld.list_of_bullets.draw(background)
self.ThisWorld.list_of_explosions.draw(background)
screen.blit(background, (0,0))
self.clock.tick(20)
pygame.display.flip()
self.playerscolors.reset()
if len(self.ThisWorld.players)<2:
# assuming we have some winner now that the game is over
wscreen = winscreen(self.ThisWorld.players.sprites()[0].id)
else:
messagescreen("Cancelled by User")
screen.blit(background, (0,0))
pygame.display.flip()
time.sleep(5)