代码如下:
import pygame, sys
from pygame.locals import *
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
WHITE = (255, 255, 255)
GRASSCOLOR = GREEN
BGCOLOR = WHITE
WINDOWWIDTH = 500
WINDOWHEIGHT = 300
def main():
pygame.init()
global DISPLAYSURF
DISPLAYSURF = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
pygame.display.set_caption('Platformer')
player = pygame.image.load('megaman_running_sprites_by_cobalt_blue_knight-d2y1i8s.png')
playerx = 140
playery = 10
DISPLAYSURF.fill(BGCOLOR)
DISPLAYSURF.blit(player, (10, 140))
while True: # Event handling loop
ground()
mousex, mousey = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type …Run Code Online (Sandbox Code Playgroud) pygame ×1