Beispiel #1
0
def intro():
	text_blink = 0.0
	angle = 0
	fps = camera.fps_controller(0, 2, -10)
	fps.update(clock.update())
	render.set_camera3d(fps.pos.x, fps.pos.y, fps.pos.z, fps.rot.x, fps.rot.y, fps.rot.z)
	while not input.key_press(gs.InputDevice.KeyEnter):
		render.clear(gs.Color.White)
		text_blink += clock.update()
		if text_blink > 1.0:
			text_blink = 0.0

		# Effet de background animé à la "Street Fighter" (hem)
		dessine_fond_qui_scroll()
		for z in range(-100, 100, 5):
			for x in range(-100, 100, 5):
				render.geometry3d(x, 0, z, cube)

		afficheTexte(500, 400, 'Quel est ton gourou ?', size=2)
		afficheTexte(500, 365, 'Choisis le sens de ta vie ~~~~~~~~~~~~~~')
		afficheTexte(500, 325, '...et appuie sur [enter]', text_blink)
		afficheTexte(815,20, 'Made by Trofis #CODE and Safae #DESIGN' , size=0.5)
		render.flip()
		angle += 0.01

	while input.key_press(gs.InputDevice.KeyEnter):
		render.clear()
		render.flip()
def play_simulation():
	while not input.key_press(gs.InputDevice.KeyEscape):
		clock.update()
		fps.update(clock.get_dt())
		render.set_camera3d(fps.pos.x, fps.pos.y, fps.pos.z, fps.rot.x, fps.rot.y, fps.rot.z)

		render.clear()

		for perso in array_perso:
			perso.draw()
			perso.update(physic_world)

		array_perso[0].kohonen_behaviour.draw(render.get_renderer().GetCurrentOutputWindow().GetSize().x, render.get_renderer().GetCurrentOutputWindow().GetSize().y)

		physic_world.draw()

		# render text
		if input.key_down(gs.InputDevice.KeyL):
			render.text2d(10, 120, 'Frag in Mem: %d' % KohonenBehaviour.memory.GetNbFragment())
			for action in range(perso_actions.nb_actions):
				render.text2d(10, 140 + 20*action, 'Frag for %s: %d, %d%%' % (perso_actions.get_current_action_name(action), KohonenBehaviour.memory.m_NbFragmentPerActionArray[action], KohonenBehaviour.memory.m_TabPercentFragmentPerAction[action]), 12, array_perso[0].kohonen_behaviour.color_array[action])

		render.text2d(10, 50, str(perso.selected_action)+" "+perso_actions.get_current_action_name(perso.selected_action))

		#draw it to the screen
		render.flip()
    def edition_scene3d(cls):
        noeuds=cls.scene3d.GetNodes()
        if input.key_press(gs.InputDevice.KeySpace):
            if input.key_down(gs.InputDevice.KeyLShift):
                cls.noeud_actuel-=1
                if cls.noeud_actuel<0:
                    cls.noeud_actuel=len(noeuds)-1
            else:
                cls.noeud_actuel+=1
                if cls.noeud_actuel>=len(noeuds):
                    cls.noeud_actuel=0

        if input.key_press(gs.InputDevice.KeyBackspace):
            cls.drapeau_lumieres_actives=not cls.drapeau_lumieres_actives
            if not cls.drapeau_lumieres_actives:
                for noeud in noeuds:
                    if not noeud.GetLight()==None:
                        noeud.GetLight().SetDiffuseIntensity(0.)
                        noeud.GetLight().SetSpecularIntensity(0.)
            else:
                i=0
                for noeud in noeuds:
                    if not noeud.GetLight()==None:
                        noeud.GetLight().SetDiffuseIntensity(cls.lumieres_intens_mem[2*i])
                        noeud.GetLight().SetSpecularIntensity(cls.lumieres_intens_mem[2*i+1])
                        i+=1

        listing_sprites(cls.liste_sprites_scene,cls.sprite_actuel,gs.Color.Red,gs.Color.Green)
        listing_noeuds(noeuds,cls.noeud_actuel,gs.Color.Red,gs.Color.Green)
        listing_components(cls.components,0)
        affiche_donnees_environnement(cls.environnement,300,450)
        affiche_donnees_camera(cls.camera,300)
        affiche_donnees_lumiere(cls.lumiere_soleil,600)
        affiche_donnees_noeud(noeuds[cls.noeud_actuel],  gs.Color.Yellow)
        maj_zoom(cls.camera)
        edit_noeud(noeuds[cls.noeud_actuel])


        cls.cube_l_ciel.GetTransform().SetPosition(cls.lumiere_ciel.GetTransform().GetPosition())
        cls.cube_l_ciel.GetTransform().SetRotation(cls.lumiere_ciel.GetTransform().GetRotation())
        cls.cube_l_soleil.GetTransform().SetPosition(cls.lumiere_soleil.GetTransform().GetPosition())
        cls.cube_l_soleil.GetTransform().SetRotation(cls.lumiere_soleil.GetTransform().GetRotation())
Beispiel #4
0
def generation(gourou, gourou_index_list):
	print(gourou_index_list)
	index_gourou = (gourou_index_list[0] + gourou_index_list[1] * 3) + 1
	while not input.key_press(gs.InputDevice.KeyEnter):
		render.clear(gs.Color.White)
		# dessine_fond_qui_scroll()

		afficheTexte(800, 500, 'Voyons désormais quel est ton Gourou ....')
		# render.set_blend_mode2d(1)
		# render.image2d((1920-400)/2,(1024-350)/2,1.0,'@data/gourou' + str(index_gourou) + '.png')
		# render.set_blend_mode2d(0)
		render.flip()
	render.flip()
	# print(render.get_font(lesGourou [index_gourou]))
	gourou_scale = 0.25
	gourou_acc = 0.995
	y_offset = 0.0
	while not input.key_press(gs.InputDevice.KeyEnter):
		render.clear(gs.Color.White)
		dessine_fond_qui_scroll()
		afficheTexte(700, 850, lesGourou[index_gourou-1]  )
		# afficheTexte(1050, 400, 'Au coeur ' + str(getTxt(phases, 1, indexImg[0], indexImg[1])))
		# afficheTexte(1100, 300, 'Qui regarda '+str(getTxt(phases,2,indexImg[1], indexImg[2] )))
		render.set_blend_mode2d(1)
		gourou_scale_tmp = gourou_scale * 1.5
		render.image2d((1920 - (400 * gourou_scale_tmp)) / 2,
					   (1024 - (350 * gourou_scale_tmp)) / 2 + y_offset * (1.0 - gourou_scale * gourou_scale),
					   gourou_scale_tmp, '@data/gourou' + str(index_gourou) + '.png')
		render.set_blend_mode2d(0)
		render.flip()

		gourou_scale = (gourou_scale * gourou_acc + (1.0 - gourou_acc))
		y_offset = y_offset * 0.95 + 0.5 * random.randint(-15, 15)
	render.flip()

	return index_gourou - 1
		draw_line(pos.x+cursor_point[4].x, pos.y+cursor_point[4].y, lerp(timeline-3, pos.x+cursor_point[4].x, pos.x+cursor_point[0].x), lerp(timeline-3, pos.y+cursor_point[4].y, pos.y+cursor_point[0].y), get_random_color())
	if 4 < timeline < 5:
		draw_line(lerp(timeline-4, pos.x+cursor_point[4].x, pos.x+cursor_point[0].x), lerp(timeline-4, pos.y+cursor_point[4].y, pos.y+cursor_point[0].y), pos.x+cursor_point[0].x, pos.y+cursor_point[0].y, get_random_color())
		draw_line(pos.x+cursor_point[0].x, pos.y+cursor_point[0].y, lerp(timeline-4, pos.x+cursor_point[0].x, pos.x+cursor_point[1].x), lerp(timeline-4, pos.y+cursor_point[0].y, pos.y+cursor_point[1].y), get_random_color())


def draw_cursor():
	mouse_pos = input.get_mouse_pos()
	mouse_pos = gs.Vector3(mouse_pos[0] / size_pixel.x, mouse_pos[1] / size_pixel.y, 0)

	draw_pentacle(mouse_pos, 5, 15)

reduce_speed = 15
increase_speed = 15

while not input.key_press(gs.InputDevice.KeyEscape) and not exit:
	dt_sec = clock.update()
	time_pass += dt_sec

	def check_clicked():
		global radius_circle_eye, counter_seed, lose, win, array_point, array_size_point, array_full_point, array_id_line, next_symbol, reducing, start, reset
		if not input.mouse_button_was_down() and input.mouse_button_down():
			counter_seed = 0
			lose = False
			win = False
			array_point = []
			array_size_point = []
			array_full_point = []
			array_id_line = []
			next_symbol = True
			reducing = 0.0
            new_cube = scene.add_physic_cube(scn, world, width, height, length,
                                             2)
            node_list.append(new_cube[0])

# fps = camera.fps_controller(0, 3.5, -12.5)

thrown_bullet = False
fixed_step = True
record_motion = False
record_done = False

dt_sum = 0.0

# Start simulation & record

while not input.key_press(gs.InputDevice.KeyEscape) and not record_done:
    if fixed_step:
        dt_sec = 1.0 / 120.0
    else:
        dt_sec = clock.update()

    dt_sum += dt_sec
    print(dt_sum)

    if not thrown_bullet and dt_sum > 1.0:
        world = gs.Matrix4.TransformationMatrix(make_solid_pos(-0.25, 40),
                                                gs.Vector3())
        new_cube, rigid_body = scene.add_physic_cube(scn, world, width, height,
                                                     length, 2)
        rigid_body.ApplyLinearImpulse(world.GetY() * -5)
        node_list.append(new_cube)
            )
            new_cube = scene.add_physic_cube(scn, world, width, height, length, 2)
            node_list.append(new_cube[0])

# fps = camera.fps_controller(0, 3.5, -12.5)

thrown_bullet = False
fixed_step = True
record_motion = False
record_done = False

dt_sum = 0.0

# Start simulation & record

while not input.key_press(gs.InputDevice.KeyEscape) and not record_done:
    if fixed_step:
        dt_sec = 1.0 / 120.0
    else:
        dt_sec = clock.update()

    dt_sum += dt_sec
    print(dt_sum)

    if not thrown_bullet and dt_sum > 1.0:
        world = gs.Matrix4.TransformationMatrix(make_solid_pos(-0.25, 40), gs.Vector3())
        new_cube, rigid_body = scene.add_physic_cube(scn, world, width, height, length, 2)
        rigid_body.ApplyLinearImpulse(world.GetY() * -5)
        node_list.append(new_cube)

        world = gs.Matrix4.TransformationMatrix(make_solid_pos(-0.65, 55), gs.Vector3())
Beispiel #8
0
def selection():
	global indexImg
	Gourou = []
	gourou_index_list = []
	indexDecor = 0
	indexEntrer = -1
	amplitude = 1
	indexImg = {}
	for phase in range(len(phases)):

		joue_sfx_phase()
		entrer = False
		angle = 0

		while not entrer:
			render.clear(gs.Color.White)
			# dessine_fond_qui_scroll()

			if input.key_press(gs.InputDevice.KeyLeft) and indexDecor > 0:
				indexDecor = (indexDecor - 1) % getImgParPha(phases)
				# joue_sfx_selection()
				amplitude = 1

			if input.key_press(gs.InputDevice.KeyRight) and indexDecor < getImgParPha(phases) - 1:
				indexDecor = (indexDecor + 1) % getImgParPha(phases)
				# joue_sfx_selection()
				amplitude = 1

			if indexDecor >= 0:

				amplitude *= 0.95

			yOffSet = [0, 0, 0]

			# print(indexDecor)
			render.set_blend_mode2d(1)
			afficheImageNot(430, 165 + 25, 1, '@data/ornement_gauche.png')
			afficheImageNot(1090, 165 + 25, 1, '@data/ornement_droite.png')
			render.set_blend_mode2d(0)
			if phase == 0:
				yOffSet[indexDecor] = random.randint(-5, 5)
				afficheImage((SCREEN_W - 1050) / 2, 285 + random.randint(-25, 25) * amplitude, phase, 1.0, indexDecor,
							 0)
				afficheTexte(800, 220 + 25, 'OÙ VEUX TU TE RETIRER ?', size=0.75)
				render.set_blend_mode2d(1)
				afficheImageNot(600, 50, 1, '@data/choix_paysage.png')
				render.set_blend_mode2d(0)
				if indexDecor == 0:
					afficheTexte(620, 25 + yOffSet[0], getTxt(phases, phase, 0, 0))
				if indexDecor == 1:
					afficheTexte(890, 25 + yOffSet[1], getTxt(phases, phase, 0, 1))
				if indexDecor == 2:
					afficheTexte(1165, 25 + yOffSet[2], getTxt(phases, phase, 0, 2))

			elif phase == 1:
				yOffSet[indexDecor] = random.randint(-5, 5)
				afficheImage((SCREEN_W - 1050) / 2, 285 + random.randint(-25, 25) * amplitude, phase, 1.0, indexDecor,
							 indexImg[phase - 1])
				afficheTexte(740, 220 + 25, 'CHOISIS UNE AMBIANCE MYSTIQUE', size=0.75)
				render.set_blend_mode2d(1)
				afficheImageNot(600, 50, 1, '@data/choix_ambiance.png')
				render.set_blend_mode2d(0)

				# print(indexImg)

				if indexDecor == 0:
					afficheTexte(600, 25 + yOffSet[0], getTxt(phases, phase, indexImg[phase - 1], indexDecor),
								 size=0.75)

				if indexDecor == 1:
					afficheTexte(840, 25 + yOffSet[1], getTxt(phases, phase, indexImg[phase - 1], indexDecor),
								 size=0.75)

				if indexDecor == 2:
					afficheTexte(1050, 25 + yOffSet[2], getTxt(phases, phase, indexImg[phase - 1], indexDecor),
								 size=0.75)

			else:
				yOffSet[indexDecor] = random.randint(-5, 5)
				afficheImage((SCREEN_W - 1050) / 2, 285 + random.randint(-25, 25) * amplitude, phase, 1.0, indexDecor,
							 indexImg[phase - 1])
				afficheTexte(700, 220 + 25, 'CHOISIS UN TRUC A OBSERVER', size=0.85)
				render.set_blend_mode2d(1)
				afficheImageNot(600, 50, 1, '@data/choix_paysage.png')
				render.set_blend_mode2d(0)

				if indexDecor == 0:
					afficheTexte(670, 25 + yOffSet[0], getTxt(phases, phase, indexImg[phase - 1], indexDecor))

				if indexDecor == 1:
					afficheTexte(900, 25 + yOffSet[1], getTxt(phases, phase, indexImg[phase - 1], indexDecor))

				if indexDecor == 2:
					afficheTexte(1180, 25 + yOffSet[2], getTxt(phases, phase, indexImg[phase - 1], indexDecor))


			if input.key_press(gs.InputDevice.KeyEnter):

				gourou_index_list.append(indexDecor)
				entrer = True
				indexEntrer = indexDecor
				if phase == 0:
					Gourou.append(getTxt(phases, phase, 0, indexDecor))
				else:
					Gourou.append(getTxt(phases, phase, indexImg[phase - 1], indexDecor))

			if entrer:
				indexImg[phase] = indexEntrer

			# if phase > 0:
			#     for index in range(len(indexImg)):
			#         if index != 2:
			#             render.set_blend_mode2d(1)
			#             afficheImage(100+(600*(index)), 400, index , 0.6, indexImg[index])
			#             render.set_blend_mode2d(0)
			#         else:
			#             render.set_blend_mode2d(1)
			#             afficheImage(450, 100, index , 0.6, indexImg[index])
			#             render.set_blend_mode2d(0)

			render.flip()
		render.flip()

		# prochaine phase, on joue un son de "selection"
		joue_sfx_selection()

	return Gourou, gourou_index_list
Beispiel #9
0
SCR_DISP_WIDTH = 320 * 2
SCR_DISP_HEIGHT = 200 * 2

SCR_SCALE_FACTOR = min(SCR_DISP_WIDTH / SCR_PHYSIC_WIDTH,
                       SCR_DISP_HEIGHT / SCR_PHYSIC_HEIGHT)
SCR_MARGIN_X = (SCR_DISP_WIDTH - (SCR_PHYSIC_WIDTH * SCR_SCALE_FACTOR)) / 2.0

gs.LoadPlugins(gs.get_default_plugins_path())

render.init(SCR_DISP_WIDTH, SCR_DISP_HEIGHT, "pkg.core")

# provide access to the data folder
gs.MountFileDriver(gs.StdFileDriver("assets/"), "@assets/")

gameReset()
player.initial_pox_z = (board.board_length * 0.45)
player.reset()

while not input.key_press(gs.InputDevice.KeyEscape):
    dt = clock.update()  # 1.0 / 60.0

    # update mouse
    gs.GetInputSystem().Update()

    # get the mouse device
    mouse_device = gs.GetInputSystem().GetDevice("mouse")

    gameMainLoop(mouse_device)

    render.flip()
Beispiel #10
0
    gestion_signal_scene(Demo.signal_scene)


    # ---- Rendu de la scène:

    Demo.Scene_actuelle.maj_cinetique()
    Demo.signal_scene=Demo.Scene_actuelle.maj_physique()  #Si il y a des réactions aux mouvements.

    # ---- Mise à jour Caméra:

    Demo.Scene_actuelle.maj_camera()


    # ----- Edition:

    if input.key_press(gs.InputDevice.KeyF12):
        Demo.Scene_actuelle.edit_id+=1
        if Demo.Scene_actuelle.edit_id>Demo.Scene_actuelle.NUM_PAGES_EDIT: Demo.Scene_actuelle.edit_id=0

    if Demo.Scene_actuelle.edit_id!=Scene_base.EDIT_OFF: Demo.drapeau_camera_controle_utilisateur=False
    else: Demo.drapeau_camera_controle_utilisateur=True

    if Demo.Scene_actuelle.edit_id!=Scene_base.EDIT_OFF:
        Demo.Scene_actuelle.edition()

    # --- Message système:
    if Demo.drapeau_erreur:
        Demo.affiche_message_erreur()
        Demo.drapeau_erreur=False

    # ----- Affichage des sprites de la scène:
	#launch fade out with the new scene
	if state == state_fade_out:
		fade_percent -= fade_speed * globals.dt_sec
		if fade_percent < 0:
			fade_percent = 0
			state = state_ready

	if fade_percent > 0:
		color = gs.Color(0, 0, 0, fade_percent)
		size = render.get_renderer().GetCurrentOutputWindow().GetSize()
		render.triangle2d(0, 0, size.x, size.y, size.x, 0, color, color, color)
		render.triangle2d(0, 0, 0, size.y, size.x, size.y, color, color, color)


while not input.key_press(gs.InputDevice.KeyEscape):
	globals.dt_sec = clock.update()

	render.clear(gs.Color.Black)

	if state == state_ready or state == state_fade_out:
		if globals.current_scene is not None:
			globals.current_scene.draw()
			globals.current_scene.update()
	else:
		if globals.prev_scene_fade is not None:
			globals.prev_scene_fade.draw()
			globals.prev_scene_fade.update()

	fade_between_scene()
Beispiel #12
0
def get_random_color():
	return gameboy_palette[random.randint(0, len(gameboy_palette)-1)]


def lerp(x, a, b):
	return a + (b - a)*x

default_font = gs.RasterFont("@core/fonts/default.ttf", 12)
radius_circle_eye = 10
counter_seed = 0
time_pass = 0.0

inverse = False

while not input.key_press(gs.InputDevice.KeyEscape):
	dt_sec = clock.update()
	time_pass += dt_sec

	random.seed(counter_seed)

	render.clear(gs.Color(16/255, 19/255, 12/255))
	# render.clear(gs.Color.Black)

	draw_circle_explosion(big_resolution.x * .5, big_resolution.y * .5, radius_circle_eye, 10, get_random_color())
	draw_circle(big_resolution.x * .5, big_resolution.y * .5, lerp(abs(math.cos(time_pass*3)), radius_circle_eye, radius_circle_eye + 10), get_random_color())
	draw_circle(big_resolution.x * .5, big_resolution.y * .5, radius_circle_eye + 10, get_random_color())

	if inverse:
		radius_circle_eye -= dt_sec * 30
	else:
Beispiel #13
0
    # Placé ici car il faut laissé au rendu précédent le temps de se dérouler normalement.
    gestion_signal_scene(Demo.signal_scene)

    # ---- Rendu de la scène:

    Demo.Scene_actuelle.maj_cinetique()
    Demo.signal_scene = Demo.Scene_actuelle.maj_physique(
    )  #Si il y a des réactions aux mouvements.

    # ---- Mise à jour Caméra:

    Demo.Scene_actuelle.maj_camera()

    # ----- Edition:

    if input.key_press(gs.InputDevice.KeyF12):
        Demo.Scene_actuelle.edit_id += 1
        if Demo.Scene_actuelle.edit_id > Demo.Scene_actuelle.NUM_PAGES_EDIT:
            Demo.Scene_actuelle.edit_id = 0

    if Demo.Scene_actuelle.edit_id != Scene_base.EDIT_OFF:
        Demo.drapeau_camera_controle_utilisateur = False
    else:
        Demo.drapeau_camera_controle_utilisateur = True

    if Demo.Scene_actuelle.edit_id != Scene_base.EDIT_OFF:
        Demo.Scene_actuelle.edition()

    # --- Message système:
    if Demo.drapeau_erreur:
        Demo.affiche_message_erreur()
def update():
	global dt_sec
	dt_sec = clock.update()
	scene.update_scene(scn, dt_sec)
	if input.key_press(gs.InputDevice.KeyEnter):
		globals.current_scene = level_game