示例#1
0
def creerVirus(corps):
	global i	
	x, y = 0, 0
	FENETRE = data.get_fenetre()

	if i == -1:
		x = random.randint(FENETRE[0][0], FENETRE[0][1] - 2 * data.get_objet("virus", "rayon"))
		y = random.randint(FENETRE[1][0], FENETRE[1][1] - 2 * data.get_objet("virus", "rayon"))

		game.creerObjet(corps, "virus0", x, y, data.get_objet("virus", "rayon"), data.get_objet("virus", "vitesse"), data.get_objet("virus", "angle"), data.get_objet("virus", "pushUp"), data.get_objet("virus", "pushDown"), data.get_objet("virus", "pushLeft"), data.get_objet("virus", "pushRight"), data.get_objet("virus", "limiteVitesse"), data.get_objet("virus", "acceleration"), math.pi/data.get_objet("virus", "anglePlus"), data.get_objet("virus", "mitoseTime"), None, [0, 0, 0], 0, None)
		i=0
	return True
示例#2
0
def mitose(corps):
	global i
	
	listeCellule = game.GET_OBJET('cellule')
	listeVirus = game.GET_OBJET("virus")
	celluleMap = cell.GET_MAP()
	FENETRE = data.get_fenetre()
	
	# Limit of allowed active bacterias
	enemiPopulationLimite = data.get_modeItem('enemiPopulationLimite')
	x, y, continuer = 0, 0, 0
	
	# Initializes the initial mitosis
	if mode.get() is "bacteria":
		item="bacteria"
		if i == -1:
			for celluleKey in listeCellule:
				continuer = 0
				
				while continuer == 0:
					x = random.randint(FENETRE[0][0], FENETRE[0][1] - 2 * data.get_objet('bacteria', 'rayon'))
					y = random.randint(FENETRE[1][0], FENETRE[1][1] - 2 * data.get_objet('bacteria', 'rayon'))
					game.creerObjet(corps, 'bacteria0', x, y, data.get_objet('bacteria', 'rayon'), data.get_objet('bacteria', 'vitesse'), data.get_objet('bacteria', 'angle'), data.get_objet('bacteria', 'pushUp'), data.get_objet('bacteria', 'pushDown'), data.get_objet('bacteria', 'pushLeft'), data.get_objet('bacteria', 'pushRight'), data.get_objet('bacteria', 'limiteVitesse'), data.get_objet('bacteria', 'acceleration'), math.pi/data.get_objet('bacteria', 'anglePlus'), data.get_objet('bacteria', 'mitoseTime'), data.get_objet('bacteria', 'projectileTime'), [0, 0, 0], 0, None)
				
					if collision.collisionPhagocyteBacteria(corps, 'bacteria0') == True and collision.collisionCellule(corps, 'bacteria0', celluleKey, celluleMap) is not False:
						continuer = 1
					else:
						game.supprimerObjet(corps, 'bacteria0')
			
			i = 0
		
		# Process mitosis
		for key in corps.keys():
			if i > enemiPopulationLimite:
				i = 0
			
			if 'bacteria' in key:
				if corps[key]['clock'][1] == corps[key]['mitoseTime']:
					game.creerObjet(corps, 'bacteria' + str(i), corps[key]['x'] + corps[key]['r'] * 2, corps[key]['y'], data.get_objet('bacteria', 'rayon'), data.get_objet('bacteria', 'vitesse'), data.get_objet('bacteria', 'angle'), data.get_objet('bacteria', 'pushUp'), data.get_objet('bacteria', 'pushDown'), data.get_objet('bacteria', 'pushLeft'), data.get_objet('bacteria', 'pushRight'), data.get_objet('bacteria', 'limiteVitesse'), data.get_objet('bacteria', 'acceleration'), math.pi/data.get_objet('bacteria', 'anglePlus'), data.get_objet('bacteria', 'mitoseTime'), data.get_objet('bacteria', 'projectileTime'), [0, 0, 0], 0, None)
					loiMitose(corps[key], corps['bacteria' + str(i)])
					
					i += 1
					corps[key]['clock'][1] = 0
				
				corps[key]['clock'][1] += 1
		
	return True
示例#3
0
def collisionBord(objet1):
	FENETRE = data.get_fenetre()
	collision = 0
	
	if objet1['x'] + objet1['r'] < FENETRE[0][0]:
		objet1['x'] += FENETRE[0][1] + objet1['r'] * 2
		collision=1
	
	if objet1['x'] - objet1['r'] > FENETRE[0][1]:
		objet1['x'] -= FENETRE[0][1] + objet1['r'] * 2
		collision=1
	
	if objet1['y'] - objet1['r'] < FENETRE[1][0]:
		objet1['y'] += FENETRE[1][1] + objet1['r'] * 2
		collision=1
	
	if objet1['y'] - objet1['r'] > FENETRE[1][1]:
		objet1['y'] -= FENETRE[1][1] + objet1['r'] * 2
		collision=1
	
	if collision:
		return False
	
	return True