Esempio n. 1
0
 def __init_psyco(self):
     try:
         from psyco import background
         background()
     except ImportError:
         pass
     return False
Esempio n. 2
0
	def __init_psyco(self):
		try:
			from psyco import background
			background()
		except ImportError:
			pass
		return False
Esempio n. 3
0
def init(screen_size=None,
         screen_size_2d=None,
         use_psyco=True,
         icon_image=None,
         fullscreen=False,
         hwrender=True,
         decorated=True):
    """Initialize the display, OpenGL and whether to use psyco or not.
       screen_size must be the pixel dimensions of the display window (defaults to 640x480)
       screen_size_2d is the 2d size of the screen that the 2d elements use (defaults to screen_size),
           the 2d elements are handled as if this is the real screen size,
           and then scaled to fit the real screen size at render time,
           this allows multiple screen resolutions without resorting to hacking the 2d or,
           like some 3d engines do, make the 2d elements really 3d that are projected funny.
       use_psyco must be a boolean value indicating whether psyco should be used or not (only if available)
       icon_image must be a string indicating the image to load from disk, or a pygame Surface to use for the window icon
       full_screen indicates whether the render screen is fullscreen or not
       hwrender indicates whether hwrendering should be used for pygame operations
       decorated indicates whether the display window should have a border and top bar or not"""
    if screen_size and not screen_size_2d:
        screen_size_2d = screen_size

    screen_size = screen.set_size(screen_size, screen_size_2d)

    if use_psyco:
        try:
            import psyco
            psyco.background()
        except:
            pass

    screen.fullscreen = fullscreen
    screen.hwrender = hwrender
    screen.decorated = decorated

    pygame.init()

    if type(icon_image) is type(""):
        pygame.display.set_icon(pygame.image.load(icon_image))
    elif icon_image:
        pygame.display.set_icon(icon_image)
    screen.icon = icon_image

    set_title()

    build_screen()

    glEnable(GL_TEXTURE_2D)
    glEnable(GL_COLOR_MATERIAL)
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE)

    glEnable(GL_LIGHTING)
    glEnable(GL_NORMALIZE)
    glShadeModel(GL_SMOOTH)
    glEnable(GL_DEPTH_TEST)
    glDepthFunc(GL_LEQUAL)
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
    glEnable(GL_SCISSOR_TEST)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    glEnable(GL_BLEND)

    glPointSize(10)

    clear_screen()
    set_fog_color()
    glFogi(GL_FOG_MODE, GL_LINEAR)
    glFogf(GL_FOG_DENSITY, .35)
    glHint(GL_FOG_HINT, GL_NICEST)
    glFogf(GL_FOG_START, 10.0)
    glFogf(GL_FOG_END, 125.0)
    set_fog(True)
    glAlphaFunc(GL_GEQUAL, .5)
    set_background_color()

    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)

    glFrontFace(GL_CCW)
    glCullFace(GL_BACK)
    glEnable(GL_CULL_FACE)

    screen.have_init = True
Esempio n. 4
0
import util
import rules, ai

import gui, wui
import config

import random

import time, os, sys

SCROLL_SPEED = 12

try:
    import psyco
    psyco.background()
except:
    pass

def make_map_players(world, num_players=7, num_ai=6):
    if num_players < 2:num_players = 2
    if num_players > 7:num_players = 7
    if num_ai < 0:num_ai = 0
    if num_ai > 7:num_ai = 7
    mg = MapGrid(util.make_random_map())

    world.grid = mg
    world.map_size = ()

    players = []
    pterr = list(mg.comp_terrs)
Esempio n. 5
0
def init(screen_size=None, screen_size_2d=None,
         use_psyco=True, icon_image=None,
         fullscreen=False, hwrender=True,
         decorated=True):
    """Initialize the display, OpenGL and whether to use psyco or not.
       screen_size must be the pixel dimensions of the display window (defaults to 640x480)
       screen_size_2d is the 2d size of the screen that the 2d elements use (defaults to screen_size),
           the 2d elements are handled as if this is the real screen size,
           and then scaled to fit the real screen size at render time,
           this allows multiple screen resolutions without resorting to hacking the 2d or,
           like some 3d engines do, make the 2d elements really 3d that are projected funny.
       use_psyco must be a boolean value indicating whether psyco should be used or not (only if available)
       icon_image must be a string indicating the image to load from disk, or a pygame Surface to use for the window icon
       full_screen indicates whether the render screen is fullscreen or not
       hwrender indicates whether hwrendering should be used for pygame operations
       decorated indicates whether the display window should have a border and top bar or not"""
    if screen_size and not screen_size_2d:
        screen_size_2d = screen_size

    screen_size = screen.set_size(screen_size, screen_size_2d)

    if use_psyco:
        try:
            import psyco
            psyco.background()
        except:
            pass

    screen.fullscreen = fullscreen
    screen.hwrender = hwrender
    screen.decorated = decorated

    pygame.init()

    if type(icon_image) is type(""):
        pygame.display.set_icon(pygame.image.load(icon_image))
    elif icon_image:
        pygame.display.set_icon(icon_image)
    screen.icon = icon_image

    set_title()

    build_screen()

    glEnable(GL_TEXTURE_2D)
    glEnable(GL_COLOR_MATERIAL)
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    glEnable(GL_LIGHTING)
    glEnable(GL_NORMALIZE)
    glShadeModel(GL_SMOOTH)
    glEnable(GL_DEPTH_TEST)
    glDepthFunc(GL_LEQUAL)
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
    glEnable(GL_SCISSOR_TEST)
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
    glEnable(GL_BLEND)

    glPointSize(10)

    clear_screen()
    set_fog_color()
    glFogi(GL_FOG_MODE, GL_LINEAR)
    glFogf(GL_FOG_DENSITY, .35)
    glHint(GL_FOG_HINT, GL_NICEST)
    glFogf(GL_FOG_START, 10.0)
    glFogf(GL_FOG_END, 125.0)
    set_fog(True)
    glAlphaFunc(GL_GEQUAL, .5)
    set_background_color()

    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)

    glFrontFace(GL_CCW)
    glCullFace(GL_BACK)
    glEnable(GL_CULL_FACE)

    screen.have_init = True