Пример #1
0
def doTitleScreen(window):
    w = window.width
    h = window.height
    logo = resource.getSprite("logo")
    logo.position = (w / 2, h / 2)
    logo.scale = float(w) / float(logo.width)
    title = resource.getSprite("title")
    title.position = (w / 2, h / 2)
    title.scale = float(w) / float(title.width)

    def draw_logo():
        window.clear()
        logo.draw()
        return True

    def draw_title():
        window.clear()
        title.draw()
        return True

    def on_key_press(key, modifiers):
        window.pop_handlers()
        return True

    window.push_handlers(on_draw=draw_title, on_key_press=on_key_press)
    window.push_handlers(on_draw=draw_logo, on_key_press=on_key_press)
Пример #2
0
 def __init__(s, creator, parent, direction=1):
     SurfFeature.__init__(s)
     #s.loc = creator.loc + (direction * 0.2)
     s.direction = direction
     s.speed = 1.0
     s.lifetime = 0.5
     s.setParent(s)
     s.radius += 2.0
     s.creator = creator
     s.size = 10.0
     s.spriteRight = resource.getSprite("bladeRight")
     s.spriteLeft = resource.getSprite("bladeLeft")
     s.setSprite()
Пример #3
0
 def __init__(s):
     Dude.__init__(s)
     s.hits = 10
     s.sprite = resource.getSprite('civvie')
     s.aiCooldownMax = 1.0
     s.aiCooldown = random.random() * s.aiCooldownMax
     s.ai = CivvieAI(s)
Пример #4
0
    def draw(s, gs):
        starstep = 100
        # This would be nicer if it worked.  But, screw it for now.  More important things.
        # nearx = int(gs.camerax - (gs.camerax % starstep)) - (gs.screenW / 2) + starstep
        # farx = nearx + gs.screenW
        # neary = int(gs.cameray - (gs.cameray % starstep)) - (gs.screenH / 2) + starstep
        # fary = nearx + gs.screenH
        # for i in range(nearx, farx, starstep):
        #     for j in range(neary, fary, starstep):
        #         dist = vec.mag(vec.new(i,j))
        #         relativeDist = dist / gs.universeSize
        #         brightness = 255 - min(255, int(255 * relativeDist))
        #         sc = gs.screenCoords(vec.new(i, j))
        #         pygame.draw.circle(surf, pygame.Color(brightness,brightness,brightness), sc, 2)

        xoff = int(gs.camerax) % starstep
        yoff = int(gs.cameray) % starstep
        sprite = resource.getSprite('warpspark')
        for i in range(0, gs.screenW + starstep, starstep):
            for j in range(0, gs.screenH + starstep, starstep):
                dist = vec.mag(vec.new(gs.camerax, gs.cameray))
                relativeDist = dist / gs.universeSize
                brightness = 255 - min(255, int(255 * relativeDist))
                sprite.x = i - xoff
                sprite.y = j - yoff
                sprite.draw()
Пример #5
0
 def __init__(s):
     starstep = 100
     s.stars = []
     #for i in range(starstep):
     #    for j in range(starstep):
     s.starsprite = resource.getSprite('planet')
     s.starsprite.scale = 0.1
Пример #6
0
 def __init__(s):
     Dude.__init__(s)
     s.hits = 20
     s.sprite = resource.getSprite('soldier')
     s.aiCooldownMax = 1.5
     s.aiCooldown = random.random() * s.aiCooldownMax
     s.ai = SoldierAI(s)
     s.damageParticle = particles.BloodSplat
Пример #7
0
 def __init__(s):
     Dude.__init__(s)
     s.speed = 20.0
     s.hits = 50
     s.sprite = resource.getSprite('invader')
     s.damageParticle = particles.AlienBloodSplat
     s.hitSound = resource.getSound("invaderhit")
     s.dieSound = resource.getSound("enemydie")
     s.attackSound = resource.getSound("swing")
Пример #8
0
 def __init__(s, creator, parent, direction=1):
     SurfFeature.__init__(s)
     #s.loc = creator.loc + (direction * 0.2)
     s.direction = direction
     s.speed = 52.0
     s.lifetime = 1.0
     s.setParent(s)
     s.radius += 2.0
     s.creator = creator
     s.size = 1.0
     s.sprite = resource.getSprite("bullet")
Пример #9
0
 def __init__(s):
     #GameObj.__init__(s)
     s.parent = None
     s.loc = 0.0
     s.size = 2.0
     s.hits = 10
     s.alive = True
     s.sprite = resource.getSprite("test")
     s.radius = 0.0
     s.hitCooldown = 0.0
     s.hitCooldownTotal = 0.5
     s.damageParticle = particles.HitChip
     s.hitSound = resource.getSound("buildinghit")
     s.dieSound = resource.getSound("buildingdie")
Пример #10
0
def doGameOver(window):
    gameover = resource.getSprite("gameover")
    gameover.position = (window.width / 2, window.height / 2)
    gameover.scale = float(window.width) / float(gameover.width)

    # Pop off the actual game handlers
    window.pop_handlers()

    def on_draw():
        window.clear()
        gameover.draw()
        return True

    def doClose(dt):
        window.close()

    window.push_handlers(on_draw)
    pyglet.clock.schedule_once(doClose, 2)
Пример #11
0
 def __init__(s, loc, vel, image, life):
     s.loc = loc
     s.vel = vel
     s.sprite = resource.getSprite(image)
     s.life = life
     s.alive = True
Пример #12
0
 def __init__(s, buildingType):
     SurfFeature.__init__(s)
     (img, size, hits) = BUILDING[buildingType]
     s.size = size
     s.hits = hits
     s.sprite = resource.getSprite(img)