Esempio n. 1
0
	def render(self, screen):
		cursortile = terrain.nearesttile(self.you.x, self.you.y)
		worldmap.drawscene(screen, self.structures + self.sprites, (self.you.x, self.you.y))
		if settings.showminimap:
			worldmap.drawminimap(screen, [self.you])
		ax, ay = terrain.toModel(*cursortile)
		screen.blit(get_text("Position: %s %s" % (int(ax//1), int(ay//1)), (255, 0, 0), 18), (4, settings.sy-22))
Esempio n. 2
0
 def render(self, screen):
     cursortile = terrain.nearesttile(self.you.x, self.you.y)
     worldmap.drawscene(screen, self.structures + self.sprites,
                        (self.you.x, self.you.y))
     if settings.showminimap:
         worldmap.drawminimap(screen, [self.you])
     ax, ay = terrain.toModel(*cursortile)
     screen.blit(
         get_text("Position: %s %s" % (int(ax // 1), int(ay // 1)),
                  (255, 0, 0), 18), (4, settings.sy - 22))
	def deploy(self, scene, target, btype):
		X0, Y0 = terrain.toModel(target.x, target.y)
		#print self.hq.x, self.hq.y, X0, Y0, X0 - Y0, -X0 - Y0
		r = 3
		while True:
			theta = random.random() * 1000
			X = int((X0 + r * math.sin(theta))//1)
			Y = int((Y0 + r * math.cos(theta))//1)
			x, y = terrain.nearesttile(X - Y, -X - Y)
			if not terrain.isunderwater(x, y) and not self.border.iswithin(x, y):
				break
			r += 0.2
		alien = btype(X, Y)
		alien.settarget(target)
		self.attackers.append(alien)
Esempio n. 4
0
 def deploy(self, scene, target, btype):
     X0, Y0 = terrain.toModel(target.x, target.y)
     #print self.hq.x, self.hq.y, X0, Y0, X0 - Y0, -X0 - Y0
     r = 3
     while True:
         theta = random.random() * 1000
         X = int((X0 + r * math.sin(theta)) // 1)
         Y = int((Y0 + r * math.cos(theta)) // 1)
         x, y = terrain.nearesttile(X - Y, -X - Y)
         if not terrain.isunderwater(x, y) and not self.border.iswithin(
                 x, y):
             break
         r += 0.2
     alien = btype(X, Y)
     alien.settarget(target)
     self.attackers.append(alien)
 def getModelXY(self):
     return terrain.toModel(self.x, self.y)
	def getModelXY(self):
		return terrain.toModel(self.x, self.y)
	def process_input(self, events, pressed):
		
		if self.tutorial:
			if self.tutorial_instance.current_step == 5:
				x, y = self.player.getModelXY()
				if x > 85 and x < 94 and y > 27 and y < 39:
					self.tutorial_instance.current_step += 1
			pages = self.tutorial_instance.get_active_dialog()
			if pages != None:
				title = self.tutorial_instance.active_step()[0]
				self.toolbar.mode == 'main'
				self.next = TutorialDialogScene(self, pages, title, self.tutorial_instance.current_step == 6)
		
		building_menu = False
		demolish_building = False
		attack_building = False  # set to 0, 1, or 2 to be an attack type
		if self.curiosity != None:
			pass
		else:
			direction = ''
			dx, dy = 0, 0
			if pressed['up']: dy = 1.0
			if pressed['down']: dy = -1.0
			if pressed['left']: dx = -1.0
			if pressed['right']: dx = 1.0
			
			if dx != 0 and dy != 0:
				dx *= .7071
				dy *= .7071
			
			self.player.setrun(False)  # TODO: would be nice if we ran when you were holding down shift
			self.player.move(dx, dy)
			
			if self.battle:
				for event in events:
					if event.type == 'mouseleft':
						pass
					elif event.type == 'mousemove':
						pass
					elif event.type == 'key':
						if event.down and event.action in ('shoot', 'build'):
							self.shoot()
						elif event.down and event.action == 'b1':
							if not self.battle.is_computer_attacking():
								attack_building = 0
						elif event.down and event.action == 'b2':
							if not self.battle.is_computer_attacking():
								attack_building = 1
						elif event.down and event.action == 'b3':
							if not self.battle.is_computer_attacking():
								attack_building = 2
						elif event.down and event.action == 'f9':
							self.battle.forfeit()
			else:
				for event in events:
					if event.type == 'mouseleft':
						if event.down:
							self.toolbar.click(event.x, event.y, self.last_width, self)
					elif event.type == 'mousemove':
						self.mousex, self.mousey = event.x, event.y
						self.toolbar.hover(event.x, event.y, self.last_width)
					elif event.type == 'key':
						if event.down and event.action == 'debug':
							buildings = self.potato.get_all_buildings_of_player_SLOW(self.user_id)
							bord = self.potato.borders_by_user[self.user_id]
							self.pendingbattle = battle.Battle(self.user_id, buildings, bord, None)
						elif event.down and event.action == 'build':
							if self.build_mode != None:
								self.build_thing(self.build_mode)
							elif self.toolbar.mode == 'fight':
								self.shoot()
							elif self.toolbar.mode == 'demolish':
								demolish_building = True
						elif event.down and event.action == 'action':
							building_menu = True
						elif event.down and event.action == 'back':
							self.toolbar.press_back()
						elif event.down and event.action == 'shoot':
							self.shoot()
					elif event.type == 'type':
						self.toolbar.accept_key(event.action, self)
						
		you_x, you_y = terrain.toModel(self.player.x, self.player.y)
		selected_building = self.potato.get_building_selection(you_x, you_y)
		
		if building_menu and selected_building != None:
			if selected_building.user_id == self.user_id or selected_building.btype == 'radar':
				self.next = buildingmenu.BuildingMenu(self, selected_building)
		if demolish_building and selected_building != None:
			jukebox.play_voice("demolishing_please_stand_back")
			x, y = selected_building.getModelXY()
			self.blow_stuff_up(x, y)
		if attack_building is not False and selected_building is not None:
			self.battle.attack_building(self, selected_building, attack_building)