python
import pygame
from pygame.locals import *
# Initialize Pygame
pygame.init()
# Set up the display window
screen_width, screen_height = 800, 600
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Character Movement")
# Load the character image
character_img = pygame.image.load("character.png") # Replace "character.png" with the actual filename of your character image
# Set the initial position of the character
character_x = 100
character_y = 100
# Set the movement speed of the character
move_speed = 5
# Game loop
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:
running = False
# Get the state of the keyboard
keys = pygame.key.get_pressed()
# Update the position of the character based on the keyboard input
if keys[K_LEFT]:
character_x -= move_speed
if keys[K_RIGHT]:
character_x += move_speed
if keys[K_UP]:
character_y -= move_speed
if keys[K_DOWN]:
character_y += move_speed
# Clear the screen
screen.fill((255, 255, 255))
# Draw the character
screen.blit(character_img, (character_x, character_y))
# Update the display
pygame.display.flip()
# Quit the game
pygame.quit()