Пример #1
0
def inlevel_redraw_screen( gamestate ):
	maze_colour = mopelib.dim_colour( gamestate.config.colour_maze,
		gamestate.dim )
	duck_colour = mopelib.dim_colour( gamestate.config.colour_duck,
		gamestate.dim )

	if gamestate.dim != gamestate.old_dim:
		bgcol = mopelib.dim_colour( gamestate.cur_lev.background_colour,
			gamestate.dim )
		ingame_surface_background.fill( bgcol )
		gamestate.old_dim = gamestate.dim

	screen.blit( ingame_surface_background, (0,0) )

	lev = gamestate.cur_lev
	for y in range( len( lev.lines_hor ) ):
		for x in range( len( lev.lines_hor[y] ) ):
			pos = lev.lines_hor[y][x]
			if pos == 1:
				pygame.draw.rect( screen, maze_colour,
					( screen_border + scale[0] * (x + 0.1),
					  screen_border + scale[1] * y,
					  scale[0] * 0.92, scale[1] * 0.1 ) )

	for y in range( len( lev.lines_ver ) ):
		for x in range( len( lev.lines_ver[y] ) ):
			pos = lev.lines_ver[y][x]
			if pos == 1:
				pygame.draw.rect( screen, maze_colour,
					( screen_border + scale[0] * x,
					  screen_border + scale[1] * (y + 0.1),
					  scale[0] * 0.1, scale[1] * 0.92 ) )

	if( lev.position[0] >=0 and lev.position[0] < config.arena_size[0] and
			lev.position[1] >=0 and lev.position[1] < config.arena_size[1] ):
		duck_size = int( scale[1] * 0.3 )
		duck_pos = ( int( screen_border + scale[0] * ( lev.position[0] + 0.495 ) ),
					 int( screen_border + scale[1] * ( lev.position[1] + 0.495 ) ) )
		pygame.draw.circle( screen, duck_colour, duck_pos, duck_size )
		pygame.draw.circle( screen, maze_colour, duck_pos, duck_size+1, 1 )

		if lev.direction == level.DIR_UP:
			end_pos_inc = ( 0, -duck_size )
		elif lev.direction == level.DIR_RIGHT:
			end_pos_inc = ( duck_size, 0 )
		elif lev.direction == level.DIR_DOWN:
			end_pos_inc = ( 0, duck_size )
		elif lev.direction == level.DIR_LEFT:
			end_pos_inc = ( -duck_size, 0 )

		pygame.draw.line( screen, maze_colour, duck_pos,
			( duck_pos[0] + end_pos_inc[0], duck_pos[1] + end_pos_inc[1] ) )

	write_text_ingame( gamestate )

	pygame.display.update()
Пример #2
0
def write_text_ingame( gamestate ):
	global ingame_font

	bgcol = mopelib.dim_colour( gamestate.cur_lev.background_colour,
		gamestate.dim )
	fgcol = mopelib.dim_colour( gamestate.cur_lev.text_colour, gamestate.dim )

	write_text_blank_font_coords( "Level: %d" % ( gamestate.level_num + 1 ),
		fgcol, ingame_font, bgcol, 0.3, 0.99 )

	write_text_blank_font_coords( "Time: %s" % gamestate.cur_lev.current_time,
		fgcol, ingame_font, bgcol, 0.7, 0.99 )