Example #1
0
def init():
    global Levels, initialized
    curlev = []
    f = game.get_resource('levels.txt')
    f = open(f, 'r')
    curtitle = curtitle2 = ''
    while 1:
        l = f.readline()
        if l and l[0] == '>':
            curtitle = l[1:].strip()
            continue
        if l and l[0] == '<':
            curtitle2 = l[1:].strip()
            continue
        if curlev and (not l or l[0] == '!'):
            for _ in range(7-len(curlev)):
                curlev.append('         ')
            curlev.insert(0, curtitle2)
            curlev.insert(0, curtitle)
            Levels.append(curlev)
            curtitle = curtitle2 = ''
            curlev = []
        if not l: break
        if l[0] == '!' or l[0] == ';':
            continue
        if len(curlev) < 7:
            l = (l.rstrip() + '          ')[:9]
            curlev.append(l)
    initialized = 1
Example #2
0
def init():
    global Levels, initialized
    curlev = []
    f = game.get_resource('levels.txt')
    f = open(f, 'r')
    curtitle = curtitle2 = ''
    while 1:
        l = f.readline()
        if l and l[0] == '>':
            curtitle = l[1:].strip()
            continue
        if l and l[0] == '<':
            curtitle2 = l[1:].strip()
            continue
        if curlev and (not l or l[0] == '!'):
            for _ in range(7 - len(curlev)):
                curlev.append('         ')
            curlev.insert(0, curtitle2)
            curlev.insert(0, curtitle)
            Levels.append(curlev)
            curtitle = curtitle2 = ''
            curlev = []
        if not l: break
        if l[0] == '!' or l[0] == ';':
            continue
        if len(curlev) < 7:
            l = (l.rstrip() + '          ')[:9]
            curlev.append(l)
    initialized = 1
Example #3
0
def loadpalette():
    file = open(game.get_resource('solarwolf.pal'))
    pal = []
    for line in file.readlines()[3:]:
        vals = [int(x) for x in line.split()]
        pal.append(vals)
    surface.set_palette(pal)
Example #4
0
def loadpalette():
    file = open(game.get_resource('solarwolf.pal'))
    pal = []
    for line in file.readlines()[3:]:
        vals = [int(x) for x in line.split()]
        pal.append(vals)
    surface.set_palette(pal)
Example #5
0
 def __init__(self, name, size, bold=0, italic=0):
     val = name, size
     if FontPool.has_key(val):
         font = FontPool[val]
     else:
         if name == 'stencil':
             font = pygame.font.Font(game.get_resource('stencil.ttf'), size)
             FontPool[val] = font
         else:
             font = SysFont(name, size, bold, italic)
             FontPool[val] = font
     self.font = font
Example #6
0
 def __init__(self, name, size, bold=0, italic=0):
     val = name, size
     if FontPool.has_key(val):
         font = FontPool[val]
     else:
         if name == 'stencil':
             font = pygame.font.Font(game.get_resource('stencil.ttf'), size)
             FontPool[val] = font
         else:
             font = SysFont(name, size, bold, italic)
             FontPool[val] = font
     self.font = font
Example #7
0
    def loadnews(self):
        self.cleartext()
        self.imgs = []
        self.boxes = []
        newsfilename = game.make_dataname('news')
        if not os.path.isfile(newsfilename):
            newsfilename = game.get_resource('news')
        if os.path.isfile(newsfilename):
            news = open(newsfilename).readlines()
            if not news:
                self.makebadnews(' ', 'Invalid News File')
                return
            self.newsversion = news[0].split()[-1]
            newsitems = []
            title = date = None
            body = []
            for line in news[2:]:
                line = line.rstrip()
                if not line:
                    if title: newsitems.append((title, date, body))
                    title = date = None
                    body = []
                elif not title:
                    title = line
                elif not date:
                    date = line
                else:
                    body.append(line)

            if title and date and body:
                newsitems.append((title, date, body))

            top = 150
            for t, d, body in newsitems:
                self.boxes.append(objbox.Box((28, top + 3), 1))
                self.boxes[-1].rotspeed = 2.0
                self.boxes[-1].rotate = 0.0
                text, r = self.rendertext(0, t)
                trect = r.move(60, top)
                self.imgs.append((text, trect))
                text, r = self.rendertext(1, d)
                r = r.move(trect.right + 25, top + 10)
                self.imgs.append((text, r))
                top = trect.bottom
                for b in body:
                    text, r = self.rendertext(2, b)
                    r = r.move((100, top))
                    top = r.bottom
                    self.imgs.append((text, r))
                top += 24
        else:
            self.makebadnews(' ', 'Cannot Download News')
Example #8
0
    def loadnews(self):
        self.cleartext()
        self.imgs = []
        self.boxes = []
        newsfilename = game.make_dataname('news')
        if not os.path.isfile(newsfilename):
            newsfilename = game.get_resource('news')
        if os.path.isfile(newsfilename):
            news = open(newsfilename).readlines()
            if not news:
                self.makebadnews(' ', 'Invalid News File')
                return
            self.newsversion = news[0].split()[-1]
            newsitems = []
            title = date = None
            body = []
            for line in news[2:]:
                line = line.rstrip()
                if not line:
                    if title: newsitems.append((title, date, body))
                    title = date = None
                    body = []
                elif not title: title = line
                elif not date: date = line
                else: body.append(line)
	
            if title and date and body:
                newsitems.append((title, date, body))

            top = 150
            for t, d, body in newsitems:
                self.boxes.append(objbox.Box((28, top+3), 1))
                self.boxes[-1].rotspeed = 2.0
                self.boxes[-1].rotate = 0.0
                text, r = self.rendertext(0, t)
                trect = r.move(60, top)
                self.imgs.append((text, trect))
                text, r = self.rendertext(1, d)
                r = r.move(trect.right + 25, top+10)
                self.imgs.append((text, r))
                top = trect.bottom
                for b in body:
                    text, r = self.rendertext(2, b)
                    r = r.move((100, top))
                    top = r.bottom
                    self.imgs.append((text, r))
                top += 24
        else:
            self.makebadnews(' ', 'Cannot Download News')
Example #9
0
def initialize(size):
    global surface, rect, tile_image
    try:
        flags = 0
        depth = pygame.display.mode_ok(size, flags, 16)
        surface = pygame.display.set_mode(size, flags, depth)
        rect = surface.get_rect()

        pygame.mouse.set_visible(0)
        
        tile_image = load(game.get_resource('1945.bmp'))

    except pygame.error, msg:
        print 'Error msg: ', msg
        raise pygame.error, 'Cannot Initialize Graphics: %s' % str(msg)
Example #10
0
def init(name):
    global file2wave
    initialized = 1
    f = None
    try:
        f = open(get_resource(name + '.txt'))
    except:
        print 'Could not open waves mapping file: %s.' % name
        raise SystemError
    else:
        for line in f:
            line = line.strip()
            if line:
                if line[0] == '#': continue
                else: file2wave.append(line)
Example #11
0
def init(name):
    global file2wave
    initialized = 1
    f = None
    try:
        f = open(get_resource(name+'.txt'))
    except:
        print 'Could not open waves mapping file: %s.' % name
        raise SystemError
    else:
        for line in f:
            line = line.strip()
            if line:
                if line[0] == '#': continue
                else:  file2wave.append(line)
Example #12
0
def initialize(size):
    global surface, rect, tile_image
    try:
        flags = 0
        depth = pygame.display.mode_ok(size, flags, 16)
        surface = pygame.display.set_mode(size, flags, depth)
        rect = surface.get_rect()

        pygame.mouse.set_visible(0)

        tile_image = load(game.get_resource('1945.bmp'))

    except pygame.error, msg:
        print 'Error msg: ', msg
        raise pygame.error, 'Cannot Initialize Graphics: %s' % str(msg)
Example #13
0
def on_resource(req):
    person = get_person(request.sid)
    if req.get('action') == TAKE:
        resource_name = req.get('resource_name')
        resource_id = req.get('resource_id')
        resource = get_resource(resource_name, resource_id)
        if person.can_take_resource(resource):
            resource_remaining = use_resource(resource)
            person.add_to_inventory({resource.get('name'): 1})
            send_to_everyone(
                RESOURCE, {
                    'action': TAKE,
                    'resource_name': resource_name,
                    'resource_id': resource_id,
                    'amount': resource_remaining,
                    'person_id': person.id,
                    'inventory_gain': 1
                })
Example #14
0
 def load(self, name):
     """
     Carrega o mapa do arquivo.
     
     Parametros:
         name - nome do mapa a ser carregado.
     """
     try:
         f = open(get_resource(name+'.txt'))
     except:
         print 'Could not load map %s.' % name
         raise SystemError
     else:
         for line in f:
             if line[0] == '#': continue
             elif line.strip():
                 tname, tx, ty = line.split(';')
                 img = gfx.load(tname+'.png')
                 tx = int(tx)
                 ty = int(ty) 
                 if tx >= arena.width: tx = arena.width 
                 self.tiles.append(Tile(img, tx, ty))
         f.close()
Example #15
0
def load_raw(name):
    file = game.get_resource(name)
    img = pygame.image.load(file)
    return img
Example #16
0
def load_raw(name):
    file = game.get_resource(name)
    img = pygame.image.load(file)
    return img
Example #17
0
def load_raw(name):
    img = pygame.image.load(game.get_resource(name))
    return img
Example #18
0
def load_raw(name):
    img = pygame.image.load(game.get_resource(name))
    return img