Beispiel #1
0
def main():
    global bodies
    pg.init()
    screen = pg.display.set_mode(
                (SCREEN_WIDTH, SCREEN_HEIGHT), 0, 32)
    clock = pg.time.Clock()
    myfont = pg.font.SysFont("monospace", 15)

    load_level(next(LEVELS)())

    while True:
        clock.tick(50)
        handle_input()

        # Redraw the background
        screen.fill(BG_COLOR)
        player.inSafe = False
        collTree = rdc.RDC(bodies + safe_zones + [player])
        collTree.DoRDC()

        if player.inSafe:
            physTree = QuadTree(bodies)
        else:
            physTree = QuadTree(bodies + [player])
        physTree.doPhysics()

        update_player_physics(player)
        hits = player.updateScore()
        for h in hits:
            bodies.remove(h)

        for body in bodies:
            rad, pos = to_pixels(body.pos, body.rad)
            pg.draw.circle(screen, body.color, pos, rad, 2)

        for sz in safe_zones:
            rad, pos = to_pixels(sz.pos, sz.rad)
            pg.draw.circle(screen, (0, 0, 255), pos, rad, rad)

        rad, pos = to_pixels(player.pos, player.rad)
        pg.draw.circle(screen, (255, 0, 255), pos, rad)

        label = myfont.render("Score: {}".format(player.score), 1,
                              (255, 255, 0))
        screen.blit(label, (50, 50))

        pg.display.flip()

        if all(b.value <= 0 for b in bodies):
            load_level(next(LEVELS)())
Beispiel #2
0
#!/usr/bin/env python
"""
    Copyright (c) Bifferos 2009 ([email protected])
    
    This is free software, licensed under the GNU General Public License v2.
    See COPYING for more information.
"""

import rdc, os, sys, struct

if __name__ == "__main__":

    r = rdc.RDC()

    fname = sys.argv[1]
    fp = file(fname)
    flen = os.stat(fname).st_size
    count = 0
    print "Sector erase"
    r.EonSectorErase(0xffff0000)
    print "Programming"
    while count < flen:
        dat = struct.unpack("<H", fp.read(2))[0]
        addr = 0xffff0000 + count
        print "0x%08x <-- 0x%04x" % (addr, dat)
        if dat != 0xffff:
            r.EonProgram(addr, dat)
        count += 2

    data = r.DumpMem(0xffff0000, 0x80)
    print repr(data)