def __init__(self, position, fill_color): super().__init__() self.growing = True self.sprite = sf.CircleShape(33) self.sprite.fill_color = sf.Color(fill_color.r, fill_color.g, fill_color.b, 50) self.sprite.position = position - sf.Vector2(0, 5) self.sprite2 = sf.CircleShape(50) self.sprite2.fill_color = sf.Color(fill_color.r, fill_color.g, fill_color.b, 190) self.sprite2.position = position - sf.Vector2(0, 5)
def create_grid_elements(self): # creating start and target points self.start_point = sf.CircleShape(self.grid_step / 2) self.start_point.fill_color = sf.Color.RED self.start_point.origin = (self.grid_step / 2, self.grid_step / 2) self.start_point.position = (-self.grid_step / 2, -self.grid_step / 2) self.target_point = sf.CircleShape(self.grid_step / 2) self.target_point.fill_color = sf.Color.GREEN self.target_point.origin = (self.grid_step / 2, self.grid_step / 2) self.target_point.position = (-self.grid_step / 2, -self.grid_step / 2) # building a wall self.wall_shape = self.new_wall()
def nuklearSfmlDrawCircleFilled(self,cmd,window): p=pynk.ffi.cast("struct nk_command_circle_filled*",cmd) circle=sf.CircleShape() circle.radius=p.h/2 circle.position=sf.Vector2(p.x, p.y) circle.fill_color=sf.Color(p.color.r, p.color.g, p.color.b, p.color.a) window.draw(circle)
def reset(self): super().reset() shape = sf.CircleShape(0.1) shape.origin = (0.1, 0.1) shape.position = (self.width / 2, self.height / 2) shape.fill_color = sf.Color.TRANSPARENT self.shapes.append(shape) self.update()
def reset(self): super().reset() shape = sf.CircleShape(math.sqrt((self.width/2)**2 + (self.height/2)**2)) shape.origin = (shape.radius, shape.radius) shape.position = (self.width / 2, self.height / 2) shape.fill_color = sf.Color.TRANSPARENT self.shapes.append(shape) self.update()
def __init__(self, speed, position, boundary=None): self.velocity = speed self.boundary = boundary self.shape = sf.CircleShape() self.shape.radius = 2 self.shape.fill_color = sf.Color.WHITE self.shape.position = position
def __init__(self, pos, radius, color=sf.Color.BLACK): self.circle = sf.CircleShape(radius) self.circle.origin = ((radius / 2.0, radius / 2.0)) self.circle.fill_color = sf.Color.BLUE self.circle.outline_color = color self.circle.outline_thickness = 1 self.circle.position = pos
def get_circle(): start_point_x, start_point_y = self._draw_scope['start-point'] current_x, current_y = event.position diameter = int(math.sqrt(abs(start_point_x - current_x) ** 2 + abs(start_point_y - current_y) ** 2)) circle = sf.CircleShape() circle.outline_color = self._draw_color circle.fill_color = sf.Color.TRANSPARENT circle.outline_thickness = 1 circle.radius = diameter / 2 circle.position = ((start_point_x + current_x) / 2 - circle.radius, (start_point_y + current_y) / 2 - circle.radius) return circle
def circle(window, colors, pos, radius, outline_thickness=0): o = sf.CircleShape() o.radius = radius o.outline_thickness = outline_thickness try: o.outline_color = sf.Color(colors[1][0], colors[1][1], colors[1][2]) except: o.outline_color = sf.Color(0, 0, 0) o.fill_color = sf.Color(colors[0][0], colors[0][1], colors[0][2]) o.origin = (0, 0) o.position = pos window.draw(o) return o
def __init__(self, size, position, velocity, boundary=None, wrapping=False): self.size = size self.sizeMultiplier = 5 self.velocity = velocity self.shape = sf.CircleShape(size * self.sizeMultiplier) self.shape.position = position self.shape.outline_thickness = 1 self.shape.outline_color = sf.Color.WHITE self.shape.fill_color = sf.Color.BLACK self.boundary = boundary self.wrapping = wrapping
def __init__(self, color=sf.Color.GREEN, position=(0, 0), velocity=(1, 1), powerupType="none"): self.powerupType = powerupType self.lifetime = 20 self.creationTime = time.time() self.position = position self.velocity = velocity self.shape = sf.CircleShape(8) self.shape.position = self.position self.shape.fill_color = color
def __init__(self): super(Player, self).__init__() self.texture = sf.Texture.from_file("data/images/basic_human.png") self.sprite = sf.Sprite(self.texture) self.sprite.texture_rectangle = [25, 15, 100, 170] self.x_pos = 0 self.y_pos = 0 self.direction = 0 self.x_speed = 0 self.y_speed = 0 self.movespeed = 0.3 self.maxHP = 100 self.currntHP = 95 self.animations = AnimationManager() self.animations.create( Animation("walk_forward", 25, 15 + 190, 75, 185, 0, 190, 5, 0.0125)) self.animations.create( Animation("walk_back", 275, 15 + 190, 75, 185, 0, 190, 5, 0.0125)) self.animations.create( Animation("walk_left", 155, 15 + 190, 75, 185, 0, 190, 5, 0.0125)) self.animations.create( Animation("walk_right", 410, 15 + 190, 75, 185, 0, 190, 5, 0.0125)) self.animations.create( Animation("stay_forward", 25, 15, 75, 155, 0, 185, 1, 0.01)) self.animations.create( Animation("stay_back", 275, 15, 75, 155, 0, 185, 1, 0.01)) self.animations.create( Animation("stay_left", 155, 15, 75, 155, 0, 185, 1, 0.01)) self.animations.create( Animation("stay_right", 410, 15, 75, 155, 0, 185, 1, 0.01)) self.animations.play("stay_back") self.sprite.position = [window.size.x / 2, window.size.y / 2] self.sprite.origin = [36, 140] self.magic_hand = sf.CircleShape() self.magic_hand.radius = 10 self.x_magicoffset = 0 self.y_magicoffset = 0 self.usable_counter = None self.inventory = []
def mainloop(pis): size = sf.Vector2(1024, 600) vmode = sf.VideoMode(1024, 600) view = sf.View() view.size = size view.center = sf.Vector2(0, 0) window = sf.RenderWindow(vmode, "tokenring", sf.Style.FULLSCREEN) window.framerate_limit = 60 window.view = view clothes = [PiCloth(pi, 30) for p, pi in sorted(pis.items())] place_in_circle(clothes, size) selected_player = None observable_cloth = None world = None brush = sf.CircleShape(10) selected = set() while window.is_open: for event in window.events: if event == sf.Event.CLOSED: window.close() if event == sf.Event.MOUSE_BUTTON_PRESSED: v = sf.Vector2(event['x'], event['y']) - size / 2 target = get_cloth_under(clothes, v) if event['button'] == sfml.window.Button.LEFT and target: methods = ['add', 'remove'] getattr(selected, methods[target in selected])(target) if event['button'] == sfml.window.Button.RIGHT and target: observable_cloth = target t = time() maxtime = max(t - c.pi.ltt for c in clothes if c.pi.ltt > 0) mp = sf.Mouse.get_position(window) mp -= size / 2 selected_player = None for c in clothes: c.resolve_color(t, maxtime) if c.under(mp): selected_player = c if observable_cloth: observable_cloth.fill_color = sf.Color.BLUE world = observable_cloth.pi.world for selected_player in selected: selected_player.fill_color = sf.Color.YELLOW play_with_selected(selected_player) window.clear(sf.Color.BLACK) for c in clothes: window.draw(c) draw_world(world, window, brush) window.display()
left_paddle.size = paddle_size - (3, 3) left_paddle.outline_thickness = 3 left_paddle.outline_color = sf.Color.BLACK left_paddle.fill_color = sf.Color(100, 100, 200) left_paddle.origin = paddle_size / 2 # create the right paddle right_paddle = sf.RectangleShape() right_paddle.size = paddle_size - (3, 3) right_paddle.outline_thickness = 3 right_paddle.outline_color = sf.Color.BLACK right_paddle.fill_color = sf.Color(200, 100, 100) right_paddle.origin = paddle_size / 2 # create the ball ball = sf.CircleShape() ball.radius = ball_radius - 3 ball.outline_thickness = 3 ball.outline_color = sf.Color.BLACK ball.fill_color = sf.Color.WHITE ball.origin = (ball_radius / 2, ball_radius / 2) # load the font font = sf.Font.from_file("data/sansation.ttf") # initialize the pause message pause_message = sf.Text() pause_message.font = font pause_message.character_size = 40 pause_message.position = (170, 150) pause_message.color = sf.Color.WHITE
def _add_basic_point(self, point): mark = sf.CircleShape(5) mark.position = point[0]-5, point[1]-5 mark.fill_color = sf.Color.RED self._draw_bezier_nodes.append(mark) self._basic_bezier_points.append(point)
def __init__(self, oc=sf.Color.WHITE, ic=sf.Color.TRANSPARENT): sf.Drawable.__init__(self) self.circle = sf.CircleShape() self.circle.outline_color = oc self.circle.fill_color = ic
def get_erase_circle(_x, _y): eraser = sf.CircleShape(erase_size) eraser.fill_color = self._bg eraser.position = (_x - erase_size, _y - erase_size) return eraser