Пример #1
0
    def __init__(self, background):
        assert _initted
        self.control_menu = ControlsWindow()
        self.control_menu.update()
        self.control_menu.autoSize()
        self.control_menu.Position = (160 - self.control_menu.Width / 2 - 8,
                                      48)
        self.background = background
        self.yellowfont = ika.Font('system_yellow.fnt')
        self.greyfont = ika.Font('system_grey.fnt')

        self.header = Header(text='Control')
        self.header.setSize((self.control_menu.Width - 16, self.header.Height))
        self.header.Position = (self.control_menu.Left + 16,
                                self.control_menu.Top - self.header.Height * 3)
        self.text = ''
Пример #2
0
    def __init__(self):

        self.kbControlList = []  #array for definite order

        self.fonts = {"system": ika.Font("system.fnt")}

        self.colors = {
            "white": ika.RGB(255, 255, 255),
            "black": ika.RGB(0, 0, 0),
            "dark blue": ika.RGB(0, 0, 100),
            "light grey": ika.RGB(100, 100, 100),
            "red": ika.RGB(255, 0, 0),
            "orange": ika.RGB(150, 50, 50),
            "green": ika.RGB(0, 255, 0),
            "blue": ika.RGB(0, 0, 255)
        }

        self.spriteImages = {"test": [ika.Image("images\\spritetest.png")]}
Пример #3
0
    def __init__(self):
        self.entities = []
        self.killList = []
        self.things = []
        self.mapThings = [
        ]  # same as self.things, but is cleared every mapSwitch
        self.fields = []
        self.framerate = 100
        # ika Entity : Entity
        self.entFromEnt = {}

        self.player = None
        self.background = None

        # framerate regulating stuff:
        self.ticksPerFrame = 100.0 / self.framerate
        self.nextFrameTime = 0

        self.font = ika.Font('system.fnt')
        self.mapName = ''

        #for game clock
        self.resetTime()
        self.mapscreen = automap.MapScreen()
Пример #4
0
def menu():
    bg = ika.Image('gfx/title.png')
    cursor = ika.Image('gfx/ui/pointer.png')
    snow = Snow(velocity=(0, 0.5))
    snow.update()
    result = None
    cursorPos = 0
    FADE_TIME = 60

    font = ika.Font('system.fnt')

    def draw():
        ika.Video.Blit(bg, 0, 0, ika.Opaque)
        ika.Video.Blit(cursor, 68, 128 + cursorPos * 26)
        txt = '(c) 2003, 2021'
        length = font.StringWidth(txt)
        font.Print(ika.Video.xres - length - 10, ika.Video.yres - 10, txt)
        txt = 'Version 1.02'
        length = font.StringWidth(txt)
        font.Print(ika.Video.xres - length - 10, ika.Video.yres - 20, txt)
        if controls.useGamePad:
            font.Print(10, ika.Video.yres - 10, 'Gamepad controls enabled.')

    for i in range(FADE_TIME - 1, -1, -1):
        draw()
        ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                           ika.RGB(0, 0, 0, i * 255 / FADE_TIME), True)
        snow.update()
        snow.draw()
        ika.Video.ShowPage()
        ika.Input.Update()
        ika.Delay(1)

    u = 0  # gay unpress hack

    while result == None:
        draw()
        snow.update()
        snow.draw()
        ika.Video.ShowPage()
        ika.Input.Update()
        ika.Delay(1)

        if (controls.up() or controls.ui_up()
                or controls.joy_up()) and cursorPos > 0:
            if not u:
                cursorPos -= 1
                u = 1
        elif (controls.down() or controls.ui_down()
              or controls.joy_down()) and cursorPos < 2:
            if not u:
                cursorPos += 1
                u = 1
        elif controls.attack() or controls.ui_accept() or controls.joy_attack(
        ):
            result = cursorPos
        else:
            u = 0

    # one last draw.  Later on, there's a blurfade that can take advantage of this:
    draw()
    snow.draw()
    return result

    for i in range(FADE_TIME):
        draw()
        ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                           ika.RGB(0, 0, 0, i * 255 / FADE_TIME), True)
        snow.update()
        snow.draw()
        ika.Video.ShowPage()
        ika.Input.Update()
        ika.Delay(1)
Пример #5
0
 def __init__(self, text):
     self.font = ika.Font("ocr_grey.fnt")
     self.time = ika.GetTime()
     self.text = text
     drawList.append(self)
     updateList.append(self)
Пример #6
0
 def __init__(self):
     self.font = ika.Font("ocr_grey.fnt")
Пример #7
0
'''
joy = ika.Input.joysticks[0]
ika.Input.right = joy.axes[0]
ika.Input.left = joy.reverseAxes[0]
ika.Input.down = joy.axes[1]
ika.Input.up = joy.reverseAxes[1]
ika.Input.enter = joy.buttons[2]
ika.Input.cancel = joy.buttons[1]
#'''

# initialize the GUI system

from xi import gui

gui.init(
    ika.Font('smallfont.fnt'))

# Little doodad for showing framerate
def hook():
    gui.default_font.Print(0, 280, 'FPS: %i' % ika.GetFrameRate())

def showFps(show=True):
    # unhook it (this keeps it from being hooked more than once, which would
    # be silly and inefficient)
    ika.UnhookRetrace(hook)

    # hook it up
    if show:
        ika.HookRetrace(hook)

def hideFps():
Пример #8
0
import ika

font = ika.Font("font.fnt")
lane1 = 130
lane2 = 160
win_height = 250

donkeyroad = ika.Image("donkeyroad.png")
youwon = ika.Image("youwon.png")
youlost = ika.Image("youlost.png")


class Entity:

    #Color = ika.RGB(255,0,0)

    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.width = 8
        self.height = 16
        self.ox = x  #Origin x and y.
        self.oy = y

    def Update(self):
        pass

    def Render(self):
        ika.Video.Blit(self.img, self.x, self.y, False)

Пример #9
0
def credits():
    m = sound.music.get('music/Existing.s3m', ika.Sound('music/Existing.s3m'))
    m.loop = True
    sound.fader.kill()
    sound.fader.reset(m)

    bg = ika.Image('gfx/mountains2.png')
    snow = Snow(velocity=(0.5, 0.75))
    y = -ika.Video.yres
    font = ika.Font('system.fnt')
    totalitems = 27  #total collectable items - tnt, + all types of runes
    #currently 6 of each rune type 18 total, + 4 main runes + 5 TNT = 27
    s = system.engine.player.stats

    collecteditems = s.totaltnt + s.powerrunes + s.strengthrunes + s.guardrunes + 4  #hack - assume that all 4 main runes are collected :P
    itempercent = str(round(collecteditems * 100 / totalitems, 1)) + '%'
    if automap.map.getMapPct() >= 100:
        mappercent = '100.0%'
    else:
        mappercent = str(automap.map.getMapPct()) + '%'
    totaltxt = _basetext + """ *** Final Stats ***
    
    
  Total Time Played:  """ + system.engine.time + """    
Item Collection Rate:  """ + itempercent + """
Map Completion Rate:  """ + mappercent + """


"""

    _text = totaltxt.split('\n')

    class CreditEnt(object):
        def __init__(self, e, name, x, y, h):
            self.ent = e
            self.name = name
            self.x = x
            self.y = y
            self.h = int(h / 2)  #display line at midpoint of image height
            if self.name == 'soulreaver':
                self.displayname = 'Rune Guardian'  #hack
            else:
                self.displayname = name.capitalize()

            self.num = str(system.engine.player.stats[self.name])

        def draw(self, offset):
            self.ent.Draw(self.x, self.y - offset)

            font.Print(140, self.y - offset + self.h, self.displayname)
            font.Print(250, self.y - offset + self.h, self.num)

    def draw():
        ika.Video.Blit(bg, 0, 0, ika.Opaque)
        ika.Video.DrawRect(0, 0, ika.Video.xres, ika.Video.yres,
                           ika.RGB(0, 0, 0, 128), True)

        firstLine = int(y) / font.height
        adjust = int(y) % font.height
        length = (ika.Video.yres / font.height) + 1

        Y = -adjust
        while Y < ika.Video.yres and firstLine < len(_text):
            if firstLine >= 0:
                font.CenterPrint(160, Y, _text[firstLine])
            Y += font.height
            firstLine += 1

        for en in entlist:
            en.draw(int(y))

        ika.Video.DrawTriangle((0, 0, ika.RGB(0, 0, 0)),
                               (ika.Video.xres, 0, ika.RGB(0, 0, 0, 0)),
                               (0, 60, ika.RGB(0, 0, 0, 0)))

        ika.Video.DrawTriangle(
            (ika.Video.xres, ika.Video.yres, ika.RGB(0, 0, 0)),
            (0, ika.Video.yres, ika.RGB(0, 0, 0, 0)),
            (ika.Video.xres, ika.Video.yres - 60, ika.RGB(0, 0, 0, 0)))

        snow.draw()

    entlist = []

    startx = 80
    starty = 0
    for i, txt in enumerate(_text):
        if '*** Enemy Stats ***' in txt:
            starty = i * 10 + 30
            break

    #hack because the full sprite dimensions aren't directly accessible
    heights = [16] * 3 + [32] * 3 + [72] * 3 + [112]
    halfwidths = [8] * 3 + [16] * 3 + [48] * 4
    offseth = [0] * 3 + [0] * 3 + [16] * 3 + [15]  #compensate for hotspot

    for i, entname in enumerate([
            'anklebiter', 'carnivore', 'devourer', 'razormane', 'dragonpup',
            'hellhound', 'yeti', 'gorilla', 'soulreaver', 'serpent'
    ]):
        e = ika.Entity(-100, -100, 2,
                       entname + '.ika-sprite')  #put it off screen!
        entlist.append(
            CreditEnt(e, entname, startx - halfwidths[i], starty - offseth[i],
                      heights[i]))
        starty += heights[i] + 10

    maxy = len(_text) * 10

    draw()
    xi.effects.fadeIn(50)

    now = ika.GetTime()
    while True:
        t = ika.GetTime()
        delta = (t - now) / 5.0
        y += delta
        now = t
        snow.update()
        draw()
        ika.Video.ShowPage()
        ika.Input.Update()
        if y > maxy:
            break

    system.killmusic = False  #keep music playing after returning to menu

    raise EndGameException
Пример #10
0
from caption import Caption, DamageCaption
from gameover import EndGameException, GameOverException
from createentity import createEntity, SpawnException
from hud import HPBar, EXPBar, ShellsIndicator
from player import Player
from npc import Npc
from xi.fps import FPSManager


entities = []
killList = []
player = None
background = None
stencil = None

font = ika.Font(config.FONT)
font2 = ika.Font(config.FONT2)


mapName = ''
mapModule = None
curMap = ''

things = []     # Things that are not entities, but still need to be updated and/or drawn
bgThings = []  # same as things, but is cleared every mapSwitch and is drawn under the map
mapThings = []  # same as things, but is cleared every mapSwitch
fields = []     # Like zones, except the same!
entFromEnt = {} # Maps ika Entity objects to our Entity instances
saveData = {}   # Game flags that need to persist throughout the game.

isCutScene = 0 # if greater than zero, entities are not updated
Пример #11
0
def init():
    global _initted
    _initted = True
    gui.init(font=ika.Font('system.fnt'),
             wnd=Window('gfx/ui/win_%s.png'),
             csr=ImageCursor('gfx/ui/pointer.png', hotspot=(14, 6)))