Keyboard Interactions

Akasei Yoshiko <[email protected]> Fri, 27 Apr 2012 14:43:25 +0200
Newsgroups gmane.comp.python.visualpython.user
Message-ID <CALtf9+ofmHQRU4c7zWh1j_hGLH8QpbzB7GhrP=di+9GdSaNLeg@mail.gmail.com>
How i can chack if key is pressed?
Or when I press arrow Left and arrow Up my "ball" move only in one
direction.


# -*- coding: UTF-8 -*-
> from visual import *
>
> scene = display( title='Przykład', x=0, y=0, width=640, height=480,
> center=( 0, 0, 0 ), background=( 0, 0, 0 ), fov=1.0 )
> ball = sphere( pos=( 0, 0, 0 ), radius=0.5 )
>
> scene.autoscale = False
> scene.range=( 10, 10, 10 )
>
> while True:
>     if scene.kb.keys:
>         key = scene.kb.getkey()
>         if key == 'right':
>             ball.pos.x += 1
>         if key == 'left':
>             ball.pos.x -= 1
>         if key == 'up':
>             ball.pos.y += 1
>         if key == 'down':
>             ball.pos.y -= 1
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
Visualpython-users mailing list
Visualpython-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/visualpython-users