Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Simple graphics demo
- Sample Python/Pygame Programs
- Simpson College Computer Science
- http://programarcadegames.com/
- http://simpson.edu/computer-science/
- """
- # Import a library of functions called 'pygame'
- import pygame
- from pygame.locals import *
- # Initialize the game engine
- pygame.init()
- # Define some colors
- BLACK = (0, 0, 0)
- WHITE = (255, 255, 255)
- BLUE = (0, 0, 255)
- GREEN = (0, 255, 0)
- RED = (255, 0, 0)
- # Set the height and width of the screen
- size = (400, 500)
- screen = pygame.display.set_mode(size)
- pygame.display.set_caption("Verkefni 5")
- # Loop until the user clicks the close button.
- done = False
- clock = pygame.time.Clock()
- snua1 = 0
- snua2 = 0
- x_hnit = 350
- y_hnit = 450
- x = 0
- y = 0
- size = 25
- att="haegri"
- staekka=True
- nytt=True
- text_rotate_degrees = 0
- # Loop as long as done == False
- while not done:
- for event in pygame.event.get(): # User did something
- if event.type == pygame.QUIT: # If user clicked close
- done = True # Flag that we are done so we exit this loop
- # All drawing code happens after the for loop and but
- # inside the main while not done loop.
- # Clear the screen and set the screen background
- screen.fill(RED)
- font = pygame.font.SysFont('Calibri', 25, True, False)
- font2 = pygame.font.SysFont('Comic Sans MS', size, True, False)
- snua1 = 0
- snua2 = 0
- # Flipped text
- text2 = font2.render("GAME OVER", True, GREEN)
- #text2 = pygame.transform.rotate(text2, text_rotate_degrees)
- #text_rotate_degrees -=1
- text_rect = text2.get_rect()
- text_x = screen.get_width() / 2 - text_rect.width / 2
- screen.blit(text2, [text_x, 230])
- # Flipped text
- text3 = font2.render(":)", True, GREEN)
- text3 = pygame.transform.rotate(text3, snua1)
- snua1 -=1
- text_rect = text3.get_rect()
- text_x = screen.get_width() / 2 - text_rect.width / 2
- screen.blit(text3, [text_x, 130])
- text4 = font2.render(":)", True, GREEN)
- text4 = pygame.transform.rotate(text4, snua2)
- snua1 +=1
- text_rect = text4.get_rect()
- text_x = screen.get_width() / 2 - text_rect.width / 2
- screen.blit(text4, [text_x, 330])
- if staekka:
- size+=1
- if size>80:
- staekka=False
- elif not staekka:
- size-=1
- if size<10:
- staekka=True
- # Sideways text
- text = font.render("Bjarni", True, BLACK)
- #text = pygame.transform.rotate(text, 90)
- if att=="haegri":
- x+=1
- text = pygame.transform.rotate(text, 0)
- elif att=="nidur":
- y+=1
- text = pygame.transform.rotate(text, 270)
- elif x==10 and att=="vinstri":
- att="upp"
- x=0
- y=430
- elif y==10 and att=="upp":
- att="haegri"
- y=0
- screen.blit(text, [x, y])
- # Go ahead and update the screen with what we've drawn.
- # This MUST happen after all the other drawing commands.
- pygame.display.flip()
- # This limits the while loop to a max of 60 times per second.
- # Leave this out and we will use all CPU we can.
- clock.tick(60)
- # Be IDLE friendly
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement