added window name and hidden mouse
This commit is contained in:
		
							parent
							
								
									8acaaed74b
								
							
						
					
					
						commit
						1045707f72
					
				
					 1 changed files with 19 additions and 2 deletions
				
			
		
							
								
								
									
										21
									
								
								pyshoot.py
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								pyshoot.py
									
									
									
									
									
								
							| 
						 | 
					@ -107,11 +107,21 @@ class BulletFactory():
 | 
				
			||||||
		""" create a bullet of type 2
 | 
							""" create a bullet of type 2
 | 
				
			||||||
		temporary ennemies bullet """
 | 
							temporary ennemies bullet """
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		bullet = Bullet(['bullet.bmp'], 0, pos)
 | 
							bullet = Bullet(['bullet_red.bmp'], 0, pos)
 | 
				
			||||||
		bullet.speed = speed
 | 
							bullet.speed = speed
 | 
				
			||||||
		bullet.damage = 10
 | 
							bullet.damage = 10
 | 
				
			||||||
		return bullet
 | 
							return bullet
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						def create_type3(self, pos, speed):
 | 
				
			||||||
 | 
							""" create a bullet of type 3
 | 
				
			||||||
 | 
							temporary ennemies bullet (aiming) """
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							bullet = Bullet(['bullet_purple.bmp'], 0, pos)
 | 
				
			||||||
 | 
							bullet.speed = speed
 | 
				
			||||||
 | 
							bullet.damage = 10
 | 
				
			||||||
 | 
							return bullet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Bullet(Object):
 | 
					class Bullet(Object):
 | 
				
			||||||
	def __init__(self, frames, type, pos):
 | 
						def __init__(self, frames, type, pos):
 | 
				
			||||||
		Object.__init__(self, frames, pos, (0, 0))
 | 
							Object.__init__(self, frames, pos, (0, 0))
 | 
				
			||||||
| 
						 | 
					@ -231,7 +241,7 @@ class Enemy(Object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def shoot_player(self):
 | 
						def shoot_player(self):
 | 
				
			||||||
		""" shoot a bullet to the player """
 | 
							""" shoot a bullet to the player """
 | 
				
			||||||
		speed = self.aim_player()
 | 
							speed = self.aim()
 | 
				
			||||||
		bullet = globals.bullet_factory.create_type2(self.rect.midleft, speed)
 | 
							bullet = globals.bullet_factory.create_type2(self.rect.midleft, speed)
 | 
				
			||||||
		globals.bullets_list.add(bullet)
 | 
							globals.bullets_list.add(bullet)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -239,6 +249,11 @@ class Enemy(Object):
 | 
				
			||||||
		""" compute speed vector to aim at current player position """
 | 
							""" compute speed vector to aim at current player position """
 | 
				
			||||||
		# get player position
 | 
							# get player position
 | 
				
			||||||
		player_pos = globals.player.rect
 | 
							player_pos = globals.player.rect
 | 
				
			||||||
 | 
							direction = (player_pos[0] - self.rect[0], player_pos[1] - self.rect[1])
 | 
				
			||||||
 | 
							# norm = 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def aim(self):
 | 
				
			||||||
 | 
							""" set bullet speed """
 | 
				
			||||||
		return (-10, 0)
 | 
							return (-10, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					@ -265,6 +280,8 @@ def init_sound():
 | 
				
			||||||
def init():
 | 
					def init():
 | 
				
			||||||
	""" general initialisation"""
 | 
						""" general initialisation"""
 | 
				
			||||||
	pygame.init()
 | 
						pygame.init()
 | 
				
			||||||
 | 
						pygame.display.set_caption('Pyshoot')
 | 
				
			||||||
 | 
						pygame.mouse.set_visible(0)
 | 
				
			||||||
	init_gfx()
 | 
						init_gfx()
 | 
				
			||||||
	globals.clock = pygame.time.Clock()
 | 
						globals.clock = pygame.time.Clock()
 | 
				
			||||||
	random.seed()
 | 
						random.seed()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue