import pygame

import sys

pygame.init()

screen = pygame.display.set_mode((800, 600 ))
pygame.display.set_caption('Maze Game')                                   


clock = pygame.time.Clock()

#load all images
btn_start_img = pygame.image.load('images/start btn.png').convert_alpha()  #start button image
btn_exit_img = pygame.image.load('images/exit btn.png').convert_alpha()   #exit button image
maze1 = pygame.image.load('images/maze1.png').convert()                     #background image for L1
maze2 = pygame.image.load('images/maze2.png').convert()                     #background image for L2
maze3 = pygame.image.load('images/maze3.png').convert()                     #background image for L3
player.main(display)

#set up the window
displayWidth = 700
displayHeight = 700
pygame_pressed = 0





#button class
class Button():
  def __init__(self, x, y, image, scale):
    width = image.get_width()
    height = image.get_height()
    self.image = pygame.transform.scale(image, (int(width * scale), int(height * scale)))
    self.rect = self.image.get_rect()
    self.rect.topleft = (x, y)
    self.clicked = False
   
  def draw(self):
    action = False
    #mouse position
    pos = pygame.mouse.get_pos()
   
    #has mouse been moved over button or clicked?
    if self.rect.collidepoint(pos):
      #[0] means left mouse button!!!
      if pygame.mouse.get_pressed()[0] == 1 and self.clicked == False:
        self.clicked = True
        action = True
       
    #checking if button been clicked more than once
    if pygame_pressed()[0] == 0:
      self.clicked = False
   
    #button on screen
    screen.blit(self.image, (self.rect.x, self.rect.y))
   
    return action
 
class GameState:
    def __init__(self):
        self.state = 'intro'
       
    def intro(self):
        for event in pygame.event.get():
        #quit game
            if event.type == pygame.QUIT:
                run = False
       
        screen.fill((174, 198, 207))
        
        #make buttons
        start_button = Button(100, 200, btn_start_img, 0.5)
        exit_button = Button(450, 200, btn_exit_img, 0.5)
 
        if start_button.draw():
            self.state = "level1"
 
        if exit_button.draw():
            run = False
           
        pygame.display.update()
       
    def level1(self):
        for event in pygame.event.get():
        #quit game
          if event.type == pygame.QUIT:
            run = False
             
        screen.blit(maze1, (0, 0))
           
            #***rest of level 1 code here!!***
            
class Player: 
    def __init__(self, x, y, width, height):
      self.x = x
      self.y = y
      self.width = width 
      self.height = height 
    def main(self, display):
      pyagme.draw.rect(display, (255, 0, 0), (self.x, self.y, self.width, self.height))

player = Player(400, 300, 32, 32)

display_scroll = [0,0] 

keys = pygame.key.get_pressed()

pygame.draw.rect(display, (255,255,255), (100-display_scroll[0], 100-display_scroll[1], 16, 16))

if keys[pygame.K_a]:
	display_scroll[0] -= 5
if keys[pygame.K_d]:
	display_scroll[0] += 5
if keys[pygame.K_w]:
	display_scroll[1] -= 5
if keys[pygame.K_s]:
	display_scroll[1] += 5












player.main(display) #idk where this goes
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
class Player: 
	def __init__(self, x, y, width, height):
		self.x = x
		self.y = y
		self.width = width 
		self.height = height 
	def main(self, display):
		pyagme.draw.rect(display, (255, 0, 0), (self.x, self.y, self.width, self.height))

player = Player(400, 300, 32, 32)

display_scroll = [0,0] 

keys = pygame.key.get_pressed()

pygame.draw.rect(display, (255,255,255), (100-display_scroll[0], 100-display_scroll[1], 16, 16))

if keys[pygame.K_a]:
	display_scroll[0] -= 5
if keys[pygame.K_d]:
	display_scroll[0] += 5
if keys[pygame.K_w]:
	display_scroll[1] -= 5
if keys[pygame.K_s]:
	display_scroll[1] += 5


def state_manager(self):
  if self.state == 'intro':
    self.intro()
  if self.state == 'level1':
    self.level1()
       
       
       
game_state = GameState()



#game loop
run = True
while run:

  
  game_state.state_manager()
  clock.tick(60)    
   
pygame.quit()