Esempio n. 1
0
def enter():
    global guy, bg, wall, map, death, portal, clear, deathcount

    deathcount = 0
    guy = Guy()
    portal = Portal()
    map = create_map()
    bg = Background()
    death = Death()

    clear = Clear()
    guy.set_bg(bg)
    bg.set_guy(guy)
    death.set_bg(bg)
    death.set_guy(guy)
    clear.set_bg(bg)
    clear.set_guy(guy)
    portal.set_bg(bg)
    for wall in map:
        wall.set_bg(bg)
import pygame
import pygame.display
import pygame.image
import pygame.draw
import pygame.event
from settings import Settings
from guy import Guy
from pygame.time import Clock
from game_functions import check_event, update_guy, update_screen

pygame.init()

clock = Clock()
screen = pygame.display.set_mode((852, 480))
bg = pygame.image.load('images/bg.jpg').convert_alpha()
settings = Settings()
guy = Guy(settings, screen)

IS_JUMP = False
JUMP_COUNT = 10

# Main loop
while True:
    clock.tick(20)

    check_event(guy)

    update_guy(guy)

    update_screen(screen, bg, guy)
Esempio n. 3
0
 def __init__(self):
     self.instancevar = 42
     Guy.__init__(self)
Esempio n. 4
0
 def __init__(self):
     Guy.__init__(self)
     self.word = "A"
Esempio n. 5
0
 def __init__(self):
     Guy.__init__(self)
     self.cfg.value = "(__init__)"
Esempio n. 6
0
    def test_drink(self):
        anonyme = Guy()
        self.assertEqual(anonyme.get_stats()["life"], Guy._LIFE_MAX)
        self.assertEqual(anonyme.get_stats()["potions"], Guy._POTIONS_MAX)

        # La vie ne peut dépasser la vie maximum
        anonyme.drink()
        self.assertEqual(anonyme.get_stats()["life"], Guy._LIFE_MAX)
        self.assertEqual(anonyme.get_stats()["potions"], Guy._POTIONS_MAX-1)

        anonyme._life = 0
        anonyme.drink()
        self.assertEqual(anonyme.get_stats()["life"], Guy._HEALING_POINTS)
        self.assertEqual(anonyme.get_stats()["potions"], Guy._POTIONS_MAX-2)

        # Pas de potion, pas de soin...
        anonyme._potions = 0
        anonyme.drink()
        self.assertEqual(anonyme.get_stats()["life"], Guy._HEALING_POINTS)
        self.assertEqual(anonyme.get_stats()["potions"], 0)
Esempio n. 7
0
    def test_beat(self):
        loic = Guy("Loïc")
        hugo = Guy("Hugo")
        self.assertEqual(loic.get_stats()["life"], Guy._LIFE_MAX)
        self.assertEqual(hugo.get_stats()["life"], Guy._LIFE_MAX)

        # Ici, les armes sont supposées être des tubas => munitions infines
        loic.beat(hugo)
        hugo.beat(loic)
        loic.beat(hugo)
        dmg_tuba = Guy.WEAPONS_STATS["TUBA"]["dmg"]
        self.assertEqual(loic.get_stats()["life"], Guy._LIFE_MAX - dmg_tuba)
        self.assertEqual(loic.get_stats()["weapon"]["ammunitions"], Guy.UNLIMITED)
        self.assertEqual(hugo.get_stats()["life"], Guy._LIFE_MAX - 2*dmg_tuba)
        self.assertEqual(hugo.get_stats()["weapon"]["ammunitions"], Guy.UNLIMITED)

        # Pas de vie négative
        loic._life = dmg_tuba / 2
        hugo.beat(loic)
        self.assertEqual(loic.get_stats()["life"], 0)

        # Test des munitions
        loic.change_weapon("EFFACEUR")
        self.assertEqual(loic.get_stats()["weapon"]["name"], "EFFACEUR")
        self.assertEqual(Guy.WEAPONS_STATS["EFFACEUR"]["ammunitions_max"], 1)
        dmg_effaceur = Guy.WEAPONS_STATS["EFFACEUR"]["dmg"]
        hugo._life = Guy._LIFE_MAX
        loic.beat(hugo)
        self.assertEqual(hugo.get_stats()["life"], Guy._LIFE_MAX - dmg_effaceur)
        self.assertEqual(loic.get_stats()["weapon"]["ammunitions"], 0)
        loic.beat(hugo)
        self.assertEqual(hugo.get_stats()["life"], Guy._LIFE_MAX - dmg_effaceur)
        self.assertEqual(loic.get_stats()["weapon"]["ammunitions"], 0)
Esempio n. 8
0
 def __init__(self, title, txt=""):
     Guy.__init__(self)
     self.title = title
     self.txt = txt
     self.ret = None
Esempio n. 9
0
 def __init__(self, title="unknown"):
     Guy.__init__(self)
     self.title = title
Esempio n. 10
0
 def __init__(self, title):
     Guy.__init__(self)
     self.title = title
     self.ret = False
Esempio n. 11
0
 def __init__(self):
     Guy.__init__(self)
     self.defaultName = self.cfg.name or "empty"
     self.defaultSurname = self.cfg.surname or "empty"
Esempio n. 12
0
 def __init__(self, param):
     Guy.__init__(self)
     assert param == "42"
Esempio n. 13
0
 def __init__(self, txt):
     Guy.__init__(self)
     self.msg = txt
Esempio n. 14
0
 def __init__(self,v):
     self.instancevar=v
     Guy.__init__(self)
Esempio n. 15
0
    def test_change_weapon(self):
        anonyme = Guy()
        self.assertEqual(anonyme.get_stats()["weapon"]["name"], "TUBA")
        self.assertEqual(anonyme.get_stats()["weapon"]["dmg"], Guy.WEAPONS_STATS["TUBA"]["dmg"])

        # Pas de nom d'arme valide, pas de chgt...
        anonyme.change_weapon("une arme bidon")
        self.assertEqual(anonyme.get_stats()["weapon"]["name"], "TUBA")
        self.assertEqual(anonyme.get_stats()["weapon"]["dmg"], Guy.WEAPONS_STATS["TUBA"]["dmg"])

        for weapon in Guy.WEAPONS_STATS.keys():
            anonyme.change_weapon(weapon)
            self.assertEqual(anonyme.get_stats()["weapon"]["name"], weapon)
            self.assertEqual(anonyme.get_stats()["weapon"]["dmg"], Guy.WEAPONS_STATS[weapon]["dmg"])
Esempio n. 16
0
    screen = pygame.display.set_mode((800, 600))


    grid = Grid('grass', 10, 6)
    ui = UI(grid)

    guys = []
    enemies = []
    for x in xrange(2):
        for y in xrange(4):
            guy = Guy('dude')
            grid.add(guy, (x*2 + 1 + y % 2, y))
            guys.append(guy)

            enemy = Guy('dude')
            enemy.image = pygame.transform.flip(enemy.image, True, False)
            grid.add(enemy, (x*2 + 6 + y % 2, y))
            enemies.append(enemy)

    curguy = 0
    while 1:
        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit()
            elif event.type == KEYDOWN:
                prevguy = curguy
                curguy = handle_key(grid, ui, screen, event.key, guys, curguy)
                if prevguy > curguy: # looped around
                    move_enemies(grid, ui, screen, guys, enemies)
        update_screen(grid, ui, screen, guys, enemies)
Esempio n. 17
0
 def create_a_nude_guy(self):
     new_guy = Guy()
     new_guy.id = self.count
     self.count += 1
     return new_guy