Pages

Saturday, March 15, 2014

simple introduction screen pygame

###  An intro screen.  Trying to make my personality test, ###
### will post it when it's ready so you can try it out! ###

import pygame
from pygame.locals import*
import math
from random import randint, choice
from math import*
from sys import exit

pygame.init()




H = 800
W = 800
screen = pygame.display.set_mode((H, W))

font = pygame.font.Font(None, 32)
L_font = pygame.font.Font(None, 64)   
clock = pygame.time.Clock()
BLUE = (45, 0, 200)
GREEN = (0, 200, 45)
PURPLE = (200, 95, 255)
BLACK = (0, 0, 0)   

def display_box():
       
    # the needed variables
    pygame.draw.rect(screen, (200, 195, 100), (20, 20, 760, 760))
    pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)
    intro = font.render("For instructions, press Space bar", False, BLUE)
    title1 = font.render("For entertainment only", False, GREEN)
    title2 = L_font.render("Personality", False, BLUE)
    title3 = L_font.render("Test", False, BLUE)
    author = font.render("Nellie Tobey, 2014", False, BLACK)
    clock.tick(30)
   
     # the first screen you want them to see. #
     # the function draws it,   the loop will change it# 
    screen.blit(intro, (40, 40))
    screen.blit(title1, (60, 60))
    screen.blit(title2, (290, 300))
    screen.blit(title3, (340, 340))
    screen.blit(author, (40, 640))
    pygame.display.flip()
   
    # these three variables will help us change the
    # state of the function
      
    done = False   
    instruction_screen = 1
    display_instructions = 1
    # main LOOP. This changes the screen as the state of function changes #
 
  while done==False:       
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True
                exit()

        if instruction_screen ==1:
            screen.blit(intro, (40, 40))
            screen.blit(title1, (60, 60))
            screen.blit(title2, (290, 300))
            screen.blit(title3, (340, 340))
            screen.blit(author, (40, 640))
            pygame.display.flip()
        keys = pygame.key.get_pressed()

           # if you push space, things change

        if (keys[K_SPACE]): 
            instruction_screen = 2  #we could create more, and more screens
            display_instructions = 0
        if display_instructions == 0:           
            text = L_font.render("INSTRUCTIONS", False, (0, 35, 0))
            pygame.draw.rect(screen, (200, 255, 255), (20, 20, 760, 760))
            screen.blit(text, (H/2 - 170, W/2 - 200))
            pygame.display.flip()
       
   
       
display_box()


def instructions():
    pass
def test():
    pass
def answers():                         #these are where my app will go. 
    pass
def questions():
    pass
def results():
    pass

No comments:

Post a Comment