本文整理汇总了Python中sdl2.SDLK_d方法的典型用法代码示例。如果您正苦于以下问题:Python sdl2.SDLK_d方法的具体用法?Python sdl2.SDLK_d怎么用?Python sdl2.SDLK_d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sdl2
的用法示例。
在下文中一共展示了sdl2.SDLK_d方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _on_key_down_event
# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDLK_d [as 别名]
def _on_key_down_event(self, event, scene_state):
"""Event 'on key down'."""
code = event.keysym.sym
modifier = event.keysym.mod
if modifier == sdl2.KMOD_NONE:
if code == sdl2.SDLK_SPACE:
self._listen_for_navigation = True
elif code == sdl2.SDLK_d:
self.particle_display = (
(self.particle_display + 1) % (ParticleDisplay._LAST + 1))
elif code == sdl2.SDLK_f:
self._fit_view(scene_state)
elif code == sdl2.SDLK_g:
self.show_grid = not self.show_grid
elif code == sdl2.SDLK_r:
self._reset_view()
示例2: run
# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDLK_d [as 别名]
def run(self):
next(self.model.tick)
self.keydict = { #key mapped here
sdl2.SDLK_a:[False,False, 0, -1], #left
sdl2.SDLK_d:[False,False, 0, 1], #right
sdl2.SDLK_w:[False,False, 1, -1], #up
sdl2.SDLK_s:[False,False, 1, 1], #down
sdl2.SDLK_l:[False,False, 2, 1], #A
sdl2.SDLK_j:[False,False, 2, -1], #B
sdl2.SDLK_i:[False,False, 3, 1]} #Hold
self.intup = [0,0,0,0] #(left/right), (up/down), (b/a), (hold)
running = True
d = sdl2.timer.SDL_GetTicks()
t = d
tick = 0
while running:
tick += 1
events = sdl2.ext.get_events()
for event in events:
if event.type == sdl2.SDL_QUIT:
running=False
break
if event.type == sdl2.SDL_KEYDOWN:
if event.key.keysym.sym in self.keydict.keys():
self.keydict[event.key.keysym.sym][0] = True
if event.type == sdl2.SDL_KEYUP:
if event.key.keysym.sym in self.keydict.keys():
self.keydict[event.key.keysym.sym][0] = False
for i, d in enumerate(self.intup):
if d != 0:
self.intup[i] += ( 1 if d > 0 else -1 )
for key in self.keydict.keys():
if self.keydict[key][0] != self.keydict[key][1]:
if self.keydict[key][0]:
self.intup[self.keydict[key][2]] = self.keydict[key][3]
elif self.intup[self.keydict[key][2]] * self.keydict[key][3] > 0:
self.intup[self.keydict[key][2]] = 0
self.keydict[key][1] = self.keydict[key][0]
self.model.tick.send(self.intup)
next(self.view.render)
next(self.audio.player)
d = sdl2.timer.SDL_GetTicks()
sdl2.timer.SDL_Delay(max((tick*1000)//self.framerate-d+t, 0))
return