예제 #1
0
def game_map_turn_correct( arrow, play_map, direction ):
	# Is arrow near grid center that need to check current grid bound
	arrow_grid = play_map.detect_grid( arrow.position )
	grid_position = play_map.grid_center( arrow_grid )
	if ( cal.distance(arrow.position, grid_position) < res.distance_grid_turn*arrow.speed ):
		if ( direction!=arrow.direction and direction!=cal.reverse(arrow.direction) ):
			if ( game_map.direction_to_wall(direction) &
			play_map.grids[arrow_grid[1]*play_map.map_size[0]+arrow_grid[0]] == 0):
				arrow.set_direction( direction )
				arrow.set_position( grid_position )
예제 #2
0
def game_arrow_encounter(arrow_p1, arrow_p2):
	# arrow encounter detect and handle
	if( cal.distance(arrow_p1.position, arrow_p2.position) < res.distance_collision):
		# pygame.draw.rect(gameDisplay, res.color_obj, [0,0,30,30], 5)
		if(arrow_p1.direction == arrow_p2.direction):
			return res.game_brokeback
		elif(arrow_p1.direction == cal.reverse(arrow_p2.direction)):
			arrow_p1.set_direction( cal.reverse(arrow_p1.direction) )
			arrow_p1.position = (arrow_p1.position[0]+arrow_p1.direction[0]*res.distance_collision, 	
								arrow_p1.position[1]+arrow_p1.direction[1]*res.distance_collision)
			arrow_p2.set_direction( cal.reverse(arrow_p2.direction) )
			arrow_p2.position = (arrow_p2.position[0] + arrow_p2.direction[0]*res.distance_collision,
								arrow_p2.position[1] + arrow_p2.direction[1]*res.distance_collision)
			return res.game_collision
		else:
			# if p1 bumps p2
			if ( arrow_p1.direction == cal.unit( cal.vector(arrow_p1.position, arrow_p2.position) ) ):
				arrow_p1.set_direction( cal.reverse(arrow_p1.direction) )
			else:
				arrow_p2.set_direction( cal.reverse(arrow_p2.direction) )
				
			return res.game_side_collision
예제 #3
0
 def invoke(self, arrow):
     arrow.set_direction(cal.reverse(arrow.direction))
예제 #4
0
파일: kit.py 프로젝트: nyphoon/BreakBack
	def invoke(self, arrow):
		arrow.set_direction( cal.reverse(arrow.direction) )