Exemplo n.º 1
0
def Button(screen, id, text, rect, **kwargs):
	global hot
	color = "white"
	clicked = False
	if hot == id:
		if inside(game.get_mouse_pos(), offset(rect, context)):
			if game.get_mouse_released(1):
				hot = None
				clicked = True
		else:
			hot = None
		color = "grey"
	else:
		if inside(game.get_mouse_pos(), offset(rect, context)) and game.get_mouse_pressed(1) and not hot:
			hot = id
	if "draw" not in kwargs:
		draw_box(screen, offset(rect, context), color)
		draw_text(screen, text, (rect[0]+context[0]+10, rect[1]+context[1]+10))
	return clicked
Exemplo n.º 2
0
	def get_mouse_pos(self):
		mouse = game.get_mouse_pos()
		return (self.rect[0]+mouse[0], self.rect[1]-(mouse[1]-self.rect[3]))