"""The Pong Game."""
import sys
import sdl2
import sdl2.ext

BLACK = sdl2.ext.Color(0, 0, 0)
WHITE = sdl2.ext.Color(255, 255, 255)
PADDLE_SPEED = 3
BALL_SPEED = 3


def run():
    sdl2.ext.init()
    window = sdl2.ext.Window("The Pong Game", size=(800, 600))
    window.show()

    if "-hardware" in sys.argv:
        print("Using hardware acceleration")
        renderer = sdl2.ext.Renderer(window)
        factory = sdl2.ext.SpriteFactory(sdl2.ext.TEXTURE, renderer=renderer)
    else:
        print("Using software rendering")
        factory = sdl2.ext.SpriteFactory(sdl2.ext.SOFTWARE)
    #sprite1=sdl2.ext.load_image("o.png")
    #sprite=sdl2.ext.Sprite(sprite1,22,33,(34,444),33)
    #sprite.positon=220,203

    # Create the paddles - we want white ones. To keep it easy enough for us,
    # we create a set of surfaces that can be used for Texture- and
    # Software-based sprites.

    sprite =factory.from_image("o.png")
            
    running = True
    while running:
        for event in sdl2.ext.get_events():
            if event.type == sdl2.SDL_QUIT:
                running = False
                break
            if event.type == sdl2.SDL_KEYDOWN:
                if event.key.keysym.sym == sdl2.SDLK_UP:
                    sprite.position=100,100
                elif event.key.keysym.sym == sdl2.SDLK_DOWN:
                    sprite.position=(10,202)
            elif event.type == sdl2.SDL_KEYUP:
                if event.key.keysym.sym in (sdl2.SDLK_UP, sdl2.SDLK_DOWN):
                    sprite.position=10,20

            spriterenderer = factory.create_sprite_render_system(window)
            spriterenderer.render(sprite)

            
            print("hello")
            print(sprite.position)
           # sss = sdl2.surface.SDL_BlitSurface(sprite)
        sdl2.SDL_Delay(10)



if __name__ == "__main__":
    sys.exit(run())
