I'm trying to build a menu screen where the camera reacts to the mouse slightly, moving a little bit in the direction of the camera. Here's what I have so far, but I can't find anything on how to move the camera.
import pygame
import button
import game
#create display window
SCREEN_HEIGHT = 720
SCREEN_WIDTH = 1280
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption('Menu')
#load button images
start_img = pygame.image.load('start_btn.bmp').convert_alpha()
exit_img = pygame.image.load('exit_btn.bmp').convert_alpha()
#create button instances
start_button = button.Button(600, 360, start_img, 0.5)
exit_button = button.Button(600, 500, exit_img, 0.6)
game = game()
#game loop
run = True
while run:
screen.fill((255, 242, 203))
if start_button.draw(screen):
print('START')
if exit_button.draw(screen):
print('EXIT')
#event handler
for event in pygame.event.get():
#quit game
if event.type == pygame.QUIT:
run = False
if event.type == pygame.MOUSEMOTION:
if game.state == "menu":
position = pygame.mouse.get_pos()
#move camera slightly in the direction of the mouse
pygame.display.update()
pygame.quit()