本文整理汇总了Python中pygame.event.post函数的典型用法代码示例。如果您正苦于以下问题:Python post函数的具体用法?Python post怎么用?Python post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get
def get(self):
events.pump()
notmine = []
inp = NOOP
for event in events.get():
if event.type == QUIT:
inp = QUITCOMMAND
if ((event.type == KEYDOWN or event.type == KEYUP)
and self.keyDict.has_key(event.key)):
if event.type == KEYDOWN:
inp = self.keyDict[event.key]
elif event.type == KEYUP:
keyDown = key.get_pressed()
if(keyDown[self.commandDict[UP]]):
inp = UP
elif(keyDown[self.commandDict[DOWN]]):
inp = DOWN
elif(keyDown[self.commandDict[LEFT]]):
inp = LEFT
elif(keyDown[self.commandDict[RIGHT]]):
inp = RIGHT
else:
inp = STOP
else:
raise UnexpectedInput
else:
notmine.append(event)
for yours in notmine:
events.post(yours)
return inp
开发者ID:bry,项目名称:pybomber2,代码行数:32,代码来源:inputdevice.py
示例2: exchangeInput
def exchangeInput(self):
"""Exchange a round of inputs in a network-safe
manner.
"""
inputs = []
for player in self.playerList:
inp = self.getPlayerInput(player)
debug("Player " + str(player.name) +\
" input: " + inp + "\n")
if self.record and inp != NOOP:
self.playerInputFileList[int(player.name)].write( \
str(self.totalGameLoops) +\
',' + inp + '\n')
# Check players input
if len(inp) != len(UP):
print "Bad input from player",player.getHandle()
inp = DISCONNECT
# Can quit the game from end splash screen
if inp == QUITCOMMAND:
sys.exit()
inputs.append((player.name,inp))
for netplayer in self.playerList:
netplayer.sendCommand(player.getBroadcastable())
self.totalGameLoops += 1
# Clear all useless events
eventsWeWant = events.get([KEYDOWN, KEYUP, JOYBUTTONDOWN,\
JOYAXISMOTION])
events.clear()
for event in eventsWeWant:
events.post(event)
return inputs
开发者ID:bry,项目名称:pybomber2,代码行数:35,代码来源:game.py
示例3: _end
def _end(self):
"""
Reset the timer and post self.event to the queue. Called when time reaches
self._endTime.
"""
self.reset()
pgevent.post(pgevent.Event(self.event))
开发者ID:adambeagle,项目名称:JeoparPy,代码行数:7,代码来源:util.py
示例4: check_died
def check_died(self, scene):
"""
Check whether this enemy has died.
"""
if self.hp <= 0:
scene.enemyGroup.remove(self)
event.post(event.Event(USEREVENT, code=CAESARDEAD))
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:7,代码来源:Caesar.py
示例5: unlaunch
def unlaunch(self, what):
ev = event.Event(constants.THORPY_EVENT, id=constants.EVENT_UNLAUNCH,
launcher=self, what=what)
event.post(ev)
## print(ev, "posted")
self.remove_from_current_menu()
self.postlaunch()
开发者ID:YannThorimbert,项目名称:Thorpy-1.5.2a,代码行数:7,代码来源:launcher.py
示例6: _press
def _press(self):
state_ok = self.current_state == self._states[STATE_NORMAL]
if state_ok:
self.change_state(STATE_PRESSED)
self._hover()
ev_press = Event(THORPY_EVENT, id=EVENT_PRESS, el=self)
post(ev_press)
self._remove_help()
开发者ID:YannThorimbert,项目名称:Thorpy-1.5.2a,代码行数:8,代码来源:clickable.py
示例7: _reaction_drag
def _reaction_drag(self, event):
if self.current_state_key == constants.STATE_PRESSED:
if self.will_be_inside(event.rel[0]):
self.dragmove(event.rel[0])
drag_event = pygevent.Event(constants.THORPY_EVENT,
id=constants.EVENT_SLIDE,
el=self.father.father)
pygevent.post(drag_event)
开发者ID:YannThorimbert,项目名称:ThorPy-1.4.2,代码行数:8,代码来源:_dragger.py
示例8: _press
def _press(self):
Clickable._press(self)
self._count += 1
if not self.toggled:
ev_tog = Event(constants.THORPY_EVENT, id=constants.EVENT_TOGGLE,
el=self)
post(ev_tog)
self.toggled = True
开发者ID:YannThorimbert,项目名称:Thorpy-1.5.2a,代码行数:8,代码来源:togglable.py
示例9: _force_unpress
def _force_unpress(self):
self._count = 0
Clickable._unpress(self)
## self._unhover_noblit()
ev_untog = Event(constants.THORPY_EVENT,
id=constants.EVENT_UNTOGGLE, el=self)
post(ev_untog)
self.toggled = False
开发者ID:YannThorimbert,项目名称:Thorpy-1.5.2a,代码行数:8,代码来源:togglable.py
示例10: _unpress
def _unpress(self):
state_ok = (self.current_state_key == constants.STATE_PRESSED)
if state_ok:
self.unblit()
self.change_state(constants.STATE_NORMAL)
self.blit()
self.update()
ev_unpress = Event(constants.THORPY_EVENT, id=constants.EVENT_UNPRESS, el=self)
post(ev_unpress)
开发者ID:YannThorimbert,项目名称:Thorpy-1.5.2a,代码行数:9,代码来源:pressable.py
示例11: _press
def _press(self):
self.unblit()
self.change_state(constants.STATE_PRESSED)
self.blit()
self.update()
ev_press = Event(constants.THORPY_EVENT,
id=constants.EVENT_PRESS,
el=self)
post(ev_press)
开发者ID:YannThorimbert,项目名称:ThorPy-1.4.1,代码行数:9,代码来源:pressable.py
示例12: _press
def _press(self):
state_ok = self.current_state == self._states[constants.STATE_NORMAL]
if state_ok:
self.unblit()
self.change_state(constants.STATE_PRESSED)
self.blit()
self.update()
ev_press = Event(constants.THORPY_EVENT,
id=constants.EVENT_PRESS,
el=self)
post(ev_press)
开发者ID:YannThorimbert,项目名称:Thorpy-1.5.2a,代码行数:11,代码来源:pressable.py
示例13: quit_save
def quit_save(self):
ev = Event(constants.THORPY_EVENT,
name=constants.EVENT_DONE,
el=self)
post(ev)
for (varset, varname), handler in iter(self.handlers.items()):
# si varset
self.varsets[varset].set_value(varname, handler.get_value())
# sinon si link
# sinon si fonction
functions.quit_menu_func()
开发者ID:YannThorimbert,项目名称:ThorPy-1.0,代码行数:11,代码来源:paramsetter.py
示例14: shutdown_gate
def shutdown_gate(self):
if self.gate_active:
print "Shutting gate down"
self.gate_active = False
self.dialed_symbols = []
event.post(Event(EventType.SOUND_STOP, {
"value": "gate-loop"
}))
event.post(Event(EventType.SOUND_PLAY, {
"value": "gate-close"
}))
开发者ID:HAZARDU5,项目名称:sgdialer,代码行数:12,代码来源:DialerController.py
示例15: __init__
def __init__(self, tube, is_initiator, tube_id):
super(PygameTube, self).__init__(tube, DBUS_PATH)
log.info( 'PygameTube init' )
self.tube = tube
self.is_initiator = is_initiator
self.entered = False
self.ordered_bus_names = []
PEvent.post(PEvent.Event(CONNECT, id=tube_id))
if not self.is_initiator:
self.tube.add_signal_receiver(self.new_participant_cb, 'NewParticipants', DBUS_IFACE, path=DBUS_PATH)
self.tube.watch_participants(self.participant_change_cb)
self.tube.add_signal_receiver(self.broadcast_cb, 'Broadcast', DBUS_IFACE, path=DBUS_PATH, sender_keyword='sender')
开发者ID:rparrapy,项目名称:maze,代码行数:13,代码来源:mesh.py
示例16: test_get
def test_get(self):
# __doc__ (as of 2008-08-02) for pygame.fastevent.get:
# pygame.fastevent.get() -> list of Events
# get all events from the queue
for _ in range(1, 11):
event.post(event.Event(pygame.USEREVENT))
self.assertEquals (
[e.type for e in fastevent.get()], [pygame.USEREVENT] * 10,
race_condition_notification
)
开发者ID:AjithPanneerselvam,项目名称:Gamepy,代码行数:13,代码来源:fastevent_test.py
示例17: test_wait
def test_wait(self):
# __doc__ (as of 2008-08-02) for pygame.fastevent.wait:
# pygame.fastevent.wait() -> Event
# wait for an event
#
# Returns the current event on the queue. If there are no messages
# waiting on the queue, this will not return until one is
# available. Sometimes it is important to use this wait to get
# events from the queue, it will allow your application to idle
# when the user isn't doing anything with it.
event.post(pygame.event.Event(1))
self.assertEquals(fastevent.wait().type, 1, race_condition_notification)
开发者ID:AjithPanneerselvam,项目名称:Gamepy,代码行数:15,代码来源:fastevent_test.py
示例18: exit
def exit(self):
key_set_repeat(parameters.KEY_DELAY, parameters.KEY_INTERVAL)
if self._activated:
functions.debug_msg("Leaving inserter ", self)
self._inserted = self._value
self._urbu()
mouse_set_visible(True)
self.cursor.exit()
self._activated = False
event_quit = event.Event(constants.THORPY_EVENT,
id=constants.EVENT_INSERT,
el=self,
value=self._value)
event.post(event_quit)
if self._varlink_func:
self._varlink_func(self._value)
开发者ID:YannThorimbert,项目名称:ThorPy-1.4.1,代码行数:16,代码来源:inserter.py
示例19: _endmusic_callback
def _endmusic_callback():
global _current_music, _queue_music, _music_pos, _music_pos_time
if _endmusic_event is not None and sdl.SDL_WasInit(sdl.SDL_INIT_AUDIO):
event.post(event.Event(_endmusic_event))
if _queue_music:
if _current_music:
sdl.Mix_FreeMusic(_current_music)
_current_music = _queue_music
_queue_music = None
sdl.Mix_HookMusicFinished(_endmusic_callback)
_music_pos = 0
sdl.Mix_PlayMusic(_current_music, 0)
else:
_music_pos_time = -1
sdl.Mix_SetPostMix(ffi.NULL, ffi.NULL)
开发者ID:GertBurger,项目名称:pygame_cffi,代码行数:16,代码来源:mixer_music.py
示例20: _ddlf_reaction_press
def _ddlf_reaction_press(self, event):
x, y = self._get_dirviewer_coords(event.pos)
lift = False
if self._lift:
lift = self._lift.collide(event.pos)
if x < self._dv.size[0] and not lift:
self._clicked = self._dv.get_txt_at_pix(x, y)
if self._clicked:
if self._menu:
self._menu.set_leave()
else:
event_ddl = pygevent.Event(constants.THORPY_EVENT,
id=constants.EVENT_DDL,
el=self,
value=self._clicked)
pygevent.post(event_ddl)
return self._clicked
开发者ID:YannThorimbert,项目名称:Thorpy-1.5.2a,代码行数:17,代码来源:ddlf.py
注:本文中的pygame.event.post函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论