#! /Usr/bin/ENV python2.7 #-*-coding: UTF-8-*-# file: pg2.py # Date: 2013-6-30 # Author: wangyuimport pygamefrom pygame. locals import * From sys import exitpygame. init () screen_size = (640,480) screen = pygame. display. set_mode (screen_size, 0, 32) font = pygame. font. sysfont ("Arial", 16); # The first parameter is the font, And the last parameter is the size print fontfont_height = font. get_linesize () print font_heightevent_text = [] While true: event = pygame. event. wait () # event wait event_text.append (STR (event) # obtain the time name print event_text # test event_text = event_text [-screen_size [1]/font_height:] print event_text # This slicing operation ensures that only one screen text if event is retained in event_text. type = quit: exit () screen. fill (255,255, 0) y = screen_size [1]-font_height # find a suitable starting position and start from the bottom to retain the blank for text in reversed (event_text) Row): screen. BITs (font. render (text, true, (0, 0), (0, y) Y-= font_height # obtain the coordinates of pygame. display. update ()
These code actions are constantly updated when you move the mouse.
The two prints are the output coordinates in the command line. below is