Exemple #1
0
 def __init__(self, initial_pos = (15, 755), editable=False):
     image = pygame.Surface( (1770, 15) )
     image.fill( (255, 255, 255) )
     Thing.__init__(self,
         image, editable, None,
         initial_pos, elasticity = 100, mobility = False,
         gravity = 10)
Exemple #2
0
 def __init__(self, subjectof, objectof, verb):
     listof = []
     Thing.__init__(self, 'The fact that' + subjectof + verb + objectof, '')
     Fact.listof.append(self)
     self.subjectof = subjectof
     self.objectof = objectof
     self.verb = Action
    def __init__(self,
                 filename,
                 position,
                 default_velocity=[145.0, 0.0],
                 velocity=[0.0, 0.0],
                 acceleration=[0.0, GRAVITY],
                 jump_amount=JUMP_AMOUNT,
                 health=1,
                 max_y=None):
        # self.rect is the creature's RELATIVE position
        # self.position is the ABSOLUTE position
        Thing.__init__(self, filename)

        self.velocity = Vector(velocity[0], velocity[1], y_max=max_y)
        self.acceleration = Vector(acceleration[0], acceleration[1])
        self.default_velocity = Vector(default_velocity[0],
                                       default_velocity[1])

        self.position = pygame.rect.Rect(self.rect)
        self.position.topleft = position
        self.rect.topleft = position
        self.desired_position = pygame.rect.Rect(self.position)

        self.jumping = False
        self.jump_amount = jump_amount
        self.landed = True
        self.motion = "right" if self.velocity.x >= 0 else "left"

        self.health = health
        self.dead = False

        self.reload_time = time() - 10
        self.reload_wait = .75  #This gets tampered with elsewhere

        self.AI = AI()
    def __init__(self, filename, position, default_velocity = [145.0, 0.0],
                 velocity = [0.0, 0.0], acceleration = [0.0, GRAVITY],
                 jump_amount = JUMP_AMOUNT, health = 1, max_y = None):
        # self.rect is the creature's RELATIVE position
        # self.position is the ABSOLUTE position
        Thing.__init__(self, filename)
        
        self.velocity = Vector(velocity[0], velocity[1], y_max = max_y)
        self.acceleration = Vector(acceleration[0], acceleration[1])
        self.default_velocity = Vector(default_velocity[0], default_velocity[1])
        
        self.position = pygame.rect.Rect(self.rect)
        self.position.topleft = position
        self.rect.topleft = position
        self.desired_position = pygame.rect.Rect(self.position)
        
        self.jumping = False
        self.jump_amount = jump_amount
        self.landed = True
        self.motion = "right" if self.velocity.x >= 0 else "left"

        self.health = health
        self.dead = False

        self.reload_time = time() - 10
        self.reload_wait = .75 #This gets tampered with elsewhere

        self.AI = AI()
Exemple #5
0
 def __init__(self, name, names, pluralised = 's', plural = 's'):
     Thing.__init__(self, name, names)
     Inanimate.listof.append(self)
     self.pluralised = pluralised
     if plural == 's':
         self.plural = name + 's'
     else:
         self.plural = plural
Exemple #6
0
 def __init__(self, initial_pos=None, editable=True):
     Thing.__init__(self,
                    pygame.image.load(
                        os.path.join("data", "images", "target.png")),
                    editable,
                    None,
                    initial_pos,
                    elasticity=100,
                    mobility=False,
                    gravity=10)
Exemple #7
0
 def __init__(self, initial_pos=None, editable=True):
     if pygame.mixer.get_init():
         snd = pygame.mixer.Sound(os.path.join("data", "snd",
                                               "BowlingBall.wav"))
     else:
         snd = None
     Thing.__init__(self,
           pygame.image.load(os.path.join("data", "images", "bola.png")),
           editable, snd,
           initial_pos, elasticity = 90, mobility = True, gravity = 5)
Exemple #8
0
 def __init__(self, initial_pos=(15, 755), editable=False):
     image = pygame.Surface((1770, 15))
     image.fill((255, 255, 255))
     Thing.__init__(self,
                    image,
                    editable,
                    None,
                    initial_pos,
                    elasticity=100,
                    mobility=False,
                    gravity=10)
Exemple #9
0
 def __init__(self, initial_pos = (0, 0), editable=True):
     Thing.__init__(self,
           pygame.image.load(os.path.join("data", "images",
                                          "esteira_dir.png")),
           editable, None,
           initial_pos, elasticity = 100, mobility = False,
           gravity = 10)
     self.sentido = 1
     self.image_dir = pygame.image.load(os.path.join("data", "images",
                                                     "esteira_dir.png"))
     self.image_esq = pygame.image.load(os.path.join("data", "images",
                                                     "esteira_esq.png"))
Exemple #10
0
 def __init__(self, initial_pos=None, editable=True):
     if pygame.mixer.get_init():
         snd = pygame.mixer.Sound(os.path.join("data", "snd",
                                               "penguin.wav"))
     else:
         snd = None
     Thing.__init__(self,
          pygame.image.load(os.path.join("data", "images", "penguin.png")),
          editable, snd,
          initial_pos, elasticity = 100, mobility = True,
          gravity = 5)
     self.speed = [5, 0]
Exemple #11
0
 def __init__(self, initial_pos=(0, 0), editable=True):
     Thing.__init__(self,
                    pygame.image.load(
                        os.path.join("data", "images", "esteira_dir.png")),
                    editable,
                    None,
                    initial_pos,
                    elasticity=100,
                    mobility=False,
                    gravity=10)
     self.sentido = 1
     self.image_dir = pygame.image.load(
         os.path.join("data", "images", "esteira_dir.png"))
     self.image_esq = pygame.image.load(
         os.path.join("data", "images", "esteira_esq.png"))
Exemple #12
0
 def __init__(self, initial_pos=None, editable=True):
     if pygame.mixer.get_init():
         snd = pygame.mixer.Sound(
             os.path.join("data", "snd", "BowlingBall.wav"))
     else:
         snd = None
     Thing.__init__(self,
                    pygame.image.load(
                        os.path.join("data", "images", "futebol.png")),
                    editable,
                    snd,
                    initial_pos,
                    elasticity=70,
                    mobility=True,
                    gravity=5)
Exemple #13
0
 def __init__(self, initial_pos=None, editable=True):
     if pygame.mixer.get_init():
         snd = pygame.mixer.Sound(os.path.join("data", "snd",
                                               "penguin.wav"))
     else:
         snd = None
     Thing.__init__(self,
                    pygame.image.load(
                        os.path.join("data", "images", "penguin.png")),
                    editable,
                    snd,
                    initial_pos,
                    elasticity=100,
                    mobility=True,
                    gravity=5)
     self.speed = [5, 0]
Exemple #14
0
 def fill(self, ttype, alive=False):
     c1, c3 = self.c1, self.c3
     for y in range(c1.y, c3.y + 1):
         for x in range(c1.x, c3.x + 1):
             if ttype == ' ':
                 fld.remove(wall, Location(x, y))
             else:
                 Thing(fld, ttype, Location(x, y), alive)
Exemple #15
0
def add_walls():
    for x in range(5, 80, 4):
        L = Location
        locs = []
        for y in range(2, 10):
            locs.append(L(x, y))
            locs.append(L(x + 1, y))
        for l in locs:
            Thing(fld, wall, l, False)
Exemple #16
0
 def __init__(self, owner):
     Thing.__init__(self, owner._server)
     if hasattr(self, 'name'):
         self.name = self.name
     else:
         n = self.__class__.__name__
         i = 1
         while i < len(n):
             if n[i] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
                 n = n[:i] + ' ' + n[i:]
                 i += 1
             i += 1
         self.name = n
     if hasattr(self, 'color'):
         self.color = self.color
     elif self.cost[-1].lower() in 'rgubw':
         self.color = self.cost[-1].lower()
     else:
         self.color = ''
     self.tapped = 0
     self._isDoneCasting = 0
     self._abilities = {}
     self.untapEvent = None
Exemple #17
0
    def lifernd(self, fld, location, val, neighbours):
        """Fuzzy game of life."""
        add = 3
        rnd = random()
        if rnd > 0.8: add = 2
        elif rnd > 0.7: add = 5
        elif rnd > 0.6: add = 4

        if val == ' ':
            if neighbours == add:
                things.append(Thing(fld, cell, location))
        elif not val.alive:
            return
        elif not (1 < neighbours < 4) and random() > 0.5:
            val.remove()
Exemple #18
0
    def __init__(self, screen, screen_size, mic=None):

        # parent class init
        super().__init__(screen, screen_size, mic)

        from things import Thing

        # create thing
        self.thing = Thing(position=self.grid_world.grid_to_pos([22, 18]),
                           scale=(2, 2))

        # add to sprites
        self.all_sprites.add(self.thing)
        self.henry.thing_sprites.add(self.thing)

        # determine position
        self.henry.set_position(self.grid_world.grid_to_pos([10, 10]),
                                is_init_pos=True)
Exemple #19
0
    def lifend(self, fld, location, val, neighbours):
        """Fuzzy game of life with night/day variations."""
        add = 3
        rmv = [1, 4]
        rmv_rnd = 0.5
        rnd = random()
        if rnd > 0.8: add = 2
        elif rnd > 0.7: add = 5
        elif rnd > 0.6: add = 4

        x = int(self.n / 10)
        if int(self.n / 15) % 2:
            add += 1
            rmv[0] = 2
            rmv_rnd = 0.58

        if val == ' ':
            if neighbours == add:
                things.append(Thing(fld, cell, location))
        elif not val.alive:
            return
        elif not (rmv[0] < neighbours < rmv[1]) and random() > rmv_rnd:
            val.remove()
        self.add = add
Exemple #20
0
 def __init__(self, name, names=''):
     Thing.__init__(self, name, names)
     Place.listof.append(self)
Exemple #21
0
 def __init__(self, name, names, reasons, pluralised='s'):
     Thing.__init__(self, name, names)
     self.reasons = reasons
     self.pluralised = pluralised
     Doodad.listof.append(self)
Exemple #22
0
 def __init__(self, name, names, gender=None, comment=''):
     Thing.__init__(self, name, names, gender, 1)
     Person.listof.append(self)
     self.comment = comment
Exemple #23
0
 def life(self, fld, location, val, neighbours):
     if val == ' ':
         if neighbours == 3:
             things.append(Thing(fld, cell, location))
     elif not (1 < neighbours < 4):
         val.remove()
Exemple #24
0
 def __init__(self, name, names, elements, gender = 'F'):
     Thing.__init__(self, name, names)
     Garment.listof.append(self)
     self.elements = elements
     self.gender = gender
Exemple #25
0
 def __init__(self, name, names='', positivity=0.5):
     Thing.__init__(self, name, names)
     self.positivity = positivity
     State.listof.append(self)
Exemple #26
0
 def __init__(self, name, names, transitive=0):
     Thing.__init__(self, name, names, 0, None)
     self.transitive = transitive
     Action.listof.append(self)
Exemple #27
0
 def __init__(self, initial_pos=None, editable=True):
     Thing.__init__(self,
           pygame.image.load(os.path.join("data", "images", "target.png")),
           editable, None,
           initial_pos, elasticity = 100, mobility = False,
           gravity = 10)