From: Akasei Y. <ak...@in...> - 2012-04-27 13:11:19
|
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 > |