Terminate on key release.
This commit is contained in:
		
							
								
								
									
										14
									
								
								game/game.py
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								game/game.py
									
									
									
									
									
								
							@ -154,6 +154,7 @@ def main():
 | 
				
			|||||||
    clouds_orientation = tests_batch.params[clouds_id].orientation
 | 
					    clouds_orientation = tests_batch.params[clouds_id].orientation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print("Running...")
 | 
					    print("Running...")
 | 
				
			||||||
 | 
					    events = buffer(Event, 16)
 | 
				
			||||||
    start_time = time.monotonic()
 | 
					    start_time = time.monotonic()
 | 
				
			||||||
    current_time = 0.0
 | 
					    current_time = 0.0
 | 
				
			||||||
    frame_min = 10000.0
 | 
					    frame_min = 10000.0
 | 
				
			||||||
@ -236,6 +237,19 @@ def main():
 | 
				
			|||||||
                frame_max = max(frame_max, frame_ms)
 | 
					                frame_max = max(frame_max, frame_ms)
 | 
				
			||||||
                frame_avg += frame_ms
 | 
					                frame_avg += frame_ms
 | 
				
			||||||
                perf_count += 1
 | 
					                perf_count += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            stop = False
 | 
				
			||||||
 | 
					            while True:
 | 
				
			||||||
 | 
					                nevents = consume_events(events, len(events))
 | 
				
			||||||
 | 
					                if not nevents:
 | 
				
			||||||
 | 
					                    break
 | 
				
			||||||
 | 
					                for event in events[:nevents]:
 | 
				
			||||||
 | 
					                    if event.type == EVENT_KEY_RELEASE:
 | 
				
			||||||
 | 
					                        print("EVENT_KEY_RELEASE:", event.data.key.keycode)
 | 
				
			||||||
 | 
					                        stop = True
 | 
				
			||||||
 | 
					            if stop:
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    except KeyboardInterrupt:
 | 
					    except KeyboardInterrupt:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user