Beispiel #1
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
Beispiel #2
0
def deplacer(corps, nombreEnemi):
	global autoriserDeplacement
	global autoriserRebond
	
	vecDeplacement = [0, 0]
	nombreEnemiLimite = data.get_modeItem('nombreEnemiLimite')
	delKey = []
	
	# Gets the object lists
	listeBacteria = game.GET_OBJET('bacteria')
	listeProjectile = game.GET_OBJET('projectile')
	listeCellule = game.GET_OBJET('cellule')
	listeVirus = game.GET_OBJET("virus")
	celluleMap = cell.GET_MAP()
	
	# Move each object
	for key in corps.keys():
		if 'cellule' not in key:
			if corps[key]['angle'] != None:
				vecDeplacement[0] = math.cos(corps[key]['angle']) * corps[key]['vitesse']
				vecDeplacement[1] = math.sin(corps[key]['angle']) * corps[key]['vitesse']
		
		if 'Phagocyte' in key and nombreEnemi>=nombreEnemiLimite or 'Phagocyte' in key and autoriserDeplacement:
			corps[key]['x'] += vecDeplacement[0]
			corps[key]['y'] += vecDeplacement[1]
			autoriserDeplacement = 1
		
		elif 'Phagocyte' not in key and 'cellule' not in key:
			corps[key]['x'] += vecDeplacement[0]
			corps[key]['y'] += vecDeplacement[1]
			
			if 'bacteria' in key:
				for celluleKey in listeCellule:
					corps[celluleKey]['collisionMemory'][1][0] = collision.collisionCellule(corps, key, celluleKey, celluleMap)
					
					if corps[celluleKey]['collisionMemory'][1][0] is False:
						if autoriserRebond[1][0] is True and autoriserRebond[1][1] > 30:
							bounce.change_angle(corps, key, corps[celluleKey]['collisionMemory'][1][1])
							autoriserRebond[1][0] = False
							autoriserRebond[1][1] = 0
					
					else:
						corps[celluleKey]['collisionMemory'][1][1] = corps[celluleKey]['collisionMemory'][1][0]
						autoriserRebond[1][0] = True
			
			autoriserRebond[1][1] += 1
		
		if 'Phagocyte' in key and autoriserDeplacement:
			for bacteriaKey in listeBacteria:
				if collision.collisionCercle(corps['Phagocyte'], corps[bacteriaKey]) is False:
					delKey.append(bacteriaKey)
			for virusKey in listeVirus:
				if collision.collisionCercle(corps['Phagocyte'], corps[virusKey]) is False:
					delKey.append(virusKey)
				
			
			for projectileKey in listeProjectile:
				if collision.collisionCercle(corps['Phagocyte'], corps[projectileKey]) is False:
					if 'Phagocyte' not in delKey:
						delKey.append('Phagocyte')
					if projectileKey not in delKey:
						delKey.append(projectileKey)
			
			for celluleKey in listeCellule:
				corps[celluleKey]['collisionMemory'][0][0] = collision.collisionCellule(corps, key, celluleKey, celluleMap)
				if corps[celluleKey]['collisionMemory'][0][0] is False:
					if autoriserRebond[0][0] is True and autoriserRebond[0][1] > 10:
						bounce.change_angle(corps, key, corps[celluleKey]['collisionMemory'][0][1])
						autoriserRebond[0][0] = False
						autoriserRebond[0][1] = 0
				
				else:
					corps[celluleKey]['collisionMemory'][0][1] = corps[celluleKey]['collisionMemory'][0][0]
					autoriserRebond[0][0] = True
			
			autoriserRebond[0][1] += 1
		
		if 'cellule' in key:
			for projectileKey in listeProjectile:
				if collision.collisionCercle(corps[key], corps[projectileKey]) is False:
					if key not in delKey:
						celluleMap[int(key.strip('cellule'))][2] = 0
						delKey.append(key)
					if projectileKey not in delKey:
						delKey.append(projectileKey)
			if corps[key]["inoculate"][0] is True:
				if corps[key]["inoculate"][1]>=corps[key]["inoculate"][2]:
					virus.lyse(corps, key)
					if key not in delKey:
						celluleMap[int(key.strip('cellule'))][2] = 0
						delKey.append(key)
				else:
					corps[key]["inoculate"][1]+=1

		
		if "virus" in key:
			for celluleKey in listeCellule:
				if collision.collisionCercle(corps[key], corps[celluleKey]) is False:
					delKey.append(key)
					corps[celluleKey]["inoculate"][0]=True
			
		if 'projectile' in key:
			if collision.collisionBord(corps[key]) is False:
				delKey.append(key)
		
		else:
			collision.collisionBord(corps[key])
		
		corps[key]['clock'][0] += 1
	
	# Remove objects
	for key3 in delKey:
		game.supprimerObjet(corps, key3)
	
	return True