Esempio n. 1
0
 def __init__(self, master, pos, img, states=["default"]):
     """
     Blits an image.
     """
     self.master = master
     self.master.add_widget(self)
     self.cursor = self.master.cursor
     self.id = id(self)
     self.pos = [pos[0]+self.master.rect.x, pos[1]+self.master.rect.y]
     self.img = img
     self.dimg = img
     self.rect = self.img.get_rect()
     self.rect.x = self.pos[0]
     self.rect.y = self.pos[1]
     self.states = states
     self.flashing = False
     if self.img.get_width()<=29:
         self.flashy = load_image("./data/image/menu/flashing_button1.png", \
         True).convert()
     else:
         self.flashy = load_image("./data/image/menu/flashing_button.png", \
         True).convert()
     self.alpha = 0
     self.flashy.set_alpha(0)
     self.frec = self.flashy.get_rect(center=self.rect.center)
     self.o = 1
Esempio n. 2
0
	def __init__(self, dataFolder, levelFile):
		self._dataFolder = dataFolder
		self._pelletCount = 0

		with open(levelFile) as f:
			self._level = simplejson.load(f)

		self._block, _ = helpers.load_image(self._get_image_name("block"))
		self._pellet, _ = helpers.load_image(self._get_image_name("pellet"))
		self._greenMan, _ = helpers.load_image(self._get_image_name("greenMan"))
		self._greenManClosed, _ = helpers.load_image(self._get_image_name("greenManClosed"))
		self._monster_01, _ = helpers.load_image(self._get_image_name("monster_01"))
		self._monster_scared_01, _ = helpers.load_image(self._get_image_name("monster_scared_01"))
		self._monster_evil_01, _ = helpers.load_image(self._get_image_name("monster_evil_01"))
		self._purpleMan, _ = helpers.load_image(self._get_image_name("purpleMan"))
		self._purpleManClosed, _ = helpers.load_image(self._get_image_name("purpleManClosed"))
		self._superPellet, _ = helpers.load_image(self._get_image_name("super_pellet"))
		self._images = {
			self.BLOCK: self._block,
			self.GREENMAN: self._greenMan,
			self.GREENMAN_CLOSED: self._greenManClosed,
			self.PELLET: self._pellet,
			self.MONSTER: self._monster_01,
			self.SCARED_MONSTER: self._monster_scared_01,
			self.EVIL_MONSTER: self._monster_evil_01,
			self.PURPLEMAN: self._purpleMan,
			self.PURPLEMAN_CLOSED: self._purpleManClosed,
			self.SUPER_PELLET: self._superPellet,
		}
		self._biteSound = pygame.mixer.Sound(self._get_sound_name("bite"))
		self._superSound = pygame.mixer.Sound(self._get_sound_name("super"))
		self._killSound = pygame.mixer.Sound(self._get_sound_name("kill"))
Esempio n. 3
0
    def _load_images(self):
        """Ustaw FishSprite.images, wczytując obrazki z dysku jeżeli to
        konieczne.
        """
        if hasattr(FishSprite, 'images'):
            return

        FishSprite.images = [
            load_image('fish/fish-1.gif'),
            load_image('fish/fish-2.gif'),
            load_image('fish/fish-3.gif'),
            load_image('fish/fish-4.gif')]
 def __init__(self, xloc):
     pygame.sprite.Sprite.__init__(self)
     self.image, self.rect = helpers.load_image('pong_paddle.png')
     self.rect.centerx = xloc
     self.rect.centery = 400
     self.speed = 5
     self.yvel = 0
Esempio n. 5
0
 def __init__(self, position, possible_values):
     pygame.sprite.Sprite.__init__(self)
     self.image, self.rect = load_image('coin.png')
     self.rect.topleft = position
     
     #getting a value randomically
     key_value = random.randint(0, len(possible_values) - 1)
     self.value = possible_values.pop(key_value)
 def getLayout(self):
     return [[9, 9, 9 ,9, 9, 9, 9, 9],\
             [9, 9, 9, 9, 9, 9, 9, 9],\
             [9, 1, 1, 1, 1, 1, 1, 9],\
             [9, 0, 0, 0, 0, 0, 0, 9],\
             [9, 0, 1, 1, 0, 1, 1, 9],\
             [9, 0, 2, 0, 0, 0, 0, 9],\
             [9, 0, 1, 1, 0, 1, 0, 9],\
             [9, 0, 0, 0, 0, 1, 0, 9]
          
             
     
 def getSprites(self):
     block, rect = load_image('')
     pellet, rect = load_image('pellet.png',-1)
     snake, rect = load_image('snake.png',-1)
     return [pellet,block,snake]
     
Esempio n. 7
0
 def __init__(self):
     pygame.sprite.Sprite.__init__(self)
     self.image, self.rect = load_image("rocket.png")
     screen = pygame.display.get_surface()
     self.area = screen.get_rect()
     self.rect.topleft = 40, 310
     self.move = 9
     self.angle = -90
     self.dir = -5
     self.original = self.image
Esempio n. 8
0
 def __init__(self, position, possible_values):
     pygame.sprite.Sprite.__init__(self)
     
     #getting a value randomically
     key_value = random.randint(0, len(possible_values) - 1)
     fish = possible_values.pop(key_value)
     
     self.value = fish[0]
     self.image, self.rect = load_image(fish[1])
     self.rect.topleft = position
Esempio n. 9
0
 def __init__(self, pos, goal, creeps, pemit, player):
     pygame.sprite.Sprite.__init__(self)
     self.goal = goal
     self.creeps = creeps
     self.image = load_image("./data/image/objects/mchammer.png")
     self.rect = self.image.get_rect()
     self.rect.centerx = pos[0]
     self.rect.centery = pos[1]
     self.speed = 1
     self.particle_emitter = pemit
     self.player = player
Esempio n. 10
0
        def frames_in_direction(direction):
            frames = []

            for frame in range(1, self.number_of_frames+1):
                # Wczytaj klatkę z dysku.
                frame = load_image('penguin/penguin-%d-%s-%d.gif' % (id, direction, frame))
                # Nanieś na klatkę identyfikator gracza.
                add_name_to_penguin(str(self.penguin.number), frame, self.penguin.color)
                # Dodaj klatkę do listy.
                frames.append(frame)

            return frames
Esempio n. 11
0
    def __init__(self, image_names, path='../Images/Buttons', pos=(0, 0), function=None, parent=None,
                 text='Simple Button',
                 w=0, h=0):
        self.image_normal = helpers.load_image(image_names[0], alpha_channel=True,
                                               dir_name=path)  # изображение кнопки в базовом состоянии
        self.image_on_over = helpers.load_image(image_names[1], alpha_channel=True,
                                                dir_name=path)  # изображение кнопки в базовом состоянии
        self.image_on_click = helpers.load_image(image_names[2], alpha_channel=True,
                                                 dir_name=path)  # изображение кнопки в базовом состоянии
        self.images = [self.image_normal, self.image_on_over, self.image_on_click]  # список с кнопками
        if w != 0 and h != 0:  # изменение размера картинки, если заданы ширина и высота
            for i in range(0, 3):
                self.images[i] = pygame.transform.scale(self.images[i], (w, h))
        elif w != 0 and h == 0:  # если задан один размер, то второй изменяется пропорционально
            for i in range(0, 3):
                rect = self.images[i].get_rect()
                h = int(rect.h * (w / rect.w))
                self.images[i] = pygame.transform.scale(self.images[i], (w, h))
        elif w == 0 and h != 0:
            for i in range(0, 3):
                rect = self.images[i].get_rect()
                w = int(rect.w * (h / rect.h))
                self.images[i] = pygame.transform.scale(self.images[i], (w, h))

        self.current_image = self.images[0]  # текущая картинка

        self.rect = self.current_image.get_rect()
        self.rect.x = pos[0]
        self.rect.y = pos[1]

        self.text = Text_Button.Text(text)  # текст кнопки
        self.text_surf = self.text.font.render(text, True, (0, 0, 0))  # поверхность текста
        self.rect_text = self.text_surf.get_rect()  # рект текста
        # смещение текста на центр картинки кнопки,
        self.rect_text.x = self.rect.x + self.rect.w / 2 - self.rect_text.w / 2
        # к координате кнопки прибавляется половина длины картинки и отнимается половина длины текста
        self.rect_text.y = self.rect.y + self.rect.h / 2 - self.rect_text.h / 2

        self.function = function  # функция кнопки
        self.parent = parent  # родитель кнопки, по умолчанию отсутствует
Esempio n. 12
0
File: Snow.py Progetto: kotland/Snow
 def __init__(self, pos, wind_power=50):
     self.image = helpers.load_image('Bez_imeni.png', 1, IMAGE_PATH)
     self.pos = Vector(pos)
     self.speed = Vector((0, 5))
     self.transform()
     # self.angle = 6
     self.snow_list = []
     self.status = MOVE_DOWN
     wind1 = StrongWind(0.01, 0, 1, 0)
     wind2 = ConstantWind(-1*wind_power/1000, 0, random.randint(2000, 3000), 7000)
     self.winds = [wind1, wind2]
     w, h = 20, 20
     self.area = pygame.Rect(0, 0, w, h)
Esempio n. 13
0
  def __init__(self, pic):
    pygame.sprite.Sprite.__init__(self) 
    self.screen = pygame.display.get_surface()
    self.image, self.rect = helpers.load_image(pic, -1)
    new_size = random.randint(5, self.rect.width)
    self.image = pygame.transform.scale(self.image, (new_size, new_size))
    self.rect = self.image.get_rect()

    self.x = random.randint(0, self.screen.get_width())
    self.y = random.randint(0, self.screen.get_height()-self.rect.height)
    self.rect.topleft = (self.x, self.y)
    self.speedy = self.speedx = random.uniform(0.1, 0.3)
    self.curr_ticks = pygame.time.get_ticks()
Esempio n. 14
0
def setup():
    for i in xrange(20):
        continue
        #ROOT.children.append(RectNode(_random_color(), _random_rect()))

        sprite = pygame.sprite.DirtySprite(SpriteNode.spritegroup)
        sprite.image, sprite.rect = load_image("icon.png")
        node = SpriteNode(sprite)
        x, y = (random.randint(0, WIDTH), random.randint(0, HEIGHT))
        sprite.rect.center = x, y
        ROOT.children.append(node)

    for c in ROOT.children:
        print c.sprite.rect

    setup_ui()
    setup_pet()
Esempio n. 15
0
    def __init__(self, title="Penguin"):
        self.title = title

        # Inicjalizacja, ustawienie rozdzielczości i tytułu.
        pygame.init()
        self.screen = pygame.display.set_mode((self.width, self.height))
        pygame.display.set_caption(self.title)

        # Ustawienie powtarzania klawiszy.
        pygame.key.set_repeat(200, 30)

        # Wczytaj obrazek na górną belkę.
        self.status_bar_image = load_image('header.jpg')

        self.text = None

        # Zacznij odświeżać ekran z domyślną częstotliwością.
        refresh_it(self)
Esempio n. 16
0
 def __init__(self, player, coord_x, coord_y, rect=None):
     """Ctor"""
     pygame.sprite.Sprite.__init__(self)
     
     self.player = player
     self.coord_x = coord_x
     self.coord_y = coord_y
     
     if player == 1:
         img = 'one.png'
     elif player == 2:
         img = 'two.png'
     else:
         img = 'empty.png'
     
     self.image, self.rect = load_image(img, -1)
     
     if rect != None:
         self.rect = rect
Esempio n. 17
0
 def __init__(self):
     pygame.sprite.DirtySprite.__init__(self)
     self.image, self.rect = helpers.load_image('mallet.png',-1)
     self.dirty = 2
     self._layer = 99
Esempio n. 18
0
 def __init__(self, file_name, passable):
     pygame.sprite.Sprite.__init__(self)
     self.image, self.rect = helpers.load_image(file_name)
     self.passable = passable
Esempio n. 19
0
 def getSprites(self):
     block, rect = load_image('blocos.png')
     pellet, rect = load_image('pellet.png',-1)
     snake, rect = load_image('livro.png',-1)
     letterA, rect = load_image('A.png',-1)
     letterB, rect = load_image('B.png',-1)
     letterC, rect = load_image('C.png',-1)
     letterCD, rect = load_image('CD.png',-1)
     letterD, rect = load_image('D.png',-1)
     letterE, rect = load_image('E.png',-1)
     letterF, rect = load_image('F.png',-1)
     letterG, rect = load_image('G.png',-1)
     letterH, rect = load_image('H.png',-1)
     letterI, rect = load_image('I.png',-1)
     letterJ, rect = load_image('J.png',-1)
     letterK, rect = load_image('K.png',-1)
     letterL, rect = load_image('L.png',-1)
     letterM, rect = load_image('M.png',-1)
     letterN, rect = load_image('N.png',-1)
     letterO, rect = load_image('O.png',-1)
     letterP, rect = load_image('P.png',-1)
     letterQ, rect = load_image('Q.png',-1)
     letterR, rect = load_image('R.png',-1)
     letterS, rect = load_image('S.png',-1)
     letterT, rect = load_image('T.png',-1)
     letterU, rect = load_image('U.png',-1)
     letterV, rect = load_image('V.png',-1)
     letterX, rect = load_image('X.png',-1)
     letterY, rect = load_image('Y.png',-1)
     letterW, rect = load_image('W.png',-1)
     letterZ, rect = load_image('Z.png',-1)
     letterAT, rect = load_image('AT.png',-1)
     
     return [pellet,block,snake,letterA,letterB,letterC,letterCD,letterD,letterE,letterF,letterG,letterH,letterI,letterJ,letterK,letterL,letterM,letterN,letterO,letterP,letterQ,letterR,letterS,letterT,letterU,letterV,letterX,letterY,letterW,letterZ,letterAT]
Esempio n. 20
0
 def getPicture(self):
     figura, rect = load_image('figuras/diamante.png',-1)
     picture = basicSprite.Sprite([640,300],figura,'IMG')
     return picture
 def __init__(self, pic):
   pygame.sprite.Sprite.__init__(self) 
   self.image, self.rect = helpers.load_image(pic, None)
   self.screen = pygame.display.get_surface()
   self.area = self.screen.get_rect()
   self.rect.topleft = (0, 0)
Esempio n. 22
0
	def __init__(self):
		super().__init__()
		self.image, self.rect = load_image("derf.jpg", None)
		self.image = pygame.transform.scale(self.image, (int(500*0.80), int(707*0.80)))
		self.rect.move_ip(200, 0)
		self.cycles = 0
Esempio n. 23
0
	def __init__(self, west=True):
		super().__init__()
		self.image, self.rect = load_image("airhorn2.png", -1)
		if west:
			self.image = pygame.transform.flip(self.image, True, False)
		self.rect.move_ip(800, 0)
Esempio n. 24
0
 def __init__(self, location, layer = 2):
     pygame.sprite.DirtySprite.__init__(self)
     self._layer = layer
     
     self.image, self.rect = helpers.load_image('wall.png',-1)
     self.rect.center = location
Esempio n. 25
0
File: world.py Progetto: a-leut/sss
 def load_images(cls):
 	World.image = helpers.load_image('startile.png')
Esempio n. 26
0
    def _init_grounds(self):
        """Wczytaj obrazki podłoża, zbierając je w słowniku
        self.ground, gdzie klucz odpowiada znakowi użytemu
        na mapce poziomu.
        """
        self.ground = {
            ' ': load_image('ground/snow.gif'),
            '~': load_image('ground/water.gif'),
            '#': load_image('ground/wall.gif'),

            '[': load_image('ground/wall-horizontal-left.gif'),
            '=': load_image('ground/wall-horizontal-middle.gif'),
            ']': load_image('ground/wall-horizontal-right.gif'),

            '?': load_image('ground/wall-vertical-top.gif'),
            '|': load_image('ground/wall-vertical-middle.gif'),
            '.': load_image('ground/wall-vertical-bottom.gif'),

            '<': load_image('ground/ice-horizontal-left.gif'),
            '-': load_image('ground/ice-horizontal-middle.gif'),
            '>': load_image('ground/ice-horizontal-right.gif'),

            '^': load_image('ground/ice-vertical-top.gif'),
            '/': load_image('ground/ice-vertical-middle.gif'),
            ',': load_image('ground/ice-vertical-bottom.gif')}
 def getSprites(self):
     block, rect = load_image('')