-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
117 lines (101 loc) · 3.18 KB
/
start.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
import pygame, sys, random
from pygame.locals import *
from global_stuff import *
from fontrenderer import *
from game import Game
from gamescreen import GameScreen
from insectoid import Insectoid
from player import Player
from derpboss import DerpBoss
# Global variables common to both title screen and game loop
hiscore = 0
# Initialize pygame
pygame.init()
fpsClock = pygame.time.Clock()
pygame.display.set_caption("Planetoid")
# Create a screen
windowSurfaceObj = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), FULLSCREEN | DOUBLEBUF | HWSURFACE )
pygame.mixer.Sound('background.ogg').play(loops=-1)
# Initialize sounds
Insectoid.hitSound = pygame.mixer.Sound('insectoidhit.wav')
DerpBoss.hitSound = pygame.mixer.Sound('insectoidhit.wav')
Player.hurtSound = pygame.mixer.Sound('playerhurt.wav')
#class FallingItem:
# surf = None
#
# def __init__(self,xpos,ypos):
# self.xpos=xpos*ICON_SIZE
# self.ypos=ypos*ICON_SIZE
# self.xspeed = random.gauss(0,3)
# self.yspeed = random.gauss(0,3)
# self.onFloorCounter = 4*FPS
# self.isFalling = True
#
# def get_rect(self):
# return Rect(self.xpos,self.ypos,ICON_SIZE,ICON_SIZE)
#
# def fallAndDecideIfTimeToRemove(self):
# if self.isFalling:
# self.xpos=self.xpos+self.xspeed
# if self.xpos > SCREEN_WIDTH-2*ICON_SIZE or self.xpos < ICON_SIZE :
# self.xspeed = -self.xspeed
#
# self.yspeed = self.yspeed + 0.2
# self.ypos=self.ypos+self.yspeed
# if self.ypos > SCREEN_HEIGHT-2*ICON_SIZE:
# self.ypos = SCREEN_HEIGHT-2*ICON_SIZE
# self.yspeed = -0.5*self.yspeed
# if int(round(self.yspeed))==0:
# self.ypos = SCREEN_HEIGHT-2*ICON_SIZE
# self.isFalling = False
#
# else:
# self.onFloorCounter -=1
# if self.onFloorCounter<0:
# return False
# return True
#
# def draw(self):
# if self.ypos<SCREEN_HEIGHT-2*ICON_SIZE or self.onFloorCounter>1*FPS or self.onFloorCounter%4>1:
# windowSurfaceObj.blit(self.surf,(int(round(self.xpos)),int(round(self.ypos))))
#
#class Skull(FallingItem):
# surf = skullSurfaceObj
# def giveBonus(self,p):
# p.water = p.water/2
# #soundSkullPickup.play()
#
#class ClockItem(FallingItem):
# surf = clockSurfaceObj
# def giveBonus(self,p):
# p.addScore(7)
# #soundPickup.play()
#
#class Pellet(FallingItem):
# surf = pelletSurfaceObj
# def giveBonus(self,p):
# p.addScore(7)
# p.pellets += 1
# #soundPickup.play()
#
#class FlowerItem(FallingItem):
# surf = flowerSurfaceObj
# def giveBonus(self,p):
# p.addScore(50)
# #soundPickup.play()
#
#class FlowerStalkItem(FallingItem):
# surf = flowerstalkSurfaceObj
# def giveBonus(self,p):
# p.addScore(25)
# #soundPickup.play()
#
while True:
g = Game()
gs = GameScreen(g, windowSurfaceObj)
gs.showTitleScreen()
while (not g.isGameOver):
g.update(fpsClock.tick_busy_loop())
gs.render()
pygame.display.flip()
gs.showGameOverScreen()