Python pygame.K_f() Examples
The following are 9
code examples of pygame.K_f().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygame
, or try the search function
.
Example #1
Source File: kernal.py From RoboMaster-AI-Challenge-Simulator-2D with MIT License | 5 votes |
def get_order(self): # get order from controler for event in pygame.event.get(): if event.type == pygame.QUIT: return True pressed = pygame.key.get_pressed() if pressed[pygame.K_1]: self.n = 0 if pressed[pygame.K_2]: self.n = 1 if pressed[pygame.K_3]: self.n = 2 if pressed[pygame.K_4]: self.n = 3 self.orders[self.n] = 0 if pressed[pygame.K_w]: self.orders[self.n, 0] += 1 if pressed[pygame.K_s]: self.orders[self.n, 0] -= 1 if pressed[pygame.K_q]: self.orders[self.n, 1] -= 1 if pressed[pygame.K_e]: self.orders[self.n, 1] += 1 if pressed[pygame.K_a]: self.orders[self.n, 2] -= 1 if pressed[pygame.K_d]: self.orders[self.n, 2] += 1 if pressed[pygame.K_b]: self.orders[self.n, 3] -= 1 if pressed[pygame.K_m]: self.orders[self.n, 3] += 1 if pressed[pygame.K_SPACE]: self.orders[self.n, 4] = 1 else: self.orders[self.n, 4] = 0 if pressed[pygame.K_f]: self.orders[self.n, 5] = 1 else: self.orders[self.n, 5] = 0 if pressed[pygame.K_r]: self.orders[self.n, 6] = 1 else: self.orders[self.n, 6] = 0 if pressed[pygame.K_n]: self.orders[self.n, 7] = 1 else: self.orders[self.n, 7] = 0 if pressed[pygame.K_TAB]: self.dev = True else: self.dev = False return False
Example #2
Source File: Base.py From three.py with MIT License | 5 votes |
def run(self): self.initialize() while self.running: # update input state (down, pressed, up) self.input.update() if self.input.quit(): self.running = False # debug tools # print FPS (Ctrl+F) if (self.input.isKeyPressed(pygame.K_LCTRL) or self.input.isKeyPressed(pygame.K_RCTRL)) and self.input.isKeyDown(pygame.K_f): fps = self.clock.get_fps() print( "FPS: " + str(int(fps)) ) # save screenshot (Ctrl+S) if (self.input.isKeyPressed(pygame.K_LCTRL) or self.input.isKeyPressed(pygame.K_RCTRL)) and self.input.isKeyDown(pygame.K_s): timeString = str( int(1000 * time.time()) ) fileName = "image-" + timeString + ".png" pygame.image.save(self.screen, fileName) self.deltaTime = self.clock.get_time() / 1000.0 self.update() # display image on screen pygame.display.flip() # limit to 60 FPS self.clock.tick(60) # end of program pygame.quit() sys.exit()
Example #3
Source File: FirstPersonController.py From three.py with MIT License | 5 votes |
def __init__(self, input, target): super().__init__() self.input = input self.target = target # forward vector stays level with horizontal plane self.forward = np.array( [0, 0, -1] ) # up vector is constant self.up = np.array( [0,1,0] ) # recalculate right vector whenever forward vector changes self.right = np.cross( self.forward, self.up ) # control rate of movement self.deltaTime = 1.0/60.0 # TODO: get actual number from input? self.unitsPerSecond = 1 self.moveAmount = self.unitsPerSecond * self.deltaTime self.degreesPerSecond = 60 self.turnAmount = self.degreesPerSecond * (3.1415926 / 180) * self.deltaTime # customizable key mappings # standard controls (WASDRF, QETG) self.KEY_MOVE_FORWARDS = pygame.K_w self.KEY_MOVE_BACKWARDS = pygame.K_s self.KEY_MOVE_LEFT = pygame.K_a self.KEY_MOVE_RIGHT = pygame.K_d self.KEY_MOVE_UP = pygame.K_r self.KEY_MOVE_DOWN = pygame.K_f self.KEY_TURN_LEFT = pygame.K_q self.KEY_TURN_RIGHT = pygame.K_e self.KEY_LOOK_UP = pygame.K_t self.KEY_LOOK_DOWN = pygame.K_g
Example #4
Source File: main.py From Hermit with MIT License | 5 votes |
def keyupdowncontrol(event): global keyseq, showconsole, fullscreen if event.type == pygame.QUIT: sys.exit() man.keyupdowncontrol(event,horse) if event.type == pygame.KEYDOWN: if showconsole: k = pygame.key.name(event.key) #print k if k == "return": exe("".join(keyseq)) showconsole = False elif k == "space": keyseq.append(" ") elif k == "-": keyseq.append("-") elif len(k) == 1: keyseq.append(k) elif event.key == pygame.K_BACKSPACE : if len(keyseq) > 0: keyseq.pop() if event.key == pygame.K_SLASH: showconsole = not showconsole if showconsole: settings.msg = ["CONSOLE READY.",settings.msgt] else: settings.msg = ["",settings.msgt] keyseq = [] if event.key == pygame.K_f and not showconsole: fullscreen = not fullscreen if fullscreen: pygame.display.set_mode([width/2,height+50],pygame.FULLSCREEN) else: pygame.display.set_mode([width/2,height+50]) pygame.display.set_caption("")
Example #5
Source File: booth.py From pibooth with MIT License | 5 votes |
def find_fullscreen_event(self, events): """Return the first found event if found in the list. """ for event in events: if event.type == pygame.KEYDOWN and \ event.key == pygame.K_f and pygame.key.get_mods() & pygame.KMOD_CTRL: return event return None
Example #6
Source File: glcube.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
def main(): "run the demo" #initialize pygame and setup an opengl display pygame.init() fullscreen = True pygame.display.set_mode((640,480), OPENGL|DOUBLEBUF|FULLSCREEN) init_gl_stuff() going = True while going: #check for quit'n events events = pygame.event.get() for event in events: if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): going = False elif event.type == KEYDOWN: if event.key == pygame.K_f: if not fullscreen: print("Changing to FULLSCREEN") pygame.display.set_mode((640, 480), OPENGL | DOUBLEBUF | FULLSCREEN) else: print("Changing to windowed mode") pygame.display.set_mode((640, 480), OPENGL | DOUBLEBUF) fullscreen = not fullscreen init_gl_stuff() #clear screen and move camera glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) #orbit camera around by 1 degree glRotatef(1, 0, 1, 0) drawcube() pygame.display.flip() pygame.time.wait(10)
Example #7
Source File: glcube.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
def main(): "run the demo" #initialize pygame and setup an opengl display pygame.init() fullscreen = True pygame.display.set_mode((640,480), OPENGL|DOUBLEBUF|FULLSCREEN) init_gl_stuff() going = True while going: #check for quit'n events events = pygame.event.get() for event in events: if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): going = False elif event.type == KEYDOWN: if event.key == pygame.K_f: if not fullscreen: print("Changing to FULLSCREEN") pygame.display.set_mode((640, 480), OPENGL | DOUBLEBUF | FULLSCREEN) else: print("Changing to windowed mode") pygame.display.set_mode((640, 480), OPENGL | DOUBLEBUF) fullscreen = not fullscreen init_gl_stuff() #clear screen and move camera glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) #orbit camera around by 1 degree glRotatef(1, 0, 1, 0) drawcube() pygame.display.flip() pygame.time.wait(10)
Example #8
Source File: glcube.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
def main(): "run the demo" #initialize pygame and setup an opengl display pygame.init() fullscreen = True pygame.display.set_mode((640,480), OPENGL|DOUBLEBUF|FULLSCREEN) init_gl_stuff() going = True while going: #check for quit'n events events = pygame.event.get() for event in events: if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): going = False elif event.type == KEYDOWN: if event.key == pygame.K_f: if not fullscreen: print("Changing to FULLSCREEN") pygame.display.set_mode((640, 480), OPENGL | DOUBLEBUF | FULLSCREEN) else: print("Changing to windowed mode") pygame.display.set_mode((640, 480), OPENGL | DOUBLEBUF) fullscreen = not fullscreen init_gl_stuff() #clear screen and move camera glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) #orbit camera around by 1 degree glRotatef(1, 0, 1, 0) drawcube() pygame.display.flip() pygame.time.wait(10)
Example #9
Source File: glcube.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
def main(): "run the demo" #initialize pygame and setup an opengl display pygame.init() fullscreen = True pygame.display.set_mode((640,480), OPENGL|DOUBLEBUF|FULLSCREEN) init_gl_stuff() going = True while going: #check for quit'n events events = pygame.event.get() for event in events: if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): going = False elif event.type == KEYDOWN: if event.key == pygame.K_f: if not fullscreen: print("Changing to FULLSCREEN") pygame.display.set_mode((640, 480), OPENGL | DOUBLEBUF | FULLSCREEN) else: print("Changing to windowed mode") pygame.display.set_mode((640, 480), OPENGL | DOUBLEBUF) fullscreen = not fullscreen init_gl_stuff() #clear screen and move camera glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) #orbit camera around by 1 degree glRotatef(1, 0, 1, 0) drawcube() pygame.display.flip() pygame.time.wait(10)