hello, I have been having a really hard time on trying to make my
character jump in this platformer, here is the code, do not mind the
"from pif import *" that is for my animation, and dont mind the "two"
function haha.
thank you very muchimport pyglet
from pyglet.window import key
from pif import *
ninja = two('ninja.move.2.png', 'ninja.move.1.png', 0.2)
ninja.still = pyglet.image.load('ninja.still.png')
ninja.y = 122
window = pyglet.window.Window(500, 500)
map = pyglet.image.load('map.png')
keymap = key.KeyStateHandler()
window.push_handlers(keymap)
ninja.still = pyglet.sprite.Sprite(ninja.still)
@window.event
def on_draw():
window.clear()
map.blit(0, 0, 0)
if not keymap[key.LEFT] and not keymap[key.RIGHT] and not
keymap[key.SPACE]:
ninja.still.set_position(ninja.x, ninja.y)
ninja.still.draw()
else:
ninja.draw()
ninja.set_position(ninja.x, ninja.y)
def update(dt):
if keymap[key.LEFT]:
ninja.x -= dt * 60
if keymap[key.SPACE] or keymap[key.UP]:
ninja.y += dt * 120
elif keymap[key.RIGHT]:
ninja.x += dt * 60
if keymap[key.SPACE] or keymap[key.UP]:
ninja.y += dt * 120
elif keymap[key.SPACE] or keymap[key.UP]:
ninja.y += dt * 120
pyglet.clock.schedule_interval(update, 1/60.)
pyglet.app.run()
Thanks!
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.