Beispiel #1
0
    def __init__( self ):

        self.engine = annchienta.getEngine()
        self.videoManager = annchienta.getVideoManager()
        self.inputManager = annchienta.getInputManager()
        self.cacheManager = annchienta.getCacheManager()
        self.mapManager   = annchienta.getMapManager()
        self.mathManager  = annchienta.getMathManager()
        self.sceneManager = SceneManager.getSceneManager()

        # Background spriteace
        self.background = annchienta.Surface( "images/backgrounds/sky.png" )
        self.backgroundY = 0.0

        # Create a ship for the player
        self.ship = GameObject( annchienta.Vector( videoManager.getScreenWidth()/2, videoManager.getScreenHeight()/2 ),
                                annchienta.Surface( "sprites/ship_small.png" ) )

        # Load sprites into cache
        self.enemySprite = annchienta.Surface("sprites/ship_pirate.png")

        # All enemies
        self.enemies = []

        # The final enemy
        self.captain = None

        # Number of miliseconds we need to fly to gain victory
        self.victoryTime = 60000
Beispiel #2
0
    def __init__( self ):

        self.engine = annchienta.getEngine()
        self.videoManager = annchienta.getVideoManager()
       
        self.background = annchienta.Surface( "images/backgrounds/land.png" )
        self.ship = annchienta.Surface( "sprites/ship_small.png" )

        self.backgroundY = 0.0
        self.lastUpdate = None
Beispiel #3
0
    def throwRandomBattle(self):

        self.partyManager = party.getPartyManager()
        self.sceneManager = scene.getSceneManager()

        if self.randomBattleDelay > 0:
            self.randomBattleDelay -= 1
            return
        else:
            self.randomBattleDelay = self.mathManager.randInt(300, 1000)

            # Return if there are no enemies in this level.
            if not len(self.enemiesInMap):
                return

            music = self.audioManager.getPlayingMusic()
            self.audioManager.playMusic("music/battle_" +
                                        str(self.mathManager.randInt(1, 4)) +
                                        ".ogg")
            self.sceneManager.rotateEffect()

            enames = map(
                lambda a: self.enemiesInMap[self.mathManager.randInt(
                    0, len(self.enemiesInMap))],
                range(self.mathManager.randInt(2, 4)))
            enemies = map(lambda n: self.createEnemy(n), enames)

            b = Battle(self.partyManager.team + enemies)
            b.background = annchienta.Surface(self.battleBackground)
            b.run()

            self.audioManager.playMusic(music)
Beispiel #4
0
    def __init__( self ):

        # Get references
        self.engine = annchienta.getEngine()
        self.videoManager = annchienta.getVideoManager()
        self.inputManager = annchienta.getInputManager()
        self.cacheManager = annchienta.getCacheManager()
        self.mapManager   = annchienta.getMapManager()
        self.mathManager  = annchienta.getMathManager()
        self.sceneManager = SceneManager.getSceneManager()

        # Load images
        self.background = annchienta.Surface("images/backgrounds/water.png")
        self.cacheManager.getSurface("sprites/rock1.png")
        self.cacheManager.getSurface("sprites/rock2.png")

        # Initial positions
        self.backgroundY = 0.0
        self.speed = 0.1
        self.nextSpawn = 500
        self.rocks = []

        self.raft = RaftObject( annchienta.Surface("sprites/raft.png"), annchienta.Vector( self.videoManager.getScreenWidth()/2, self.videoManager.getScreenHeight()/2 ) )
Beispiel #5
0
    def onLose(self):
        self.won = False
        self.running = False

        self.audioManager.playMusic("music/game_over.ogg")

        # Little animation
        s = annchienta.Surface("images/animations/game_over.png")
        self.videoManager.drawSurface(s, 0, 0)
        self.sceneManager.fadeOut(100, 0, 0, 5000)
        self.sceneManager.waitForClick()

        #self.sceneManager.info( "You lost...", None )
        self.mapManager.stop()
Beispiel #6
0
def fight_krelshar():

    sceneManager.speak(krelshar, "You stubborn fools! Feel my wrath!")
    audioManager.playMusic("music/battle_1.ogg")

    # Create some enemies
    enemies = map(lambda a: battle.getBattleManager().createEnemy(a),
                  ["ghost", "krelshar", "ghost"])

    # Start a battle.
    b = battle.Battle(partyManager.team + enemies)
    b.background = annchienta.Surface("images/backgrounds/woods.png")
    b.run()

    if b.won:
        partyManager.addRecord("tasumian_passed_krelshar")
Beispiel #7
0
    def throwRandomBattle(self):

        if self.randomBattleDelay > 0:
            self.randomBattleDelay -= 1
            return
        else:
            self.randomBattleDelay = self.mathManager.randInt(400, 900)

            # Return if there are no enemies in this area.
            if not len(self.randomBattleEnemies):
                return

            enames = map(
                lambda a: self.randomBattleEnemies[self.mathManager.randInt(
                    0, len(self.randomBattleEnemies))],
                range(self.mathManager.randInt(2, 5)))

            self.runBattle(enames,
                           annchienta.Surface(self.randomBattleBackground),
                           True)
Beispiel #8
0
    def __init__(self):

        # Get references
        self.engine = annchienta.getEngine()
        self.videoManager = annchienta.getVideoManager()
        self.inputManager = annchienta.getInputManager()
        self.audioManager = annchienta.getAudioManager()
        self.cacheManager = annchienta.getCacheManager()
        self.mapManager = annchienta.getMapManager()

        # Load our assets
        self.defaultFont = annchienta.Font("assets/regular.ttf", 14)
        self.italicsFont = annchienta.Font("assets/italics.ttf", 14)
        self.largeDefaultFont = annchienta.Font("assets/regular.ttf", 20)
        self.largeItalicsFont = annchienta.Font("assets/italics.ttf", 20)
        self.boxTextures = map(
            lambda i: annchienta.Surface("assets/box" + str(i) + ".png"),
            range(9))

        self.margin = 6
Beispiel #9
0
    esana.lookAt(player)

    # Talk a little, then move back.
    sceneManager.chat(esana, "Yeah, we actually have to go down that window.",
                      ["What?"])
    sceneManager.speak(
        esana,
        "Below us are only guards. And I brought this rope just in case... Let's go!"
    )
    sceneManager.move(esana, player.getPosition())

    # Remove Esana.
    sceneManager.quitDialog()
    partyManager.currentMap.removeObject(esana)

    background = annchienta.Surface("images/storyline/prison_tower.png")
    s1 = annchienta.Surface("sprites/aelaan.png")
    s2 = annchienta.Surface("sprites/esana.png")
    start = engine.getTicks()
    while start + 9000 > engine.getTicks() and inputManager.running():
        inputManager.update()
        t = engine.getTicks() - start
        videoManager.clear()
        videoManager.translate(0, (-engine.getTicks() + start) / 10)
        videoManager.drawPattern(background, 0, 0, 400, 1200)
        videoManager.drawSurface(s1, 142, 600, 0, 0, 37, 75)
        videoManager.drawSurface(s2, 142, 680, 0, 0, 31, 71)
        videoManager.flip()

    sceneManager.thoughts(
        "Esana then said we'd have to head back to Tetia. I agreed, there was no time to think."
Beispiel #10
0
videoManager = annchienta.getVideoManager()
audioManager = annchienta.getAudioManager()
partyManager = PartyManager.getPartyManager()
sceneManager = SceneManager.getSceneManager()
battleManager = BattleManager.getBattleManager()

currentMap = partyManager.getCurrentMap()

august = partyManager.getPlayer()

sceneManager.initDialog([august])

sceneManager.text("March:\nLook out!")
sceneManager.text("Ultros:\nYaaaouch! Seafood soup!")
won = battleManager.runBattle(
    ["ultros"], annchienta.Surface("images/backgrounds/cave.png"), False)
#won = True

if won:
    sound = annchienta.Sound("sounds/collapse.ogg")
    audioManager.playSound(sound)

    sceneManager.speak(august, "The cave is collapsing!")
    sceneManager.text("March:\nGet on this raft. Now.")
    sceneManager.text(
        "Use the mouse cursor to steer the raft. You will reach the cave exit in approximately one minute."
    )
    execfile("locations/inaran/raft.py")
    if mapManager.isRunning():

        # Make everything black
Beispiel #11
0
# Start Main menu.
import Menu
import MenuItem

# Display a splash image. removed for quicker testing purposes
#splashImage = annchienta.Surface( "images/backgrounds/splash.png" )
start = engine.getTicks()
#while engine.getTicks() < start + 1000:
#    videoManager.clear()
#    videoManager.drawSurface( splashImage, 0, 0 )
#    videoManager.flip()
#sceneManager.fade( 255, 255, 255, 2000 )

# Load a title background.
titleBackground = annchienta.Surface("images/storyline/title.png")

running = True
while running and inputManager.isRunning():

    videoManager.clear()
    videoManager.drawSurface(titleBackground, 0, 0)
    videoManager.flip()
    videoManager.flip()

    menu = Menu.Menu("Main Menu", "I love my girlfriend.")
    options = [
        MenuItem.MenuItem("new", "Start a new game."),
        MenuItem.MenuItem("load", "Continue from the last save point."),
        MenuItem.MenuItem(
            "video size",
Beispiel #12
0
mapManager.setMaxDescentHeight(32)
mapManager.setOnUpdateScript("scripts/onupdate.py")

inputManager = annchienta.getInputManager()
inputManager.setInteractKey( annchienta.SDLK_SPACE )

audioManager = annchienta.getAudioManager()
audioManager.playMusic("music/title.ogg")

import scene

scene.initSceneManager()
sceneManager = scene.getSceneManager()
sceneManager.defaultFont = annchienta.Font("assets/regular.ttf", 14)
sceneManager.italicsFont = annchienta.Font("assets/italics.ttf", 14)
sceneManager.boxTextures = map( lambda i: annchienta.Surface("assets/box"+str(i)+".png"), range(9) )

import battle

battle.initBattleManager()
battleManager = battle.getBattleManager()
battleManager.loadEnemies("locations/common/enemies.xml")

import party

# Depends on battleManager
party.initPartyManager()
partyManager = party.getPartyManager()

# Main menu
title_background = annchienta.Surface("assets/title.png")
Beispiel #13
0
    sceneManager.speak(player, "But I'm so afraid to speak the truth...")

    # Create jelobat enemy
    jelobatEnemy = battleManager.createEnemy("jelobat")

    # Heal party
    partyManager.heal()

    # Adapt to player stats.
    adapt(jelobatEnemy)
    annchienta.getLogManager().message(str(
        jelobatEnemy.status.get("strength")))

    b = battle.Battle(partyManager.team + [jelobatEnemy])
    b.background = annchienta.Surface("images/backgrounds/wooden_floor.png")

    audioManager.playMusic("music/anpere.ogg")
    b.run()
    #b.won = True

    if b.won:

        audioManager.playMusic("music/title.ogg")
        # Fall from boat
        sceneManager.speak(jelobat, "Why... you...")
        sceneManager.move(jelobat, annchienta.Point(annchienta.TilePoint, 7,
                                                    6))
        jelobat.setAnimation("standsouth")
        sceneManager.speak(jelobat, "Argh...")
        sceneManager.move(jelobat, annchienta.Point(annchienta.TilePoint, 6,
Beispiel #14
0
# Create an object like this.
flyAnimation = FlyAnimation()

# Now display some text with this animation
sceneManager.text( "August:\nAnd so we returned to the Imiryn Empirial City.", flyAnimation, True )
sceneManager.text( "August:\nWe were quite excited, but scared, too.", flyAnimation, True )
sceneManager.text( "August:\nWhat if we were arrested and executed? After all, some people had very good reasons to hate us now.", flyAnimation, True )
sceneManager.text( "August:\nMarch was sure we were going to be punished by the Empire himself.", flyAnimation, True )
sceneManager.text( "August:\nAvril thought we would get a fair trial, and that the judge would have no choice but choosing our side.", flyAnimation, True )
sceneManager.text( "August:\nTo tell you the truth, I didn't really care. I had done what I had to do.", flyAnimation, True )
sceneManager.text( "August:\nSo much had happened... it felt like we had gotten ten years older in, what would it be, two weeks?", flyAnimation, True )
sceneManager.text( "August:\nAvril was talking about the future of the Laustwan as we approached the Imiryn Empirial City...", flyAnimation, True )

# Animation done... display text with the background of a ruined empirial city.
imirynBurns = annchienta.Surface( "images/storyline/imiryn_burns.png" )
videoManager.clear()
videoManager.drawSurface( imirynBurns, 0, 0 )
videoManager.flip()
videoManager.flip()

sceneManager.text( "August:\nNot quite the scene we expected.", None, True )
sceneManager.text( "August:\nThe pirates had attacked the city... and won.", None, True )
sceneManager.text( "August:\nThere was nothing left to return to. Together with the few survivors, we had to leave the location.", None, True )
sceneManager.text( "August:\nMost Laustwan had fled by then.", None, True )
sceneManager.text( "August:\nI still did not care.", None, True )
sceneManager.text( "It would take hundreds of year before the descendants of the survivors regained some power.", None, True )
sceneManager.text( "Because of what had happened in the past, they did not want to hear the name Imiryn Empire. By that time, everyone knew the Legend of the Laustwan.", None, True )
sceneManager.text( "They called themselves The Dark Lion Alliance, referring to something one of their first leaders called Avril once said:", None, True )
sceneManager.text( "Like a dark lion, engulfed in shadow, watching a sparkle of light. Just like that, we all can see some hope.", None, True )
sceneManager.text( "And hope was born again.", None, True )
Beispiel #15
0
    def update( self ):

        # Update input
        self.inputManager.update()

        if not self.inputManager.isRunning():
            return

        # Number of ms passed
        ms = 0.0
        if self.lastUpdate:
            ms = float( self.engine.getTicks() - self.lastUpdate )
        self.lastUpdate = self.engine.getTicks()

        # Update background
        self.backgroundY += ms*1.0
        #while( self.backgroundY > self.videoManager.getScreenHeight() ):
        self.backgroundY %= self.videoManager.getScreenHeight()

        # Update player
        mouse = annchienta.Vector( self.inputManager.getMouseX(), self.inputManager.getMouseY() )
        mouse -= self.ship.pos
        mouse.normalize()
        mouse *= (ms * 0.3)
        self.ship.pos += mouse

        # Check if we should spawn enemies
        if self.engine.getTicks()<self.victoryTime:
            self.nextEnemySpawn -= ms
            while self.nextEnemySpawn <= 0 and self.inputManager.isRunning():
               
                # Spawn a new enemy
                pos = annchienta.Vector( self.mathManager.randInt( 0, videoManager.getScreenWidth() ), videoManager.getScreenHeight() + self.enemySprite.getHeight() )
                self.enemies += [ GameObject( pos, self.enemySprite ) ]
                self.nextEnemySpawn += self.mathManager.randInt( 500, 2000 )
        # Check if we should spawn the captain
        else:
            # Wait until all enemies are gone
            if not len(self.enemies) and not self.captain:

                # Spawn our captain
                pos = annchienta.Vector( videoManager.getScreenWidth()/2, videoManager.getScreenHeight()+100 )
                self.captain = GameObject( pos, annchienta.Surface("sprites/ship_captain.png") )

        # Move enemies
        for enemy in self.enemies:

            vect = None

            # Just fly on in current direction when we
            # already passed the player
            if enemy.pos.y < self.ship.pos.y:
                vect = annchienta.Vector( enemy.dir )
            # Else, approach the player's ship
            else:
                vect = self.ship.pos - enemy.pos
                vect.normalize()
                enemy.dir = annchienta.Vector( vect )

            vect.y = -1
            vect *= ( ms * 0.2 )

            enemy.pos += vect

        # Move captain
        if self.captain:
            vect = self.ship.pos - self.captain.pos
            vect.normalize()
            vect *= ( ms * 0.2 )
            self.captain.pos += vect

        # Minimum distance between player and enemies
        minDistance = 0.25*( self.enemySprite.getWidth() + self.enemySprite.getHeight() +
                             self.ship.sprite.getWidth() + self.ship.sprite.getHeight() )

        # Check for collision between enemies and
        # the player
        for enemy in self.enemies:

            if enemy.pos.distance( self.ship.pos ) < minDistance:

                # Game over
                self.running = False
                self.sceneManager.fade()
                self.sceneManager.text("We were caught by some sky pirate and executed...", None)
                self.mapManager.stop()

        # Check for collision between player and
        # the captain
        if self.captain:

            if self.captain.pos.distance( self.ship.pos ) < minDistance:

                self.running = False
                self.sceneManager.fade()
                self.sceneManager.text("We were lucky. We were caught by one of their captains, who was impressed by our flying.", None)
                self.sceneManager.text("He brouht us aboard their mothership...", None)

        # Remove enemies out of screen
        self.enemies = filter( lambda e: e.pos.y > -e.sprite.getHeight(), self.enemies )
Beispiel #16
0
august.lookAt(enthavos)
march.lookAt(enthavos)
avril.lookAt(enthavos)
enthavos.lookAt(august)

sceneManager.speak(enthavos, "We are on the Nupol continent.")
sceneManager.speak(
    avril,
    "We figured that much! Are you Enthavos? What are you doing here? And what do you want from us?!"
)
sceneManager.speak(enthavos, "Mostly, I want it all to go away...")
sceneManager.speak(enthavos,
                   "But now the time has come for a little test. Engage!")

won = battleManager.runBattle(["enthavos"],
                              annchienta.Surface("images/backgrounds/ice.png"),
                              False)
#won = True

if won:
    sceneManager.speak(enthavos, "Good... very good. This will be sufficient.")
    sceneManager.speak(march, "What the heck are you talking about?!")
    sceneManager.speak(enthavos, "...")
    enthavos.setAnimation("reveal")
    sceneManager.speak(august, "Brother?!")
    sceneManager.speak(enthavos, "I'm sorry.")
    sceneManager.speak(enthavos, "I am indeed August's older brother, Kyzano.")
    enthavos.setName("kyzano")
    sceneManager.speak(avril, "What?!")
    sceneManager.speak(march, "Weren't you... dead?")
    sceneManager.speak(enthavos, "That's a long story...")
Beispiel #17
0
    def __init__(self, xmlElement):

        # Call super constructor
        BattleEntity.BattleEntity.__init__(self, xmlElement)

        # We need to log stuff
        self.logManager = annchienta.getLogManager()

        # Get references
        self.videoManager = annchienta.getVideoManager()
        self.cacheManager = annchienta.getCacheManager()
        self.mathManager = annchienta.getMathManager()
        self.sceneManager = SceneManager.getSceneManager()

        # Create a dictionary describing the level stuff
        self.level = {}
        levelElement = xmlElement.getElementsByTagName("level")[0]
        for k in levelElement.attributes.keys():
            self.level[k] = int(levelElement.attributes[k].value)

        # Create a dictionary describing the health stats
        self.healthStats = {}
        healthStatsElement = xmlElement.getElementsByTagName("healthstats")[0]
        for k in healthStatsElement.attributes.keys():
            self.healthStats[k] = int(healthStatsElement.attributes[k].value)

        # Get all possible actions. The actual actions are in the first child
        # of the element, hence the code. <actions> action1 action2 </actions>
        actionsElement = xmlElement.getElementsByTagName("actions")[0]
        actionNames = str(actionsElement.firstChild.data).split()
        # Prepare to get the from the xml data
        self.actions = []
        # Get them
        for a in actionNames:
            self.addAction(a)

        # Create a dictionary describing the elemental properties
        # Only enemies have them, usually
        self.primaryElemental = {}
        elementalElements = xmlElement.getElementsByTagName("elemental")
        if len(elementalElements):
            for k in elementalElements[0].attributes.keys():
                self.primaryElemental[k] = float(
                    elementalElements[0].attributes[k].value)

        # Load sprite
        spriteElement = xmlElement.getElementsByTagName("sprite")[0]
        # Keep the filename so we can save it later on
        self.spriteFilename = str(spriteElement.getAttribute("filename"))
        self.sprite = annchienta.Surface(self.spriteFilename)
        if spriteElement.hasAttribute("x1"):
            self.sx1 = int(spriteElement.getAttribute("x1"))
            self.sy1 = int(spriteElement.getAttribute("y1"))
            self.sx2 = int(spriteElement.getAttribute("x2"))
            self.sy2 = int(spriteElement.getAttribute("y2"))
        else:
            self.sx1, self.sy1 = 0, 0
            self.sx2 = self.sprite.getWidth()
            self.sy2 = self.sprite.getHeight()

        # Get width and height from those facts.
        self.width = self.sx2 - self.sx1
        self.height = self.sy2 - self.sy1

        self.position = annchienta.Vector(0, 0)

        # We will draw a mark upon ourselves sometimes
        self.active = False
        self.selected = False

        # Damage done by an attack
        self.damage = 0
        self.damageTimer = 0.0

        self.reset()
Beispiel #18
0
    sceneManager.speak(
        captain,
        "Well, isn't it ironic? You were so close to freeing the Laustwan.")
    sceneManager.speak(
        captain,
        "After all, these plants here are the only good ones left. We lost a lot of them in our war against the pirates."
    )
    sceneManager.speak(
        captain,
        "And that's why we will guard these plantation, no matter what! Now die!"
    )

    battleManager = BattleManager.getBattleManager()
    won = battleManager.runBattle(
        ["captain", "war mage", "captain"],
        annchienta.Surface("images/backgrounds/kimen.png"), False)

    currentMap.removeObject(captain)
    sceneManager.quitDialog()

    if won:
        sceneManager.initDialog([august, avril, march])

        sceneManager.speak(
            avril,
            "Did you hear that? We have to destroy this plantation, quick!")
        sceneManager.speak(
            august,
            "Then Empire will not be able to make the drugs for a long time..."
        )
        sceneManager.speak(march,
Beispiel #19
0
 def setSprite(self, fname, x1=None, y1=None, x2=None, y2=None):
     self.spriteFileName = fname
     self.sprite = annchienta.Surface(self.spriteFileName)
     self.sx1, self.sy1 = x1, y1
     self.sx2, self.sy2 = x2, y2
Beispiel #20
0
import annchienta, scene, party, battle

partyManager = party.getPartyManager()
sceneManager = scene.getSceneManager()

passiveObject = annchienta.getPassiveObject()

# Fight with wolf here.
audioManager.playMusic("music/battle_3.ogg")

# Create some enemies
enemies = [battle.getBattleManager().createEnemy("wolf")]

# Start a battle.
b = battle.Battle(partyManager.team + enemies)
b.background = annchienta.Surface("images/backgrounds/woods.png")
b.run()

if b.won:
    partyManager.addRecord("tasumian_killed_" + passiveObject.getName())
    partyManager.refreshMap()
Beispiel #21
0
sceneManager.speak(banver, "I bet you have a Laustwan at home, too?")
sceneManager.speak(avril, "Yeah, but I treat him right! I don't lock him up.")
sceneManager.speak(banver, "Idiots. Did you never wonder what Laustwan are?")
sceneManager.speak(
    soldier1,
    "General... We are receiving new reports. A massive fleet of sky pirates is gathering near our capital."
)
sceneManager.speak(soldier2,
                   "Why can't those arrogant thieves leave us alone?")
sceneManager.speak(banver,
                   "Alright then. Let's finish these fools off and fly back.")

battleManager = BattleManager.getBattleManager()
won = battleManager.runBattle(
    ["soldier", "banver", "soldier"],
    annchienta.Surface("images/backgrounds/facilities.png"), False)
#won = True

# Soldiers come, soldiers go...
currentMap.removeObject(banver)
currentMap.removeObject(soldier1)
currentMap.removeObject(soldier2)

if won:

    sceneManager.move([august, march, avril], [
        annchienta.Point(annchienta.TilePoint, 8, 8),
        annchienta.Point(annchienta.TilePoint, 9, 9),
        annchienta.Point(annchienta.TilePoint, 7, 9)
    ])
    sceneManager.speak(august, "Brother! Are you alright?")