Esempio n. 1
0
def on_draw():
    window.clear()
    pyglet.gl.glColor4f(1.0, 0.0, 1.0, 1.0)
    points = []
    generate_branch(window.width/2, root.y, pi/2, root.length*root.percent, root.percent,
                root.start_angle, root.num_children, root.offset_angle, root.levels, points)
    pyglet.graphics.draw(len(points)//2, pyglet.gl.GL_LINES, ('v2f', points))
Esempio n. 2
0
def on_draw():
    window.clear()
    w, sx = _dim(window.width, window.height)
    h, sy = _dim(window.height, window.width)
    for i, color in enumerate(_strip):
        y, x = divmod(i, 3)
        px = sx+(2-x)*w
        py = sy+(2-y)*h

        gl.glColor3f(*((c/255)**0.5 for c in color))
        draw_rect(px, py, w-1, h-1)

        if sum(color) > 255:
            textcolor = (0, 0, 0, 100)
        else:
            textcolor = (255, 255, 255, 100)
        pyglet.text.Label(str(i), color=textcolor, x=px, y=py+1).draw()

    def _draw_button(x, y, r, pin):
        with pushed_matrix():
            gl.glTranslatef(x, y, 0)
            gl.glRotatef(45 + r, 0, 0, 1)
            if pin in _pressed_button_pins:
                gl.glColor3f(0.5, 0.7, 0.6)
            else:
                gl.glColor3f(0.1, 0.1, 0.1)
            draw_rect(1, 1, w/2, w/2)

    for i, pin in enumerate([12, 13, 14, 4]):
        _draw_button(sx-w, sy+h*1.5, -i*90, pin)
    for i, pin in enumerate([0, 2]):
        _draw_button(sx+w*3.5, sy+h*1.6, (i+2)*90, pin)
Esempio n. 3
0
        def on_draw():
            window.clear()
            self.background_sprite.draw()
            self.user.load_tank(window, self.bullet, self.enemy, self.user_health, self.score, self.level)
            self.bullet.load_bullet(window, self.user, self.enemy, self.leaderboard, self.user_health, self.score,
                                    self.level)
            self.enemy.load_enemy(window, self.user, self.bullet, self.user_health, self.score, self.level)
            self.walls.load_wall(window, self.user, self.bullet, self.enemy, self.user_health, self.score, self.level)

            health1 = pyglet.text.Label("Health:", font_name="Ariel", font_size=30, x=80, y=670, anchor_x="center",
                                        anchor_y="center")
            health2 = pyglet.text.Label(str(self.user_health), font_name="Ariel", font_size=30, x=180, y=670,
                                        anchor_x="center", anchor_y="center")
            score1 = pyglet.text.Label("Score:", font_name="Ariel", font_size=30, x=80, y=600, anchor_x="center",
                                       anchor_y="center")
            score2 = pyglet.text.Label(str(self.score), font_name="Ariel", font_size=30, x=180, y=600,
                                       anchor_x="center", anchor_y="center")
            level1 = pyglet.text.Label("Level:", font_name="Ariel", font_size=30, x=80, y=530, anchor_x="center",
                                       anchor_y="center")
            level2 = pyglet.text.Label(str(self.level), font_name="Ariel", font_size=30, x=180, y=530,
                                       anchor_x="center", anchor_y="center")
            health1.draw()
            health2.draw()
            score1.draw()
            score2.draw()
            level1.draw()
            level2.draw()
Esempio n. 4
0
def on_draw():
        window.clear()
        img1.blit(225,500)
        img2.blit(315,470)
        img3.blit(350,350)
        img4.blit(370,250)
        img5.blit(380,150)
        img6.blit(25,200)
def update(ad):
    # Clear Window
    window.clear()

    ball.update_position(ball.x + 1)

    # Draw Other Object
    ball.draw()
Esempio n. 6
0
def on_draw():
    window.clear()
    background.blit(0, 0)
    level_label.draw()
    label_game.draw()
    score_label.draw()
    for bee in bees:
        bee.draw()
Esempio n. 7
0
 def on_mouse_press(x, y, button, modifiers):
     for sprite in sprites:
         sprite_x, sprite_y = sprite.position
         if (sprite_x < x < sprite_x + sprite.width
             and sprite_y < y < sprite_y + sprite.height):
             if sprite.visible:
                 sprite.visible = False
             else:
                 sprite.visible = True
             break
     window.clear()
     batch.draw()
Esempio n. 8
0
 def on_mouse_press(x, y, button, modifiers):
     for sprite in sprites:
         sprite_x, sprite_y = sprite.position
         if (sprite_x < x < sprite_x + sprite.width
             and sprite_y < y < sprite_y + sprite.height):
             if sprite.visible:
                 sprite.visible = False
             else:
                 sprite.visible = True
             break
     window.clear()
     batch.draw()
Esempio n. 9
0
def on_draw():
    window.clear()

    logging.info("on_draw: %s" % str(camera))
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()

    camera.lookAt(0, 0, 0)
    camera.focus(width, height)

    drawAxes()
    drawPoints()

    return pyglet.event.EVENT_HANDLED
Esempio n. 10
0
def on_draw():
  window.clear()

  logging.info("on_draw: %s" % str(camera))
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
  glLoadIdentity()

  camera.lookAt(0, 0, 0)
  camera.focus(width, height)
  
  drawAxes()
  drawPoints()

  return pyglet.event.EVENT_HANDLED
Esempio n. 11
0
def on_draw():
    window.clear()
    label.draw()
    labe.draw()
    lab1.draw()
    lab.draw()
    lab2.draw()
    lab3.draw()
    lab4.draw()
    lab5.draw()
    lab6.draw()
    lab7.draw()
    lab8.draw()
    lab9.draw()
    labe9.draw()
    animSprite.draw()
Esempio n. 12
0
def on_draw():
    window.clear()
    image1.blit(-150, -250)
    batch.draw()
    space.debug_draw(options)
    for block in range(len(blocks)):
        block_image = pyglet.sprite.Sprite(block_surface,
                                           blocks[block].body.position.x - 40,
                                           blocks[block].body.position.y - 15)
        blocks_images.append(block_image)
        block_image.draw()
    stick_image.draw()
    ball_image.draw()
    if winnner:
        image_winner.blit(-5, -5)
        winner_label.draw()
Esempio n. 13
0
def on_draw():
    window.clear()
    draw_rectangle_background(
    )  # on the bottom, creates background for the game_label.
    classroom.blit(0, 58)
    batch_objects.draw()  # These are toys, bed, chair, table.
    create_batch_state_labels(children)  # mood, energy, hunger... At the top.
    icons = create_icons_children(
        children,
        batch_labels)  # small icons next to the state labels, at the top.
    for child in children:
        child.sprite.draw()
    game_label.draw(
    )  # It displayes main text of the game on the bottom of the page.
    batch_gl_objects.draw(
    )  # Contains rectangle, which is displayed at the beggining and at the end of the game.
    batch_labels.draw(
    )  # Contains name of the game, introduction label, icons created above.
Esempio n. 14
0
    def on_draw():
        window.clear()

        gl.glEnable(gl.GL_TEXTURE_2D)

        gl.glBindTexture(gl.GL_TEXTURE_2D, texture.id)
        gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, pic.width, pic.height,
                        0, gl.GL_BGRA, gl.GL_UNSIGNED_BYTE, data)

        gl.glBegin(gl.GL_QUADS)
        gl.glTexCoord2f(0.0, 1.0)
        gl.glVertex2i(0, 0)
        gl.glTexCoord2f(1.0, 1.0)
        gl.glVertex2i(pic.width, 0)
        gl.glTexCoord2f(1.0, 0.0)
        gl.glVertex2i(pic.width, pic.height)
        gl.glTexCoord2f(0.0, 0.0)
        gl.glVertex2i(0, pic.height)
        gl.glEnd()
Esempio n. 15
0
def on_draw():
    window.clear()
    # Draw texture backed by ImageSurface

    gl.glEnable(gl.GL_TEXTURE_2D)

    gl.glBindTexture(gl.GL_TEXTURE_2D, texture.id)
    gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, width, height, 0,
                    gl.GL_BGRA, gl.GL_UNSIGNED_BYTE, surface_data)

    gl.glBegin(gl.GL_QUADS)
    gl.glTexCoord2f(0.0, 1.0)
    gl.glVertex2i(0, 0)
    gl.glTexCoord2f(1.0, 1.0)
    gl.glVertex2i(width, 0)
    gl.glTexCoord2f(1.0, 0.0)
    gl.glVertex2i(width, height)
    gl.glTexCoord2f(0.0, 0.0)
    gl.glVertex2i(0, height)
    gl.glEnd()
Esempio n. 16
0
def on_draw():
    window.clear()

    gl.glEnable(gl.GL_TEXTURE_2D)

    gl.glBindTexture(gl.GL_TEXTURE_2D, texture.id)
    gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, WIDTH, HEIGHT, 0,
                    gl.GL_BGRA, gl.GL_UNSIGNED_BYTE, data)

    gl.glBegin(gl.GL_QUADS)
    gl.glTexCoord2f(0.0, 1.0)
    gl.glVertex2i(0, 0)
    gl.glTexCoord2f(1.0, 1.0)
    gl.glVertex2i(WIDTH, 0)
    gl.glTexCoord2f(1.0, 0.0)
    gl.glVertex2i(WIDTH, HEIGHT)
    gl.glTexCoord2f(0.0, 0.0)
    gl.glVertex2i(0, HEIGHT)
    gl.glEnd()

    text.draw()
Esempio n. 17
0
 def on_draw():
     '''The draw command is one glDraw command after gathering all of the 
     vertex information from the simulation. The draw loop first draws the 
     lines in simulation coordinates which is then "scaled" up using 
     glMatrixmode.'''
     window.clear()
     vertices = []
     colors = []
     for p in liquid.particles:
         vertices.extend([p.x, p.y, p.x - p.u, p.y - p.v])
         colors.extend(p.color)
         colors.extend([0, 0, 0])
     graphics.draw(
         len(liquid.particles)*2,
         gl.GL_LINES,
         ('v2f', vertices),
         ('c3B', colors)
     )
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glLoadIdentity()
     gl.glOrtho(0, liquid.width, liquid.height, 0, -1, 1)
     gl.glMatrixMode(gl.GL_MODELVIEW)
Esempio n. 18
0
 def on_draw(self, window):
     window.clear()
     window.background_image.blit(0,0)
Esempio n. 19
0
 def on_draw():
     window.clear()
     batch.draw()
Esempio n. 20
0
 def on_draw():
     window.clear()
     label.draw()
Esempio n. 21
0
 def on_draw():
     window.clear()
     batch.draw()
Esempio n. 22
0
def on_draw():
  window.clear()
  label.draw()
  if len(argv) > 2:
    label2.draw()
Esempio n. 23
0
def on_draw():
    window.clear()
    director.on_draw()
Esempio n. 24
0
def on_mouse_press(x, y, button, modifiers):
    window.clear()
    Iml.blit(x, y)
Esempio n. 25
0
        state = get_next_state(state)
        last_update = time.time()
    return (state, last_update, update_period)

@window.event
def on_key_press(symbol, modifiers):
    global speed_IO, pause_IO
    if symbol == key.SPACE:
        pause_IO = 1 - pause_IO
    elif symbol == key.MINUS:
        speed_IO = speed_IO / SPEED_MODIFIER_STEP
    elif symbol == key.EQUAL:
        speed_IO = speed_IO * SPEED_MODIFIER_STEP

@window.event
def on_mouse_press(x, y, button, modifiers):
    global point_buffer_IO
    if button == mouse.LEFT:
        point_buffer_IO.append([x, y])

while not window.has_exit:
    dt = clock.tick()
    (state, last_update, update_period) = updateIO(state, last_update, update_period)

    window.dispatch_events()
    window.clear()
    draw(state)
    window.flip()


Esempio n. 26
0
def on_draw():
    window.clear()
    glBegin(GL_POINTS)
    for i in range(0, len(xi)):
        glVertex2f(xi[i], yi[i])
    glEnd()
Esempio n. 27
0
 def on_draw():
     beenoir.create_waiting_players()
     window.clear()
     batch.draw()
def on_draw():
    window.clear()
    animSprite.draw()
Esempio n. 29
0
def on_draw():
    window.clear()
    batch.draw()
    counter.draw()