示例#1
0
def render_space_screen():
    seq_duration = 20.0
    fx_timer = 0.0
    while fx_timer < seq_duration:
        dt_sec = clock.update()
        fx_timer += dt_sec
        render.clear()
        render.set_blend_mode2d(render.BlendAlpha)

        x_star = RangeAdjust(fx_timer, 0.0, seq_duration, demo_screen_size[0],
                             -53 * zoom_size())
        x_moon = RangeAdjust(fx_timer, seq_duration * 0.475, seq_duration,
                             demo_screen_size[0], -60 * zoom_size())
        x_planet = RangeAdjust(fx_timer, seq_duration * 0.65, seq_duration,
                               demo_screen_size[0], -95 * zoom_size())

        render.image2d(x_star, (demo_screen_size[1] - 53 * zoom_size()) * 0.5,
                       zoom_size(), "@assets/space_star.png")

        render.image2d(x_moon, (demo_screen_size[1] - 60 * zoom_size()) * 0.5,
                       zoom_size(), "@assets/space_moon.png")

        render.image2d(x_planet, 0, zoom_size(), "@assets/space_planet.png")

        render.set_blend_mode2d(render.BlendOpaque)
        render.flip()
示例#2
0
def render_landscape_screen():
    seq_duration = 40.0
    fx_timer = 0.0
    y_offset = 50
    logo_freq = 6
    while fx_timer < seq_duration:
        dt_sec = clock.update()
        fx_timer += dt_sec
        render.clear()
        render.set_blend_mode2d(render.BlendAlpha)

        render.image2d(
            (demo_screen_size[0] - 320 * zoom_size()) * 0.5,
            (demo_screen_size[1] - (34 + y_offset) * zoom_size()) * 0.5,
            zoom_size(), "@assets/landscape_mountains.png")
        render.image2d(
            (demo_screen_size[0] - 100 * zoom_size()) * 0.5,
            (demo_screen_size[1] - (80 + y_offset) * zoom_size()) * 0.5,
            zoom_size(), "@assets/landscape_stones.png")

        x, y = math.cos(
            fx_timer / seq_duration * math.pi * 2 * logo_freq) * 16, math.sin(
                fx_timer / seq_duration * math.pi * 5 * logo_freq) * 16
        render.image2d(
            (demo_screen_size[0] - (187 + x) * zoom_size()) * 0.5,
            (demo_screen_size[1] - (106 - 80 + y) * zoom_size()) * 0.5,
            zoom_size(), "@assets/logo_exxos.png")

        render.set_blend_mode2d(render.BlendOpaque)
        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()
示例#4
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 render_text_screen(strings=None, duration=4.0, fade_duration=1.0, render_callback=None):

	if strings is None:
		return

	fonts_dict = {}
	fx_timer = 0.0
	while fx_timer < duration:
		dt_sec = clock.update()
		fx_timer += dt_sec

		if fx_timer < fade_duration:
			fade = RangeAdjust(fx_timer, 0.0, fade_duration, 0.0, 1.0)
		else:
			if fx_timer < duration - fade_duration:
				fade = 1.0
			else:
				fade = RangeAdjust(fx_timer, duration - fade_duration, duration, 1.0, 0.0)

		render.clear()
		fonts_dict = render_strings_array(strings, fade, fonts_dict)
		if fade > 0.2:
			if render_callback is not None:
				render_callback()
		render.flip()
def render_text_screen(strings=None,
                       duration=4.0,
                       fade_duration=1.0,
                       render_callback=None):

    if strings is None:
        return

    fonts_dict = {}
    fx_timer = 0.0
    while fx_timer < duration:
        dt_sec = clock.update()
        fx_timer += dt_sec

        if fx_timer < fade_duration:
            fade = RangeAdjust(fx_timer, 0.0, fade_duration, 0.0, 1.0)
        else:
            if fx_timer < duration - fade_duration:
                fade = 1.0
            else:
                fade = RangeAdjust(fx_timer, duration - fade_duration,
                                   duration, 1.0, 0.0)

        render.clear()
        fonts_dict = render_strings_array(strings, fade, fonts_dict)
        if fade > 0.2:
            if render_callback is not None:
                render_callback()
        render.flip()
示例#7
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
示例#8
0
			reset = True

	if lose:
		render.text2d(31.25*size_pixel.x, size.y/4, "You LOSE yourself \nto the devil !", 6.5*size_pixel.x, gameboy_palette[2], font_path="Early GameBoy.ttf")
		render.text2d(size.x/6, size.y/4*3, "Click to Restart", 7.8125*size_pixel.x, gameboy_palette[2], font_path="Early GameBoy.ttf")
		check_clicked()
		draw_pentacle(gs.Vector3(big_resolution.x*0.5, big_resolution.y*0.5, 0), 50, 40)

	if win:
		render.text2d(size.x/20, size.y/4*3.5, "The demon's door is \nnow closed\nCongratulation !", 7.8125*size_pixel.x, gameboy_palette[2], font_path="Early GameBoy.ttf")
		render.text2d(size.x/6, size.y/4, "Click to Restart", 7.8125*size_pixel.x, gameboy_palette[2], font_path="Early GameBoy.ttf")
		check_clicked()

	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 reset:
		radius_circle_eye = radius_circle_eye + (15-radius_circle_eye)*dt_sec
		if abs(radius_circle_eye - 15) < 0.1:
			reset = False

	if not start and not lose:
		if radius_circle_eye < 5.0:
			win = True
			radius_circle_eye -= dt_sec * 10
示例#9
0
def render_mask_screen():
    mask_segment_list = wireframe_json_to_segment_list(
        "@assets/exxos_mask.json")

    scn = scene.new_scene()

    while not scn.IsReady():
        scene.update_scene(scn, 0.0)

    # Add an environment to the scene
    env = gs.Environment()
    env.SetBackgroundColor(gs.Color.Black)
    scn.AddComponent(env)

    # Add a camera
    render_camera = gs.Node()
    render_camera.AddComponent(gs.Transform())
    render_camera.AddComponent(gs.Camera())
    scn.AddNode(render_camera)
    scn.SetCurrentCamera(render_camera)
    render_camera.GetTransform().SetPosition(gs.Vector3(0, 0, -50))

    # Create a (parent) node to rotate the mask
    master_node = gs.Node()
    master_node.AddComponent(gs.Transform())
    scn.AddNode(master_node)

    # Init the starfield
    starfield.init_stars()
    starfield.set_camera_velocity(gs.Vector3(0, 0, -50))

    segment_nodes_list = []
    for seg in mask_segment_list:
        node_a, node_b = gs.Node(), gs.Node()
        tr_a, tr_b = gs.Transform(), gs.Transform()
        tr_a.SetPosition(gs.Vector3(seg[0][0], seg[0][1], seg[0][2]))
        tr_b.SetPosition(gs.Vector3(seg[1][0], seg[1][1], seg[1][2]))
        tr_a.SetParent(master_node)
        tr_b.SetParent(master_node)
        node_a.AddComponent(tr_a)
        node_b.AddComponent(tr_b)
        scn.AddNode(node_a)
        scn.AddNode(node_b)
        segment_nodes_list.append([node_a, node_b])

    seq_duration = 20.0
    fx_timer = 0.0
    while fx_timer < seq_duration:

        render.clear()
        dt_sec = clock.update()

        master_node.GetTransform().SetRotation(
            master_node.GetTransform().GetRotation() +
            gs.Vector3(1, 1, 1) * dt_sec * 0.25)
        scene.update_scene(scn, dt_sec)

        # render.commit_3d()
        # render.set_depth_write3d(False)

        starfield.update_stars(dt_sec)
        starfield.draw_stars(render)

        for seg in segment_nodes_list:
            pos_a = seg[0].GetTransform().GetWorld().GetTranslation()
            pos_b = seg[1].GetTransform().GetWorld().GetTranslation()
            render.line3d(pos_a.x,
                          pos_a.y,
                          pos_a.z,
                          pos_b.x,
                          pos_b.y,
                          pos_b.z,
                          start_color=gs.Color.Blue,
                          end_color=gs.Color.Blue)

        render.flip()

        fx_timer += dt_sec
示例#10
0
def final():
	render.clear()

	# initialize graphic and audio systems

	movie = gs.WebMMovie()
	movie.Open("@data/sylvain_durif.webm")

	video_format = movie.GetVideoData().GetFormat()

	# create the frame textures and frame object
	gpu = render.get_renderer()
	y_tex = gpu.NewTexture()
	gpu.CreateTexture(y_tex, video_format.width, video_format.height, gs.GpuTexture.R8, gs.GpuTexture.NoAA,
					  gs.GpuTexture.UsageDefault, False)
	u_tex = gpu.NewTexture()
	gpu.CreateTexture(u_tex, video_format.width // 2, video_format.height // 2, gs.GpuTexture.R8,
						  gs.GpuTexture.NoAA, gs.GpuTexture.UsageDefault, False)
	v_tex = gpu.NewTexture()
	gpu.CreateTexture(v_tex, video_format.width // 2, video_format.height // 2, gs.GpuTexture.R8,
						  gs.GpuTexture.NoAA, gs.GpuTexture.UsageDefault, False)

	frame = gs.VideoFrame()
	video_format.ClearFrame(frame)
	video_timestamp = gs.time(0)  # assume first frame time stamp is 0

	# load the YV12 to RGB shader and setup drawing states
	shader = gpu.LoadShader("@data/yv12.isl")

	gpu.EnableDepthTest(False)  # disable depth testing so that we don't even need to clear the z-buffer

	# start streaming the movie audio data
	channel = audio.get_mixer().StreamData(movie.GetAudioData())

	# play until movie ends
	while not movie.IsEOF():
		render.clear()
		# fit the while output window
		screen_size = gpu.GetCurrentOutputWindow().GetSize()
		gpu.SetViewport(gs.fRect(0, 0, screen_size.x, screen_size.y))
		gpu.Set2DMatrices()  # update the 2d matrix

		# fetch the next video frame once audio gets past video
		audio_timestamp = audio.get_mixer().GetChannelPosition(channel)  # audio timestamp as reported by the mixer

		if audio_timestamp >= video_timestamp:
			movie.GetVideoData().GetFrame(frame)
			video_timestamp = frame.GetTimestamp()
			gpu.BlitTexture(y_tex, frame.GetPlaneData(gs.VideoFrame.Y), video_format.width, video_format.height)
			gpu.BlitTexture(u_tex, frame.GetPlaneData(gs.VideoFrame.U), video_format.width // 2,
							video_format.height // 2)
			gpu.BlitTexture(v_tex, frame.GetPlaneData(gs.VideoFrame.V), video_format.width // 2,
							video_format.height // 2)

			# draw the current video frame to screen
			vtxs = [gs.Vector3(0, 0, 0.5), gs.Vector3(0, screen_size.y, 0.5),
					gs.Vector3(screen_size.x, screen_size.y, 0.5), gs.Vector3(0, 0, 0.5),
					gs.Vector3(screen_size.x, screen_size.y, 0.5), gs.Vector3(screen_size.x, 0, 0.5)]
			uvs = [gs.Vector2(0, 1), gs.Vector2(0, 0), gs.Vector2(1, 0), gs.Vector2(0, 1), gs.Vector2(1, 0),
				   gs.Vector2(1, 1)]
		render_system = render.get_render_system()
		gpu.SetShader(shader)
		gs.SetShaderEngineValues(render_system)
		gpu.SetShaderTexture("y_tex", y_tex)
		gpu.SetShaderTexture("u_tex", u_tex)
		gpu.SetShaderTexture("v_tex", v_tex)
		render_system.DrawTriangleUV(2, vtxs, uvs)
		render.flip()
示例#11
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
示例#12
0
def gameMainLoop(mouse_device):
    # Update the ball motion
    ball.update(dt)

    # Update the player motion
    player.setMouse(
        mouse_device.GetValue(gs.InputDevice.InputAxisX) / SCR_DISP_WIDTH,
        mouse_device.GetValue(gs.InputDevice.InputAxisY) / SCR_DISP_HEIGHT)
    player.update(dt)

    # Update the AI
    ai.updateGameData(ball.pos_x, ball.pos_z, board.board_width,
                      board.board_length)
    ai.update(dt)

    # Collisions
    if ball.velocity_z > 0.0:
        if (not ballIsBehindRacket(ball, player)) and (BallWasWithinXReach(
                ball, player) or BallIsWithinXReach(ball, player)):
            ball.setPosition(
                ball.pos_x, player.pos_z - ball.velocity_z * dt +
                min(0.0, player.velocity_z) * dt)
            player.setPosition(player.pos_x, ball.pos_z + player.length)
            ball.bounceZ()

    # Compute 3D/2D projections
    ball_2d_x, ball_2d_y, ball_2d_scale = project3DTo2D(
        ball.pos_x, ball.pos_z, board.board_width, board.board_length)
    ball_2d_x *= SCR_SCALE_FACTOR
    ball_2d_y = SCR_DISP_HEIGHT - (ball_2d_y * SCR_SCALE_FACTOR)

    player_2d_x, player_2d_y, player_2d_scale = project3DTo2D(
        player.pos_x, player.pos_z, board.board_width, board.board_length)
    player_2d_x *= SCR_SCALE_FACTOR
    player_2d_y = SCR_DISP_HEIGHT - (player_2d_y * SCR_SCALE_FACTOR)

    ai_2d_x, ai_2d_y, ai_2d_scale = project3DTo2D(ai.pos_x, ai.pos_z,
                                                  board.board_width,
                                                  board.board_length)
    ai_2d_x *= SCR_SCALE_FACTOR
    ai_2d_y = SCR_DISP_HEIGHT - (ai_2d_y * SCR_SCALE_FACTOR)

    render.clear()
    render.set_blend_mode2d(render.BlendAlpha)
    # Opponent
    render.sprite2d(SCR_MARGIN_X + (320 * 0.5) * SCR_SCALE_FACTOR,
                    (SCR_PHYSIC_HEIGHT - 96 * 0.5) * SCR_SCALE_FACTOR,
                    106 * SCR_SCALE_FACTOR, "@assets/robot5.png")

    # Game board
    render.image2d(SCR_MARGIN_X, 0, SCR_SCALE_FACTOR, "@assets/game_board.png")

    # Score panel
    render.image2d(SCR_MARGIN_X, SCR_DISP_HEIGHT - (32 * SCR_SCALE_FACTOR),
                   SCR_SCALE_FACTOR, "@assets/game_score_panel.png")

    # Render moving items according to their Z position
    renderAI(ai_2d_x, ai_2d_y, ai_2d_scale)

    if ball.pos_z - ball.radius < player.pos_z + player.length:
        renderBall(ball_2d_x, ball_2d_y, ball_2d_scale)
        renderPlayer(player_2d_x, player_2d_y, player_2d_scale)
    else:
        renderPlayer(player_2d_x, player_2d_y, player_2d_scale)
        renderBall(ball_2d_x, ball_2d_y, ball_2d_scale)

    render.set_blend_mode2d(render.BlendOpaque)
示例#13
0
for spr_file in os.listdir("data/"):

    if not spr_file.startswith("scaled_"):
        render.init(512, 512, "../pkg.core")

        spr_pic = gs.LoadPicture("@data/" + spr_file)
        w, h = spr_pic.GetWidth(), spr_pic.GetHeight()

        render.uninit()

        render.init(w * scaled_copies, h, "../pkg.core")

        capture_buffer = gs.Picture(w * scaled_copies, h, gs.Picture.RGBA8)

        for i in range(2):
            render.clear(gs.Color(1, 0, 1))
            for i in range(scaled_copies):
                sprite_scale_factor = RangeAdjust(float(i), 0.0,
                                                  float(scaled_copies), 1.0,
                                                  min_factor)
                render.image2d(i * w + (w * (1.0 - sprite_scale_factor) * 0.5),
                               h * (1.0 - sprite_scale_factor) * 0.5,
                               sprite_scale_factor, "@data/" + spr_file)
            # render.sprite2d(512 - 64, 512 - 64, 128, "@data/blink.jpg")
            # render.blit2d(0, 0, 512, 512, 80, 80, 512 - 160, 512 - 160, "@data/owl.jpg")
            render.flip()

        render.get_renderer().CaptureFramebuffer(capture_buffer)
        gs.SavePicture(capture_buffer, "@data/" + "scaled_" + spr_file, 'STB',
                       'format:png')
示例#14
0
	#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()

	render.flip()