Reputation: 11
I'm testing pyglet, and it has everything(except for a good guide) but the only thing that i don't understand is: how do I move the camera to show hidden content?
Upvotes: 1
Views: 1166
Reputation: 31
For anyone who comes since the pyglet 2 update, you can now use Window.view = Window.view.from_translation(pygmath.Vec3(xpos, ypos, zpos))
.
Upvotes: 3
Reputation: 105
As stated by Rabbid76, try pyglet.gl.glTranslatef(dx,dy,dz).
The first argument in glTranslatef changes the x-direction of a supposed "camera", the second changes y, and the third changes z. Heres a quick code example that may also help:
import pyglet
from pyglet.window import key
from pyglet.gl import glTranslatef
def movement(keys):
if keys[key.I]:
glTranslatef(0,10,0)
if keys[key.K]:
glTranslatef(0,-10,0)
if keys[key.J]:
glTranslatef(-10,0,0)
if keys[key.L]:
glTranslatef(10,0,0)
def update(dt):
window.clear()
label.draw()
movement()
if __name__ == '__main__':
window = pyglet.window.Window(height=1000,width=1000)
keys = key.KeyStateHandler()
window.push_handlers(keys)
label = pyglet.text.Label('Hello, world',
font_size=36,
x=window.width//2, y=window.height//2)
pyglet.clock.schedule_interval(update,1/60)
pyglet.app.run()
In the above example, you would use the I, J, K, and L keys to move a label around your window. Hope this was helpful!
Upvotes: 1
Reputation:
Try using an offset. Fo/x, lets say x = 0, and camoffset = 5. You can render the x as x+camoffset. It works.
Upvotes: 0