Пример #1
0
	def __init__(self):
		super(TitleScene, self).__init__()

		# generate bg stars
		self.bgStars = []
		for i in range(0, 100):
			self.bgStars.append(Vector2(random.randrange(0, Config.getScreenSize()[0]), random.randrange(0, Config.getScreenSize()[1])))

		# menu manager
		self.menuManager = MenuManager(MainMenu(), self)

		# bg music
		pygame.mixer.music.load(Config.getFile(Config.titleBgMusic))
		pygame.mixer.music.play(-1) # loop forever
Пример #2
0
	def __init__(self):
		super(IntroScene, self).__init__()

		# generate bg stars
		self.bgStars = []
		for i in range(0, 100):
			self.bgStars.append(Vector2(random.randrange(0, Config.getScreenSize()[0]), random.randrange(0, Config.getScreenSize()[1])))

		# bg music
		pygame.mixer.music.load(Config.getFile(Config.introBgMusic))
		pygame.mixer.music.play(-1) # loop forever

		# Render Lines
		self.fontColor = (255,255,0)
		self.titleFont = pygame.font.Font(Config.getFile(Config.ethnocentric), 40)
		self.font = pygame.font.Font(Config.getFile(Config.ethnocentric), 20)
		self.lineHeight = 55
		self.lines = [
			"HOME DEFENCE",
			"",
			"It is a period of space war. Alien",
			"spaceships, striking from a hidden base,",
			"have conquered the planets of our solar",
			"system.",
			"",
			"During the battle, alien spies managed",
			"to destroy our colonies of Uranus and",
			"Neptune, using armoured space station",
			"called DEATH STAR.",
			"",
			"We must act fast to stop the aliens from",
			"destroying all of our homeland!"
		]

		# start scrolling from the bottom of the screen
		self.y = Config.getScreenSize()[1]
		self.scrollSpeed = 50
Пример #3
0
	def __init__(self, savedGame = None):
		super(GameScene, self).__init__()

		self.level = 1
		self.paused = False

		screenSize = Config.getScreenSize()
		self.camera = Camera(Vector2(screenSize[0], screenSize[1]))
		
		# setup solar system
		self.sun = Sun()
		#							size	mass	dist	year	colour						center
		mercury = Planet("Mercury",	0.383, 	3200, 	57.0, 	900, 	"img/planets/mercury.png", 	self.sun, math.radians(random.randrange(0, 359)))
		venus 	= Planet("Venus",	0.95, 	3200, 	108.0, 	2000, 	"img/planets/venus.png", 	self.sun, math.radians(random.randrange(0, 359)))
		earth 	= Planet("Earth",	1.0, 	3200, 	150.0, 	3650, 	"img/planets/earth.png", 	self.sun, math.radians(random.randrange(0, 359)))
		mars 	= Planet("Mars",	0.532, 	3200, 	227.0, 	7000, 	"img/planets/mars.png", 	self.sun, math.radians(random.randrange(0, 359)))
		jupiter = Planet("Jupiter",	11.2, 	12000, 	778.0, 	36000, 	"img/planets/jupiter.png", 	self.sun, math.radians(random.randrange(0, 359)))
		saturn 	= Planet("Saturn",	9.45, 	5000, 	1426.0, 80000, 	"img/planets/saturn.png", 	self.sun, math.radians(random.randrange(0, 359)))

		# moons
		#earth
		moon = Moon(		0.5, 	100, 	15.0, 	80, 	"img/planets/moon.png", 	earth, math.radians(random.randrange(0, 359)))
		earth.moons.append(moon)

		#mars
		phobos = Moon(		0.2, 	100, 	5.0, 	30, 	"img/planets/moon.png", 	mars, math.radians(random.randrange(0, 359)))
		deimos = Moon(		0.2, 	100, 	8.0, 	40, 	"img/planets/moon.png", 	mars, math.radians(random.randrange(0, 359)))
		mars.moons.append(phobos)
		mars.moons.append(deimos)

		#jupiter
		europa 		= Moon(		0.2, 	100, 	20.0, 	60, 	"img/planets/moon.png", 	jupiter, math.radians(random.randrange(0, 359)))
		io 			= Moon(		0.2, 	100, 	25.0, 	80, 	"img/planets/moon.png", 	jupiter, math.radians(random.randrange(0, 359)))
		ganymede 	= Moon(		0.2, 	100, 	30.0, 	100, 	"img/planets/moon.png", 	jupiter, math.radians(random.randrange(0, 359)))
		callisto 	= Moon(		0.2, 	100, 	35.0, 	120, 	"img/planets/moon.png", 	jupiter, math.radians(random.randrange(0, 359)))
		jupiter.moons.append(europa)
		jupiter.moons.append(io)
		jupiter.moons.append(ganymede)
		jupiter.moons.append(callisto)

		self.planets = [mercury, venus, earth, mars, jupiter, saturn]


		# asteroids
		self.asteroids = []
		for i in range(0, 500):
			size = random.randrange(4, 15) / 10.0
			self.asteroids.append(Asteroid(	size, 	1, 	random.randrange(400,600), 	random.randrange(100, 300), (100, 100, 100), 	self.sun, math.radians(random.randrange(0, 359))))

		# setup pointer to probe and aliens
		self.probe = Probe(earth.position + Vector2(20,0), Vector2(0,0))
		self.aliens = []

		# stars
		self.bgStars = []
		for i in range(0, 200):
			self.bgStars.append(Vector2(random.randrange(-Config.getScreenSize()[0]/2, Config.getScreenSize()[0]/2), random.randrange(-Config.getScreenSize()[1]/2, Config.getScreenSize()[1]/2)))

		# Level setup and load game if necessary
		self.levelManager = LevelManager(Level1(), self.planets, self.probe, self.aliens, self)
		
		if savedGame is not None:
			savedGame.load(self.levelManager, self.planets, self.probe, self.aliens)
			self.update(0)
			self.paused = True

		# gui
		self.currentSelection = 0
		self.selectionsRects = []

		self.selectSound = pygame.mixer.Sound("sound/select.ogg")