Esempio n. 1
0
ball = Sprite(a0, y=HEIGHT / 2, x=WIDTH / 2, autocrop=True)

padl = Sprite(a1, y=HEIGHT / 2, x=48)
padr = Sprite(a1, y=HEIGHT / 2, x=WIDTH - 48)

field = Sprite(a2, y=HEIGHT / 2, x=WIDTH / 2)

sound = pyglet.media.load('sounds/pong-blip.wav', streaming=False)

pyglet.font.add_file('fonts/PetMe64.ttf')

scorel = Label('0',
               font_name='Pet Me 64',
               font_size=42,
               color=foreground,
               x=64,
               y=HEIGHT / 2,
               anchor_y='center',
               anchor_x='left')

scorer = Label('0',
               font_name='Pet Me 64',
               font_size=42,
               color=foreground,
               x=WIDTH - 64,
               y=HEIGHT / 2,
               anchor_y='center',
               anchor_x='right')


@app.event
Esempio n. 2
0
        vec3 col_rgb = bB;

        col_rgb = col_rgb*exp2(3.5);

        fragColor = vec4(pow(col_rgb, vec3(1./2.2)), 1.);
    } 

""", 512, 256, 0, 420, 0, 'left', 'top')

st1.set_channel(0, ba1)
st1.set_channel(1, bb1)

keyboard_layout = Sprite('images/keyboard.png', x=256, y=82, scale=0.5)
label0 = Label('amp: %.2f' % get_master_volume(),
               anchor_x='right',
               x=app.width - 10,
               y=174)
label1 = Label('use ↑ ↓ to control volume', x=10, y=194)
label2 = Label('tap SPACE to change shader', x=10, y=174)

state = State(
    up=False,
    down=False,
    shader=0,
)

keys = app.window.keys

keyboard = {
    keys.Z: note.C,
    keys.S: note.Cs,
Esempio n. 3
0
a1 = np.ones((128, 16)) * 255
a2 = np.ones((app.height * 9 // 10, app.width * 9 // 10, 3)) * 255

ball = Sprite(a0, y=app.height / 2, x=app.width / 2)

padl = Sprite(a1, y=app.height / 2, x=48)
padr = Sprite(a1, y=app.height / 2, x=app.width - 48)

field = Sprite(a2, y=app.height / 2, x=app.width / 2, color=background)

pong_sound = Sample('sounds/pong-blip.wav', amp=0.2).load()

scorel = Label('0',
               font_size=42,
               color=foreground,
               x=64,
               y=app.height / 2,
               anchor_y='center',
               anchor_x='left',
               font_path='fonts/PetMe64.ttf')

scorer = Label('0',
               font_size=42,
               color=foreground,
               x=app.width - 64,
               y=app.height / 2,
               anchor_y='center',
               anchor_x='right',
               font_path='fonts/PetMe64.ttf')


@app.event
Esempio n. 4
0
        state.lv.x -= linear_acceleration * sign

    state.lv = glm.clamp(state.lv, -64, 64)
    state.av = glm.clamp(state.av, -64, 64)

    obj.move_local(dt * state.lv)

    obj.rotate_local(dt * state.av.x, (1, 0, 0))
    obj.rotate_local(dt * state.av.y, (0, 1, 0))
    obj.rotate_local(dt * state.av.z, (0, 0, 1))

    state.lv *= 0.67**dt
    state.av *= 0.67**dt


label0 = Label('Hello World!', color='white', font_size=12, x=10, y=74)
label1 = Label('Hello World!', color='white', font_size=12, x=10, y=52)
label2 = Label('Hello World!', color='white', font_size=12, x=10, y=30)
label3 = Label('Hello World!', color='white', font_size=12, x=10, y=8)

hello_world = Label('Hello World 3D!', color='cyan', font_size=16, x=600, y=10)

dtl = [0]


@app.event
def on_draw():

    app.window.clear()
    app.set3d()
Esempio n. 5
0
logger = logging.getLogger()

app = App()

stars = Sprite('images/stars.png', scale=2.5)
alien = Sprite('images/alien.png', scale=0.5)
ship = Sprite('images/ship1.png', x=app.width / 2, y=app.height / 2, scale=0.5)
moon = Sprite('images/moon.png',
              x=app.width - 70,
              y=app.height - 70,
              scale=0.5)

circle = Sprite('images/yellow-circle.png', width=184)
circle.opacity = 0.

label = Label('hello, world', color='cyan', font_size=32, x=10, y=10)


@app.event
def mouse_position_event(x, y, dx, dy):
    logger.info('Enter mouse_position_event(%r, %r, %r, %r).', x, y, dx, dy)

    alien.x = x
    alien.y = y

    circle.x = x
    circle.y = y


vx = 0
vy = 0
Esempio n. 6
0
window = app.window

WIDTH = app.width
HEIGHT = app.height

stars = Sprite('stars.png', scale=2.5)
alien = Sprite('alien.png', scale=0.5)
ship = Sprite('ship1.png', x=WIDTH/2, y=HEIGHT/2, scale=0.5)
moon = Sprite('moon.png', x=WIDTH-70, y=HEIGHT-70, scale=0.5)

circle = Sprite('yellow-circle.png')
circle.opacity = 0
circle.width = 184

label = Label('Hello World!', color='cyan', font_size=16, x=10, y=10)


@app.event
def on_draw():
    
    window.clear()
    
    stars.draw()
    moon.draw()
    
    label.draw()

    circle.draw()
    alien.draw()
    ship.draw()
Esempio n. 7
0
            a*=a*a; // add contrast
            if (r>6) fade*=1.-dm; // dark matter, don't render near
            //v+=vec3(dm,dm*.5,0.);
            v+=fade;
            v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; // coloring based on distance
            fade*=distfading; // distance fading
            s+=stepsize;
        }
        v=mix(vec3(length(v)),v,saturation); //color adjust
        fragColor = vec4(v*.01,1.);	

    }
    
""", 533, 300)  #, -1066, -600)#, 0, 'center', 'center')

l0 = Label('Star Nest by Pablo Roman Andrioli', x=10, y=10, color='cyan')


@app.event
def render(ct, dt):

    st.render(ct, dt)
    l0.render()


sample = Sample('../docs/_static/audio/tb303.5.ogg', loop=True, amp=8.)
sample.play()

if __name__ == '__main__':
    app.run()
Esempio n. 8
0
keyboard_layout = Sprite('images/keyboard.png', x=256, y=82, scale=0.5)


state = State(
    
    amp = 1.,
    ms = 50.,
    
    up = False,
    down = False,
    left = False,
    right = False,
)

label0 = Label('amp: %.1f' % state.amp, x=10, y=194)
label1 = Label('span: %.1f ms' % state.ms, x=10, y=174)
label2 = Label('use ← → ↑ ↓ to modify', anchor_x='right', x=app.width - 10, y=174)


keys = app.window.keys

keyboard = {

    keys.Z: note.C,
    keys.S: note.Cs,
    keys.X: note.D,
    keys.D: note.Ds,
    keys.C: note.E,
    keys.V: note.F,
    keys.G: note.Fs,
Esempio n. 9
0
        state.lv.x -= linear_acceleration * sign
        
    state.lv = glm.clamp(state.lv, -64, 64)
    state.av = glm.clamp(state.av, -64, 64)
    
    obj.move_local(dt * state.lv)
    
    obj.rotate_local(dt * state.av.x, (1, 0, 0))
    obj.rotate_local(dt * state.av.y, (0, 1, 0))
    obj.rotate_local(dt * state.av.z, (0, 0, 1))
    
    state.lv *= 0.67 ** dt
    state.av *= 0.67 ** dt


label0 = Label('Hello World!', color='white', font_size=14, x=10, y=74)
label1 = Label('Hello World!', color='white', font_size=14, x=10, y=52)
label2 = Label('Hello World!', color='white', font_size=14, x=10, y=30)
label3 = Label('Hello World!', color='white', font_size=14, x=10, y=8)

hello_world = Label('hello, world 3D!', color='cyan', font_size=24, x=575, y=10)


@app.event
def render(ct, dt):
        
    app.window.clear(blue=0.3)
    
    scene.draw()
    
    label0.text = 'time to draw - %0.3f ms' % (1000 * app._time2draw_rm)