def scanner_test():
    w = sf.RenderWindow(sf.VideoMode(400, 400), "Scanner Test")
    clock = sf.Clock()

    em = MyEntityManager()
    sm = SystemManager(em)

    car1 = em.create_entity()
    em.add_component(car1, PositionComponent(0, 0, 0))
    em.add_component(car1, VelocityComponent(0, 0, 0))
    car1_circle = sf.CircleShape()
    car1_circle.radius = 10
    car1_circle.fill_color = sf.Color.RED
    em.add_component(car1, DrawableComponent(car1_circle))
    em.add_component(car1, MovementControlComponent())
    em.add_component(car1,
                     ScanSoundComponent("engine_idle_freesound_loop.wav"))
    car1_engine_sound = PositionSoundComponent(
        "engine_idle_freesound_loop.wav")
    car1_engine_sound.sound.loop = True
    em.add_component(car1, car1_engine_sound)

    player = em.create_entity()
    em.add_component(player, PositionComponent(100, 100, 0))
    em.add_component(player, VelocityComponent(0, 0, 0))
    em.add_component(player, DirectionComponent(radians(180)))
    player_circle = sf.CircleShape()
    player_circle.radius = 10
    player_circle.fill_color = sf.Color.WHITE
    em.add_component(player, DrawableComponent(player_circle))
    #em.add_component(player, MovementControlComponent())
    em.add_component(player, AudioListenerComponent())
    em.add_component(player, HydrophoneComponent(radians(0)))

    sm.add_system(InputSystem(w))
    sm.add_system(PhysicsSystem())
    sm.add_system(AudioSystem())
    sm.add_system(RenderSystem(w))

    while w.is_open:
        sm.update(clock.restart())

        for event in w.events:
            if type(event) is sf.CloseEvent:
                w.close()

        #
        w.display()
示例#2
0
    def __init__(self):
        self.window = sf.RenderWindow(sf.VideoMode(WIDHT, HEIGHT), TITLE,
                                      sf.Style.DEFAULT, settings)
        self.window.framerate_limit = FPS

        self.clock = sf.Clock()

        self.ball = sf.CircleShape(30)
        self.ball.origin = self.ball.radius, self.ball.radius
        self.ball.position = self.window.size / 2
        x = randint(1, 5)
        y = randint(1, 5)
        if randint(0, 1) % 2 == 0:
            x *= -1.0
        if randint(0, 1) % 2 == 0:
            y *= -1.0

        self.ball_vel = sf.Vector2(x, y)
        self.ball_sound = None

        #sol çubuk
        self.p_left = sf.RectangleShape((30, 200))
        x = self.p_left.size.x / 2
        y = (HEIGHT - self.p_left.size.y) / 2
        self.p_left.position = sf.Vector2(x, y)
        self.left_score = 0

        #sağ çubuk
        self.p_right = sf.RectangleShape((30, 200))
        x = WIDHT - (self.p_right.size.x * 1.5)
        y = (HEIGHT - self.p_left.size.y) / 2
        self.p_right.position = sf.Vector2(x, y)
        self.right_score = 0

        self.font = None
示例#3
0
 def _create_renderables(self):
     self.polygon = sf.CircleShape(self.poly_radius)
     self.polygon.fill_color = sf.Color.BLACK
     self.polygon.position = sf.Vector2(int(self.pos_x * self.window_x),
                                        int(self.pos_y * self.window_y))
     self.polygon.origin = sf.Vector2(self.poly_radius, self.poly_radius)
     return [self.polygon]
    def update(self, particles, stats):
        self.window.clear(sf.Color.WHITE)

        # Render map
        for area in self.world:
            self.window.draw(area[0])
            self.window.draw(area[1])

        count = 0
        for p in particles:
            for f in range(p.position.shape[0] / 2):
                if count >= len(self.facilities):
                    self.facilities.append(sf.CircleShape())

                self.facilities[count].radius = 3
                self.facilities[count].fill_color = sf.Color.RED
                self.facilities[count].position = (10 +
                                                   p.position[f * 2 + 0] * 20,
                                                   10 +
                                                   p.position[f * 2 + 1] * 20)
                self.window.draw(self.facilities[count])

        self.stats.string = stats
        self.window.draw(self.stats)

        self.window.display()
示例#5
0
    def _create_renderables(self):
        size_x = int(self.L * self.window_x)
        size_y = 25
        rod = sf.RectangleShape(size=sf.Vector2(size_x, size_y))
        rod.fill_color = sf.Color.BLACK
        rod.origin = sf.Vector2(0, int(size_y / 2))

        weight = sf.CircleShape(self.circle_radius)
        weight.fill_color = sf.Color.BLUE
        weight.origin = sf.Vector2(self.circle_radius - size_x,
                                   self.circle_radius)

        pivot = sf.CircleShape(int(size_y / 2))
        pivot.fill_color = rod.fill_color
        pivot.origin = sf.Vector2(pivot.radius, pivot.radius)
        return [rod, weight, pivot]
	def __init__(self, position=None, color=None):

		sf.Drawable.__init__(self)

		self.shape = sf.CircleShape(settings.ENTITY_SIZE/2)

		r = random.randrange(56, 256)
		g = random.randrange(56, 256)
		b = random.randrange(56, 256)
		self.shape.fill_color = sf.Color(r, g, b, 50)
		self.shape.outline_color = sf.Color(r, g, b, 200)
		self.shape.outline_thickness = 1

		v_x = random.randrange(-max_speed, max_speed + 1)
		v_y = random.randrange(-max_speed, max_speed + 1)
		self.position = position
		self.velocity = sf.Vector2(v_x, v_y)

		self.line = sf.VertexArray(sf.PrimitiveType.LINES, 2)
		self.line[0].color = sf.Color(r, g, b, 200)
		self.line[1].color = sf.Color(r, g, b, 50)

		self.centre_of_mass = sf.Vector2()
		self.average_velocity = sf.Vector2()
		self.num_nearby_entities = 0
示例#7
0
def new_point():
    x = random.randint(0, 640)  #
    y = random.randint(0, 480)
    circle = sf.CircleShape()
    circle.radius = 20
    circle.outline_color = sf.Color.GREEN
    circle.position = (x, y)
    return circle
示例#8
0
 def __init__(self):
     self.window = sf.RenderWindow(sf.VideoMode(WIDHT, HEIGHT), TITLE,
                                   sf.Style.DEFAULT, settings)
     self.window.framerate_limit = 20
     self.circle = sf.CircleShape(50)
     self.circle.origin = self.circle.radius, self.circle.radius
     self.circle.position = self.window.size / 2
     self.c_vel = sf.Vector2(5, 5)
     self.clock = sf.Clock()
示例#9
0
 def __init__(self, pos, rot):
     self.position = pos
     self.rotation = rot
     radius = 2
     self.drawable = sf.CircleShape(radius=radius)
     self.drawable.fill_color = ORANGE
     self.drawable.outline_color = GREY
     self.drawable.outline_thickness = 1
     self.drawable.origin = radius, radius
 def __init__(self, position, radius, speed):
     self.speed = speed
     self.image = sf.CircleShape()
     self.image.outline_thickness = 10
     self.image.radius = radius
     self.image.origin = (radius, radius)
     self.image.position = sf.Vector2(*position)
     self.image.outline_color = sf.Color.BLACK
     self.image.fill_color = sf.Color(255, 100, 200)
示例#11
0
 def __init__(self,window):
     self._window = window
     self._background = []
     self._radius = {}
     for x in range(40):
         self._background.append(sf.CircleShape())
         self._radius[self._background[x]] = random.randint(0,20)
         self._background[x].radius = self._radius[self._background[x]]
         self._background[x].position = (random.randint(0,self._window.size[0]),random.randint(0,self._window.size[1]))
         self._background[x].fill_color = sf.Color(random.randint(0,255),random.randint(0,255),random.randint(0,255))
示例#12
0
    def __init__(self):
        self.window = sf.RenderWindow(sf.VideoMode(WIDHT, HEIGHT), TITLE,
                                      sf.Style.DEFAULT, settings)
        self.circle = sf.CircleShape(50)
        self.rectangle = sf.RectangleShape((150, 200))
        self.rectangle.position = 200, 100

        self.view = sf.View()
        self.view.reset(sf.Rectangle((0, 0), self.window.size))
        self.window.view = self.view
示例#13
0
def run():
    SIZE = 0
    window = sf.RenderWindow(sf.VideoMode(WWIDTH, WHEIGHT), WTITLE)
    window.framerate_limit = 60

    # Background
    bg_texture = sf.Texture.from_file("assets/images/background.png")
    background = sf.Sprite(bg_texture)

    # Ball
    b_texture = []
    b_texture.append(sf.Texture.from_file("assets/bln/balon0.png"))
    b_texture.append(sf.Texture.from_file("assets/bln/balon1.png"))
    b_texture.append(sf.Texture.from_file("assets/bln/balon2.png"))
    b_texture.append(sf.Texture.from_file("assets/bln/balon3.png"))

    balls = []

    # Clock
    clock = sf.Clock()

    while window.is_open:
        for event in window.events:
            if type(event) is sf.CloseEvent:
                window.close()
        # Close
        if sf.Keyboard.is_key_pressed(sf.Keyboard.ESCAPE):
            window.close()

        elapsed = clock.elapsed_time.seconds
        clock.restart()
        for ball in balls:
            ball.position = ball.position.x, (ball.position.y + BALL_SPEED)
            if ball.position.y > WHEIGHT:
                balls.remove(ball)
                SIZE -= 1

        if SIZE < MAX_SIZE:
            ball = sf.CircleShape(rm.randint(20, 60))
            ball.texture = rm.choice(b_texture)
            ball.origin = 20, 20
            ball.position = rm.randint(40, WWIDTH - 80), rm.randint(
                -300, 0)  #WHEIGHT / 8.0
            balls.append(ball)
            SIZE += 1

        # Rendering
        window.clear(sf.Color.BLACK)

        window.draw(background)
        for ball in balls:
            window.draw(ball)

        window.display()
示例#14
0
    def __init__(self):
        self.window = sf.RenderWindow(sf.VideoMode(WIDTH, HEIGHT), TITLE)

        self.circle = sf.CircleShape(50)
        self.circle.origin = self.circle.radius, self.circle.radius

        try:
            bg_texture = sf.Texture.from_file('assets/images/background.png')

            plane_texture = sf.Texture.from_file('assets/images/planeRed1.png')
            s_buffer = sf.SoundBuffer.from_file('assets/sounds/tone1.ogg')
            music = sf.Music.from_file('assets/sounds/spaceTrash3.ogg')
            font = sf.Font.from_file('assets/fonts/kenvector_future_thin.ttf')
        except IOError:
            print("HATA VERDİ!!")
            sys.exit(-1)
示例#15
0
 def __init__(self, WindowSize, rate=15, debug=False):
     self.debug = debug
     self.window = Window(WindowSize, WindowSize)
     self.line = sf.VertexArray(sf.PrimitiveType.LINES_STRIP, 2)
     self.circle = sf.CircleShape()
     self.circle.fill_color = sf.Color.TRANSPARENT
     self.circle.radius = 2
     self.window.view.reset((0, 0, WindowSize, WindowSize))
     self.clear = self.window.clear
     self.draw = self.window.draw
     self.display = self.window.display
     self.window.framerate_limit = rate  # draw speed limiter
     self.scale = self.window.view.size.x / self.window.size.x
     self.pointClicked = sf.Vector2(0, 0)
     self.hideStuff = True
     self.panFrom = None
示例#16
0
def main():
    window = sf.RenderWindow(sf.VideoMode(800, 600), 'Shape example')
    window.framerate_limit = 60
    running = True
    clock = sf.Clock()

    custom_shapes = [CustomShape()]
    rectangles = []
    circles = []

    for i in range(30):
        circle = sf.CircleShape(randint(5, 20))
        circle.fill_color = random_color()
        circle.position = random_position(window)
        circles.append(circle)

    for i in range(100):
        rectangle = sf.RectangleShape((randint(10, 30), randint(10, 30)))
        rectangle.position = random_position(window)
        rectangle.fill_color = random_color()
        rectangle.outline_color = random_color()
        rectangle.outline_thickness = randint(1, 2)
        rectangles.append(rectangle)

    while running:
        for event in window.iter_events():
            if event.type == sf.Event.CLOSED:
                running = False

        frame_time = clock.restart().as_milliseconds()

        for r in rectangles:
            r.rotate(frame_time * 0.3)

        window.clear(sf.Color.WHITE)

        for shape in custom_shapes + rectangles + circles:
            window.draw(shape)

        window.display()

    window.close()
示例#17
0
    def initialize_contents(self):

        self._board_sprite_texture = sf.Texture.from_file(
            "Data/Images/board.png")
        self._board_sprite = sf.Sprite(self._board_sprite_texture)
        self._board_sprite.origin = self._board_sprite.global_bounds.width / 2, self._board_sprite.global_bounds.height / 2
        self._board_sprite.position = self._window.size.x / 2, self._window.size.y / 2

        self._board_rows_count = 6
        self._board_columns_count = 7

        self._chips_texture = sf.Texture.from_file('Data/Images/chips.png')

        self._radius = 35
        self._x_shift = 20
        self._y_shift = 10
        self._x_offset = self._board_sprite.global_bounds.left + self._radius + 15
        self._y_offset = self._board_sprite.global_bounds.top + self._radius + 6.5

        self._circle_holes = [[
            sf.CircleShape() for x in range(self._board_columns_count)
        ] for y in range(self._board_rows_count)]
        for i in range(len(self._circle_holes)):
            for j in range(len(self._circle_holes[i])):
                self._circle_holes[i][j].radius = self._radius - 3
                self._circle_holes[i][j].origin = self._circle_holes[i][
                    j].radius, self._circle_holes[i][j].radius
                self._circle_holes[i][j].point_count = 100
                self._circle_holes[i][j].outline_color = GameManager.blue_color
                self._circle_holes[i][j].outline_thickness = 4
                self._circle_holes[i][j].fill_color = sf.Color.TRANSPARENT
                self._circle_holes[i][j].position = self.get_coordinates(i, j)

        self._board_map = [[0 for x in range(self._board_columns_count)]
                           for y in range(self._board_rows_count)]
        self._chips_sprites = []

        self._ai_controller = AIController(self._board_map)

        self._turn = 1
        self._player_selection_column = 3

        self._is_chip_animating = False

        self._pending_chip = sf.Sprite(self._chips_texture)
        self._pending_chip.texture_rectangle = (0, 0, 150, 150)
        source_width = self._pending_chip.global_bounds.width
        source_height = self._pending_chip.global_bounds.height

        target_width = (self._radius - 3) * 2
        target_height = (self._radius - 3) * 2

        self._pending_chip.origin = source_width / 2, source_height / 2
        self._pending_chip.ratio = target_width / source_width, target_height / source_height
        self._pending_chip.position = self.get_coordinates(
            -1, self._player_selection_column)

        self._is_game_finished = False

        self._game_finished_text = sf.Text()
        self._game_finished_text.font = GameManager.game_font
        self._game_finished_text.character_size = 50
        self._game_finished_text.origin = self._game_finished_text.global_bounds.width / 2, self._game_finished_text.global_bounds.height / 2
        self._game_finished_text.position = self._window.size.x / 2, self._window.size.y / 2
        self._game_finished_text.color = sf.Color.WHITE

        self._game_finished_background = sf.RectangleShape()
        self._game_finished_background.fill_color = sf.Color(0, 0, 0, 200)
        self._game_finished_background.size = self._window.size
示例#18
0
# -*- coding: utf-8 -*-

import sfml as sf

WIDTH = 800
HEIGHT = 480
TITLE = "AB2015 Python Oyun Kursu"

pencere = sf.RenderWindow(sf.VideoMode(WIDTH, HEIGHT), TITLE)

cember = sf.CircleShape(150)

cember.fill_color = sf.Color.BLUE
cember.origin = cember.radius, cember.radius
cember.position = 200, 200

dikdortgen = sf.RectangleShape(
    sf.Vector2(150, 250)
)

dikdortgen.fill_color = sf.Color.RED
dikdortgen.outline_thickness = 2
dikdortgen.outline_color = sf.Color.BLUE

dikdortgen.origin = dikdortgen.size.x / 2, dikdortgen.size.y / 2

dikdortgen.rotate(15)

while pencere.is_open:
    for event in pencere.events:
示例#19
0
 def __init__(self, target, hue):
     self.target = target
     self.circ = sf.CircleShape(point_count=6)
     self.circ.outline_color = Hue(hue, a=.25)
     self.circ.fill_color = Hue(hue, a=.5)
示例#20
0
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
示例#21
0
tank.size = tank_size - (3, 3)
tank.outline_thickness = 3
tank.outline_color = sf.Color.BLACK
tank.fill_color = sf.Color(0, 100, 0)
tank.origin = tank_size / 2

# create the dray
dray = sf.RectangleShape()
dray.size = (5, game_size.y * 2)
dray.outline_thickness = 3
dray.outline_color = sf.Color.YELLOW
dray.fill_color = sf.Color.RED
dray.origin = dray.size / 2

#create snowflake
snowflake = sf.CircleShape()
snowflake.radius = 15
snowflake.fill_color = sf.Color.WHITE
snowflake.origin = (15, 15)

hit_snowflake = sf.CircleShape()
hit_snowflake.radius = 10
hit_snowflake.outline_thickness = 5
hit_snowflake.outline_color = sf.Color.RED
hit_snowflake.fill_color = sf.Color.YELLOW
hit_snowflake.origin = (15, 15)

# load the font
font = sf.Font.from_file("data/sansation.ttf")

# initialize the pause message
示例#22
0
def run():
    window = sf.RenderWindow(sf.VideoMode(WWIDTH, WHEIGHT), WTITLE)
    window.framerate_limit = 60

    # Background
    bg_texture = sf.Texture.from_file("assets/images/background.png")
    background = sf.Sprite(bg_texture)

    # Ball
    b_texture = sf.Texture.from_file("assets/images/ball.png")
    ball = sf.CircleShape(35)
    ball.texture = b_texture
    ball.origin = 35, 35
    ball.position = WWIDTH / 2.0, WHEIGHT / 2.0

    speed = sf.Vector2(randint(-5, 5), randint(-5, 5)) * 50.0

    # Paddle 1
    paddle_1 = sf.RectangleShape((50, 175))
    paddle_1.origin = 25.0, 82.5
    paddle_1.position = 50, WHEIGHT / 2.0

    # Paddle 2
    paddle_2 = sf.RectangleShape((50, 175))
    paddle_2.origin = 25.0, 82.5
    paddle_2.position = WWIDTH - 50, WHEIGHT / 2.0

    # Scores
    scored = False
    p1_score, p2_score = 0, 0

    # Font
    font = sf.Font.from_file("assets/fonts/kenvector.ttf")

    # Texts
    p1_score_text = sf.Text(str(p1_score))
    p1_score_text.font = font
    p1_score_text.character_size = 72
    p1_score_text.color = sf.Color.WHITE
    p1_score_text.position = 170, 100

    p2_score_text = sf.Text(str(p2_score))
    p2_score_text.font = font
    p2_score_text.character_size = 72
    p2_score_text.color = sf.Color.WHITE
    p2_score_text.position = 570, 100

    # Sound
    s_buffer = sf.SoundBuffer.from_file("assets/sounds/tone1.ogg")

    sound = sf.Sound(s_buffer)

    # Clock
    clock = sf.Clock()

    while window.is_open:
        for event in window.events:
            if type(event) is sf.CloseEvent:
                window.close()
        # Close
        if sf.Keyboard.is_key_pressed(sf.Keyboard.ESCAPE):
            window.close()

        elapsed = clock.elapsed_time.seconds
        clock.restart()

        # Inputs
        if sf.Keyboard.is_key_pressed(sf.Keyboard.W):
            paddle_1.move(sf.Vector2(0, -PADDLE_SPEED))

            if paddle_1.position.y < paddle_1.origin.y:
                paddle_1.position = sf.Vector2(paddle_1.position.x,
                                               paddle_1.origin.y)

        if sf.Keyboard.is_key_pressed(sf.Keyboard.S):
            paddle_1.move(sf.Vector2(0, PADDLE_SPEED))

            if paddle_1.position.y > WHEIGHT - paddle_1.origin.y:
                paddle_1.position = sf.Vector2(paddle_1.position.x,
                                               WHEIGHT - paddle_1.origin.y)

        if sf.Keyboard.is_key_pressed(sf.Keyboard.UP):
            paddle_2.move(sf.Vector2(0, -PADDLE_SPEED))

            if paddle_2.position.y < paddle_2.origin.y:
                paddle_2.position = sf.Vector2(paddle_2.position.x,
                                               paddle_2.origin.y)

        if sf.Keyboard.is_key_pressed(sf.Keyboard.DOWN):
            paddle_2.move(sf.Vector2(0, PADDLE_SPEED))

            if paddle_2.position.y > WHEIGHT - paddle_2.origin.y:
                paddle_2.position = sf.Vector2(paddle_2.position.x,
                                               WHEIGHT - paddle_2.origin.y)

        if scored:
            speed = sf.Vector2(randint(-5, 5), randint(-5, 5)) * 50.0
            ball.position = WWIDTH / 2.0, WHEIGHT / 2.0
            paddle_1.position = 50, WHEIGHT / 2.0
            paddle_2.position = WWIDTH - 50, WHEIGHT / 2.0
            scored = False

        ball.move(speed * elapsed)

        if ball.position.x < ball.origin.x or ball.position.x > WWIDTH - ball.origin.x:
            scored = True

            if ball.position.x < ball.origin.x:
                p2_score += 1
            else:
                p1_score += 1

            p1_score_text.string = str(p1_score)
            p2_score_text.string = str(p2_score)

        if ball.position.y < ball.origin.y or ball.position.y > WHEIGHT - ball.origin.y:
            speed = sf.Vector2(speed.x, speed.y * -1.0)

        p1_col = ball.global_bounds.intersects(paddle_1.global_bounds)
        if p1_col:
            sound.play()
            if p1_col.top + p1_col.height / 2.0 > paddle_1.position.y:
                y = (-1.0, 1.0)[speed.y > 0]
            else:
                y = (1.0, -1.0)[speed.y > 0]

            x_factor = (1.0, 1.05)[-MAX_BALL_SPEED < speed.x < MAX_BALL_SPEED]

            speed = sf.Vector2(speed.x * -1.0 * x_factor, speed.y * y)

        p2_col = ball.global_bounds.intersects(paddle_2.global_bounds)
        if p2_col:
            sound.play()
            if p2_col.top + p2_col.height / 2.0 > paddle_2.position.y:
                y = (-1.0, 1.0)[speed.y > 0]
            else:
                y = (1.0, -1.0)[speed.y > 0]

            x_factor = (1.0, 1.05)[-MAX_BALL_SPEED < speed.x < MAX_BALL_SPEED]

            speed = sf.Vector2(speed.x * -1.0 * x_factor, speed.y * y)

        # Rendering
        window.clear(sf.Color.BLACK)

        window.draw(background)
        window.draw(ball)
        window.draw(paddle_1)
        window.draw(paddle_2)
        window.draw(p1_score_text)
        window.draw(p2_score_text)

        window.display()
示例#23
0
    def __init__(self):
        sf.Drawable.__init__(self)

        self.sound_rarity = 0
        self.sprite = sf.CircleShape()
示例#24
0
    def __init__(self):
        self.window = sf.RenderWindow(sf.VideoMode(WIDTH, HEIGHT), TITLE)

        self.circle = sf.CircleShape(50)
        self.circle.origin = self.circle.radius, self.circle.radius
示例#25
0
# -*- coding:utf-8 -*-
import sfml as sf

WIDTH = 800
HEIGHT = 480
TITLE = "Cindiii"

window = sf.RenderWindow(sf.VideoMode(WIDTH, HEIGHT), TITLE)
alpha = 255
circle = sf.CircleShape(50)
circle.origin = circle.radius, circle.radius
circle.fill_color = sf.Color(18, 74, 34, alpha)

rectangle = sf.RectangleShape((50, 50))
rectangle.fill_color = sf.Color.BLUE
rectangle.origin = rectangle.size.x / 2, rectangle.size.y / 2
rectangle.position = 200, 200
while window.is_open:
    for event in window.events:
        if type(event) is sf.CloseEvent:
            window.close()
        if type(event) is sf.MouseWheelEvent:
            alpha += event.delta
            if not 0 <= alpha <= 255:
                print "Al kırdın kırdııın!"
                alpha = 0
            circle.fill_color = sf.Color(18, 74, 34, alpha)
        if type(event) is sf.KeyEvent:
            if event.released and event.code is sf.Keyboard.ESCAPE:
                window.close()
    circle.position = sf.Mouse.get_position(window)
line = create_line()

while window.is_open:
    for event in window.events:
        if type(event) is sf.CloseEvent:
            window.close()
        if type(event) is sf.MouseButtonEvent and event.released:
            x, y = event.position
            y = 600 - y
            pos = pymunk.Vec2d(x, y)
            circles.append(create_circle(pos))

    window.clear()

    for c in circles:
        c_draw = sf.CircleShape(c.radius)
        x, y = c.body.position
        y = 600 - y
        c_draw.position = sf.Vector2(x, y)
        window.draw(c_draw)

    line_draw = sf.RectangleShape((640, 15))
    x, y = line.body.position
    y = y - 200
    line_draw.position = x, y
    line_draw.rotation = line.body.angle
    window.draw(line_draw)

    window.display()
    space.step(1 / 60.0)