Пример #1
0
 def load_image(self, name, scale):
     fullname = engine.get_file(name)
     try:
         image = pygame.image.load(fullname)
     except pygame.error, message:
         raise SystemExit, message
Пример #2
0
	def load_image(self, name, scale):
		fullname = engine.get_file(name)
		try:
			image = pygame.image.load(fullname)
		except pygame.error, message:
			raise SystemExit, message
Пример #3
0
            if self.up:
                self.rect.y -= self.dy
            else:
                self.rect.y += self.dy
            if self.rect.y <= self.miny:
                self.up = False
            elif self.rect.y >= self.maxy:
                self.up = True
        if self.horizontal:
            self.rect.x += self.dx
            if self.rect.x >= self.maxx:
                self.dx = -self.dx
            elif self.rect.x <= self.minx:
                self.dx = -self.dx


class Text(Entity):
    def __init__(self, text, size, fontname, (x, y), (r, g, b)):
        pygame.sprite.Sprite.__init__(self)
        self.enttype = "text"
        self.jumpheight = 0
        self.jumping = False
        self.load_font(text, size, fontname, (r, g, b))
        self.rect.topleft = (x, y)

    def load_font(self, text, size, fontname, (r, g, b)):
        fullname = engine.get_file(fontname)
        font = pygame.font.Font(fullname, size)
        self.image = font.render(text, 1, (r, g, b))
        self.rect = self.image.get_rect()
Пример #4
0
			if self.up:
				self.rect.y -= self.dy
			else:
				self.rect.y += self.dy
			if self.rect.y <= self.miny:
				self.up = False
			elif self.rect.y >= self.maxy:
				self.up = True
		if self.horizontal:
			self.rect.x += self.dx
			if self.rect.x >= self.maxx:
				self.dx = -self.dx
			elif self.rect.x <= self.minx:
				self.dx = -self.dx

class Text(Entity):
	def __init__(self, text, size, fontname, (x, y), (r, g, b)):
		pygame.sprite.Sprite.__init__(self)
		self.enttype = "text"
		self.jumpheight = 0
		self.jumping = False
		self.load_font(text, size, fontname, (r, g, b))
		self.rect.topleft = (x, y)

	def load_font(self, text, size, fontname, (r, g, b)):
		fullname = engine.get_file(fontname)
		font = pygame.font.Font(fullname, size)
		self.image = font.render(text, 1, (r, g, b))
		self.rect = self.image.get_rect()