示例#1
0
def cinq(screen):
    murs = []
    #ca marche pas psk y'a pas de mur sur les coyté jcrois
    for y in range(160, 288, 32):
        x = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(160, 288, 32):
        x = 448
        if y != 224:
            mur = Mur(screen, x, y, "mur")
            murs.append(mur)
    for x in range(0, 128, 32):
        y = 128
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for x in range(32, 456, 32):
        y = 160
        if x != 32 and x != 64:
            mur = Mur(screen, x, y, "mur")
            murs.append(mur)
    for x in range(0, 456, 32):
        y = 288
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    murs.append(Mur(screen, 128, 256, "pierre"))
    murs.append(Mur(screen, 128, 224, "pierre"))

    murs.append(Mur(screen, 256, 192, "pierre"))
    murs.append(Mur(screen, 256, 224, "pierre"))

    murs.append(Mur(screen, 384, 256, "pierre"))
    murs.append(Mur(screen, 384, 224, "pierre"))
    enemies = [
        Enemy(screen, 128, 192, 2, 1),
        Enemy(screen, 256, 256, 2, 1),
        Enemy(screen, 384, 192, 2, 3)
    ]
    potions = [
        Potion(screen, 416, 224, "heal"),
        Potion(screen, 416, 256, "heal")
    ]
    portes = [Porte(screen, 448, 224)]
    eaus = []

    return murs, enemies, potions, portes, eaus
示例#2
0
def six(screen):
    murs = []
    for x in range(0, 480, 32):
        y = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 448
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(32, 448, 32):
        x = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(32, 448, 32):
        x = 448
        if y != 224:
            mur = Mur(screen, x, y, "mur")
            murs.append(mur)

    enemies = [
        Enemy(screen, 256, 192, 1, 5),
        Enemy(screen, 288, 192, 1, 6),
        Enemy(screen, 256, 224, 1, 7),
        Enemy(screen, 288, 224, 1, 8),
        Enemy(screen, 416, 224, 1, 9),
        Enemy(screen, 416, 256, 1, 9),
        Enemy(screen, 416, 192, 1, 9)
    ]

    potions = [
        Potion(screen, 256, 192, "atkboss"),
        Potion(screen, 288, 192, "atkboss"),
        Potion(screen, 256, 224, "atkboss"),
        Potion(screen, 288, 224, "atkboss")
    ]
    portes = [Porte(screen, 448, 224)]
    eaus = []

    return murs, enemies, potions, portes, eaus
示例#3
0
def classic(screen):
    murs = []
    for x in range(0, 480, 32):
        y = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 448
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(32, 448, 32):
        x = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(32, 448, 32):
        x = 448
        if y != 224:
            mur = Mur(screen, x, y, "mur")
            murs.append(mur)

    enemies = [
        Enemy(screen, 64, 64, 1, 1),
        Enemy(screen, 160, 64, 1, 2),
        Enemy(screen, 256, 64, 1, 3),
        Enemy(screen, 352, 64, 3, 1),
    ]

    potions = [
        Potion(screen, 64, 384, "heal"),
        Potion(screen, 160, 384, "xp"),
        Potion(screen, 256, 384, "atk"),
    ]

    portes = [Porte(screen, 448, 224)]

    eaus = []

    return murs, enemies, potions, portes, eaus
示例#4
0
def quatre(screen):
    murs = [Mur(screen, 224, 416, "pierre")]
    for x in range(0, 480, 32):
        y = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 448
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 64
        if x != 224 and x != 352:
            mur = Mur(screen, x, y, "mur")
            murs.append(mur)

    for x in range(0, 480, 32):
        y = 416
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)
    for x in range(0, 224, 32):
        y = 32
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)
    for x in range(384, 456, 32):
        y = 32
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)
    for x in range(0, 480, 32):
        y = 384
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(32, 448, 32):
        x = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(32, 448, 32):
        x = 448
        if y != 224:
            mur = Mur(screen, x, y, "mur")
            murs.append(mur)

    for y in range(96, 384, 32):
        x = 288
        mur = Mur(screen, x, y, "lave")
        murs.append(mur)
    for y in range(96, 384, 32):
        x = 320
        mur = Mur(screen, x, y, "lave")
        murs.append(mur)
    for y in range(96, 384, 32):
        x = 256
        mur = Mur(screen, x, y, "lave")
        murs.append(mur)

    for y in range(96, 384, 32):
        x = 128
        if y != 256:
            mur = Mur(screen, x, y, "eau")
            murs.append(mur)
    for y in range(96, 384, 32):
        x = 160
        if y != 256:
            mur = Mur(screen, x, y, "eau")
            murs.append(mur)

    for x in range(128, 192, 32):
        y = 256
        mur = Mur(screen, x, y, "pont")
        murs.append(mur)

    murs.append(Mur(screen, 224, 352, "pierre"))
    murs.append(Mur(screen, 224, 320, "pierre"))
    murs.append(Mur(screen, 416, 96, "pierre"))
    enemies = [
        Enemy(screen, 224, 64, 1, 4),
        Enemy(screen, 352, 64, 1, 4),
        Enemy(screen, 64, 128, 1, 1),
        Enemy(screen, 96, 256, 1, 1),
        Enemy(screen, 416, 256, 1, 3),
        Enemy(screen, 384, 96, 1, 3)
    ]
    for x in range(224, 384, 32):
        y = 32
        nmy = Enemy(screen, x, y, 1, 4)
        enemies.append(nmy)
    potions = [Potion(screen, 192, 224, "atk")]
    portes = [Porte(screen, 448, 224)]
    eaus = []

    return murs, enemies, potions, portes, eaus
示例#5
0
def troix(screen):
    murs = []
    for x in range(0, 480, 32):
        y = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 416
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 32
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 384
        mur = Mur(screen, x, y, "lave")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 64
        mur = Mur(screen, x, y, "lave")
        murs.append(mur)

    for x in range(0, 480, 32):
        y = 448
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(32, 448, 32):
        x = 0
        mur = Mur(screen, x, y, "mur")
        murs.append(mur)

    for y in range(32, 448, 32):
        x = 448
        if y != 224:
            mur = Mur(screen, x, y, "mur")
            murs.append(mur)

    for y in range(96, 384, 32):
        x = 288
        mur = Mur(screen, x, y, "lave")
        murs.append(mur)
    for y in range(96, 384, 32):
        x = 320
        mur = Mur(screen, x, y, "lave")
        murs.append(mur)
    for y in range(96, 384, 32):
        x = 256
        mur = Mur(screen, x, y, "lave")
        murs.append(mur)

    enemies = []
    for y in range(96, 384, 32):
        x = 224
        nmy = Enemy(screen, x, y, 1, 4)
        enemies.append(nmy)

    potions = [
        Potion(screen, 384, 192, "heal"),
        Potion(screen, 384, 256, "heal")
    ]

    portes = [Porte(screen, 448, 224)]
    eaus = []

    return murs, enemies, potions, portes, eaus
示例#6
0
    def init(self):
        self.start = False
        self.stop_game = False
        self.bgm = load_music('./res/sound/bgm_gameplay.mp3')
        self.bgm.repeat_play()

        self.game_over_sound = load_music('./res/sound/end.mp3')
        self.game_over_sound.set_volume(64)

        self.select_button_sound = load_wav('./res/sound/button_off.wav')

        self.font = gfw.Text('./res/font.ttf', 32)
        self.font.x = SCREEN_WIDTH - 250.0
        self.font.y = SCREEN_HEIGHT - 60.0
        self.font.color_r = 0
        self.font.color_g = 0
        self.font.color_b = 0
        self.font.text = 'SCORE: 0'
        gfw.renderer.add_font(self.font)

        self.background1 = Background('./res/bk/bk6-1.png', 2, 400.0, 2)
        self.background2 = Background('./res/bk/bk6-2.png', 2, 450.0, 2)
        self.background3 = Background('./res/bk/bk6-3.png', 2, 480.0, 2)
        self.background4 = Background('./res/bk/bk6-4.png', 2, 550.0, 2)
        self.tile = Background('./res/stage/6/t0.png', 12, 450.0, 1)

        self.items = []
        self.tiles = []
        self.obstacles = []

        object_datas = {}

        for i in range(50):
            objects = None
            if self.start == False:
                with open('./res/data/objects0.json') as f:
                    objects = json.load(f)
                    self.start = True
            else:
                path = './res/data/objects' + str(
                    random.randrange(0, self.ITEM_P_COUNT)) + '.json'

                if not path in object_datas:
                    with open('./res/data/objects' +
                              str(random.randrange(0, self.ITEM_P_COUNT)) +
                              '.json') as f:
                        object_datas[path] = json.load(f)

                objects = object_datas[path]

            for o in objects:
                obj_first_name = o['name'][0]
                if obj_first_name == 'j':
                    self.items.append(Jelly(o, i * gfw.SCREEN_WIDTH))
                elif obj_first_name == 'd':
                    self.items.append(Dessert(o, i * gfw.SCREEN_WIDTH))
                elif obj_first_name == 'p':
                    self.items.append(Potion(o, i * gfw.SCREEN_WIDTH))
                elif obj_first_name == 't':
                    self.tiles.append(Tile(o, i * gfw.SCREEN_WIDTH))
                elif obj_first_name == 'o':
                    self.obstacles.append(Obstacle(o, i * gfw.SCREEN_WIDTH))

        self.cookie = None
        if self.cookie_type == 0:
            self.cookie = BraveCookie()
        else:
            self.cookie = ZombieCookie()

        self.hp_bar = gfw.Sprite('./res/hp_bar.jpg')
        self.hp_bar.x = 30.0
        self.hp_bar.y = SCREEN_HEIGHT - 42.0
        self.hp_bar.scale_x = 0.5
        self.hp_bar.scale_y = 0.5
        self.hp_bar.origin_x = 0.0
        self.hp_bar.origin_y = 1.0
        gfw.renderer.add(self.hp_bar)

        self.potion_0 = gfw.Sprite('./res/potion_0.png')
        self.potion_0.y = SCREEN_HEIGHT
        self.potion_0.origin_x = 0.0
        self.potion_0.origin_y = 1.0
        gfw.renderer.add(self.potion_0)

        self.hp = gfw.Sprite('./res/hp.png')
        self.hp.x = 70.0  # max: 535, min: 70.0
        self.hp.y = SCREEN_HEIGHT - 42.0
        self.hp.scale_x = 0.5
        self.hp.scale_y = 0.5
        self.hp.origin_x = 0.0
        self.hp.origin_y = 1.0
        gfw.renderer.add(self.hp)

        self.black_screen = gfw.Sprite('./res/bk/bb.png')
        self.black_screen.x = gfw.SCREEN_WIDTH * 0.5
        self.black_screen.y = gfw.SCREEN_HEIGHT * 0.5
        self.black_screen.alpha = 0.0
        self.black_screen.active = False
        gfw.renderer.add(self.black_screen)

        self.resume_button = gfw.Sprite('./res/resume_button.png')
        self.resume_button.x = SCREEN_WIDTH * 0.5 - 180.0
        self.resume_button.y = SCREEN_HEIGHT * 0.5
        self.resume_button.active = False
        gfw.renderer.add(self.resume_button)

        self.exit_button = gfw.Sprite('./res/exit_button.png')
        self.exit_button.x = SCREEN_WIDTH * 0.5 + 180.0
        self.exit_button.y = SCREEN_HEIGHT * 0.5
        self.exit_button.active = False
        gfw.renderer.add(self.exit_button)

        self.score = 0.0
示例#7
0
def recv(usersChan):
    global coop, gameOver,murs,potions,portes,eaus,enemies
    while True:
        if gameOver == True:
            print("gameOver")
            exit()
            return



        try:
            data = usersChan.recv_pyobj(flags=zmq.NOBLOCK)

            if data["changement"]:
                user.pos = data["coop"]["pos"]
                murs, potions= [], []
                portes = []
                eaus = []
                enemies = []


                for mur in data["murs"]:
                    murs.append(Mur(screen,*mur["pos"],mur["genre"]))

                for potion in data["potions"]:
                    potions.append(Potion(screen,*potion["pos"],potion["type"]))

                for porte in data["portes"]:
                    portes.append(Porte(screen,*porte["pos"]))

                for eau in data["eaus"]:
                    eaus.append(Eau(screen,*eau["pos"]))

                for enemy in data["enemies"]:
                    enemies.append(Enemy(screen,*enemy["pos"],enemy["level"],enemy["type"]))

            coop.pos = data["user"]["pos"]
            coop.vie = data["user"]["vie"]
            coop.attaque = data["user"]["attaque"]
            coop.defense = data["user"]["defense"]
            coop.level = data["user"]["level"]
            coop.xp= data["user"]["xp"]
            ### Supprimer objets qui ne sont pas en communs entre 2 listes python
            for potion in potions:
                ok = False
                for p in data["potions"]:
                    if potion.pos == p["pos"]:
                        ok = True
                if ok == False:
                    potions.remove(potion)

            for enemy in enemies:
                ok = False
                for e in data["enemies"]:
                    if enemy.pos == e["pos"]:
                        enemy.vie = e["vie"]
                        ok = True
                if ok == False:
                    enemies.remove(enemy)


            refresh()
        except zmq.ZMQError as err:
            pass
示例#8
0

### Génération de la MAP

data = usersChan.recv_pyobj()
murs, potions= [], []
portes = []
eaus = []
enemies = []


for mur in data["murs"]:
    murs.append(Mur(screen,*mur["pos"],mur["genre"]))

for potion in data["potions"]:
    potions.append(Potion(screen,*potion["pos"],potion["type"]))

for porte in data["portes"]:
    portes.append(Porte(screen,*porte["pos"]))

for eau in data["eaus"]:
    eaus.append(Eau(screen,*eau["pos"]))

for enemy in data["enemies"]:
    enemies.append(Enemy(screen,*enemy["pos"],enemy["level"],enemy["type"]))


# Thread parralléle qui récuperre les données
def recv(usersChan):
    global coop, gameOver,murs,potions,portes,eaus,enemies
    while True: