当前位置: 首页>>代码示例>>Python>>正文


Python sdl2.SDLK_d方法代码示例

本文整理汇总了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() 
开发者ID:christophercrouzet,项目名称:hienoi,代码行数:18,代码来源:gui.py

示例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 
开发者ID:ruby3141,项目名称:PyTGM,代码行数:46,代码来源:ctrl.py


注:本文中的sdl2.SDLK_d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。