Ejemplo n.º 1
0
def animer(dt):
	# Can animate?
	if scene.get() is not 'game':
		return False
	
	# Game won
	if state() is 'win' or state() is 'loose':
		cursor.set('default')
		background.scene_speed('pause')
		
		return False
	
	# Game not paused
	if not paused() and state() is not 'win' and state() is not 'loose':
		if mode.get() is 'bacteria':
			cell.creerCellule(corps)
			creerPhagocyte(corps)
			mitosis.mitose(corps)	
			projectile.creerProjectile(corps)
			dynamics.deplacerCorps(corps)
			set_state(corps)
		elif mode.get() is "virus":
			cell.creerCellule(corps)
			creerPhagocyte(corps)
			virus.creerVirus(corps)
			dynamics.deplacerCorps(corps)
			set_state(corps)

	
	# Schedule the next update
	pyglet.clock.schedule_once(animer, 0.01)
	
	return True
Ejemplo n.º 2
0
def load():
	global i
	i=settings.hasDifficulty()-1
	if mode.get() is "bacteria":
		readxml.readFile(listeFileBacteria[i])
	elif mode.get() is "virus":
		readxml.readFile(listeFileVirus[i])

	medius[i]=readxml.GET_MEDIUS()
	celluleMap=set_celluleMap()
Ejemplo n.º 3
0
def deplacerCorps(corps):
	intervalDeplacement = data.get_modeItem('intervalDeplacement')	
	nombreEnemi = 0
	
	for key in corps.keys():
		if mode.get() is "bacteria":
			if 'bacteria' in key:
				randomAngle(corps[key])
				nombreEnemi += 1
		elif mode.get() is "virus":
			if "virus" in key:
				randomAngle(corps[key])
				nombreEnemi += 1

		if 'cellule' not in key:	
			if corps[key]['clock'][0] >= intervalDeplacement:
				modifVitesseAngle(corps[key])
				corps[key]['clock'][0] = 0
	
	deplacer(corps, nombreEnemi)
	
	return True
Ejemplo n.º 4
0
def set_state(corps):
	global game_state
	# Get game objects
	listeCellule = GET_OBJET('cellule')
	listeBacteria = GET_OBJET('bacteria')
	listeVirus = GET_OBJET("virus")
	inoculate=False
	
	for celluleKey in listeCellule:
		if corps[celluleKey]["inoculate"][0] is True and inoculate is False:
			inoculate=True
	# Game end?
	if listeCellule == []:
		game_state = 'loose'
	if mode.get() is "bacteria":
		if listeBacteria == []:
			game_state = 'win'
	if mode.get() is "virus":
		if listeVirus == [] and inoculate is False:
			game_state = 'win'
	
	return True
Ejemplo n.º 5
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
Ejemplo n.º 6
0
def launch():
	global GAME_PAUSE
	global game_state
	global corps
	
	if mode.get() is "bacteria":
		# Reset everything
		GAME_PAUSE = False
		game_state = 'init'
		corps = {}
		mitosis.reset()
		cell.reset()
		dynamics.reset()
	else:
		# Reset everything
		GAME_PAUSE = False
		game_state = 'init'
		corps = {}
		mitosis.reset()
		cell.reset()
		dynamics.reset()
		virus.reset()
	
	return True