Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/levelfive.py
blob: 82f6cca6ced2df0b876a6a0516af30bb88d0e11f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import random, os.path
import util

import pygame
import pygame.font
from pygame.locals import *

#THE GRAPHICS ON THIS LEVEL ARE SO UGLY. FIX THEM.
#intro sucks too, players should have the numbers beforehand
#at least the concept is good =(

#level concept: player has a scrap of paper with numbers on it.
#               these numbers correspond to the answer of math problems
#               that show the correct door among several choices, leading the
#               way through a maze in the cellar

# current state: backend for creating problems is in, and displaying them
# on the piece of parchment. didnt implement the event handling code because
# that will change depending on what images i get

def run():
    #Must initialize pygame before doing anything else
    pygame.init()
    random.seed()
    
    display_flags = DOUBLEBUF
    
    #XO laptop is 1200x900 resolution
    width, height = 1200, 900

    if pygame.display.mode_ok((width, height), display_flags ):
        screen = pygame.display.set_mode((width, height), display_flags)
		  
    clock = pygame.time.Clock() 
    run = 1
    pygame.display.set_caption('OLPC Math Game')

    
    background = util.load_image('brick_wall_bg.bmp')
    door_one = util.load_image('horrid_door.bmp',1)
    numbers_list_bg = util.load_image('parchment.bmp',1)
    screen.blit(background,(0,0))
    screen.blit(door_one, (600-350/2,900-585+10))
    intro_string = "We have chased Count Mathenstein down into this cellar, and you can hear him mumbling some numbers to himself in the distance, they are probably important, lets write them down!"
    intro_two = "The numbers sound like this..."

    #remove
    dev_note = "<<DEV NOTE>> By the way, this level looks HORRIBLE and is not anything like what it will look like. I cant find graphics for the level though, so I just coded it and left the bad placeholders in for now. It is a proof of concept/backend as opposed to a full level at the moment. Ideally, players will be traveling through a maze of boxes/barrels in the cellar of a building chasing after the Count, choosing their path based on a sheet of answers to math problems that they took from the Count that tells the correct way through"
    util.ok_box(dev_note,(400,300),700,200,screen)

    screen.blit(background,(0,0))


    
    util.ok_box(intro_string, (400,300),400,80,screen)
    screen.blit(background,(0,0))
    screen.blit(door_one, (600-350/2,900-585+10))   




    draw = 1
    answers = [0,0,0,0,0,0]
    num_doors = [0,0,0,0,0,0]
    answer_spot = [0,0,0,0,0,0]
    numbers_string = ""
    answer_num =  [0,0,0,0,0,0]
    #division maze?
    for i in range(0,5):
        answers[i] = [random.randint(2,9),random.randint(5,20),random.randint(2,9),random.randint(5,20), random.randint(2,9),random.randint(5,20)]
        num_doors[i] = random.randint(2,3)
        if num_doors[i] == 2:
            answer_spot[i] = random.randint(0,1)
        else:
            answer_spot[i] = random.randint(0,2)
        answer_num[i] = answers[i][answer_spot[i]*2+1]
        numbers_string += " %s" % (answer_num[i])
    intro_two += numbers_string

 
    util.ok_box(intro_two,(500,300),200,80,screen)
    screen.blit(background,(0,0))    
    door = 0
        
    
    while run:
        events = pygame.event.get()
        for event in events: 
            #User decides to exit program
            if event.type == QUIT:              
                run = 0 #stop running
                pygame.quit()
               
        #endevents
        if draw == 1:
            font = pygame.font.Font(None, 24)
            screen.blit(background,(0,0))
            if num_doors[door] == 2:
                screen.blit(door_one,(200,100))
                text_rect = pygame.Rect((250,300),(120,50))
                door_one_text = "%i / %i = __" % (answers[door][0]*answers[door][1], answers[door][0])
                text_box = util.render_textrect(door_one_text,font,text_rect,(255,255,255),0,0)
                screen.blit(text_box,text_rect.topleft)
                
                screen.blit(door_one,(650,100))
                text_rect = pygame.Rect((700,300),(120,50))
                door_one_text = "%i / %i = __" % (answers[door][2]*answers[door][3], answers[door][2])
                text_box = util.render_textrect(door_one_text,font,text_rect,(255,255,255),0,0)
                screen.blit(text_box,text_rect.topleft)   
            if num_doors[door] == 3:
                screen.blit(door_one, (50,100))
                text_rect = pygame.Rect((100,300),(120,50))
                door_one_text = "%i / %i = __" % (answers[door][0]*answers[door][1], answers[door][0])
                text_box = util.render_textrect(door_one_text,font,text_rect,(255,255,255),0,0)
                screen.blit(text_box,text_rect.topleft)
                
                screen.blit(door_one, (450,100))
                text_rect = pygame.Rect((500,300),(120,50))
                door_one_text = "%i / %i = __" % (answers[door][2]*answers[door][3], answers[door][2])
                text_box = util.render_textrect(door_one_text,font,text_rect,(255,255,255),0,0)
                screen.blit(text_box,text_rect.topleft)
                
                screen.blit(door_one, (850,100))
                text_rect = pygame.Rect((900,300),(120,50))
                door_one_text = "%i / %i = __" % (answers[door][4]*answers[door][5], answers[door][4])
                text_box = util.render_textrect(door_one_text,font,text_rect,(255,255,255),0,0)
                screen.blit(text_box,text_rect.topleft)
            screen.blit(numbers_list_bg,(800,900-440))
            text_rect = pygame.Rect((900,900-360),(70,300))
            font = pygame.font.Font(None, 48)
            text_box = util.render_textrect(numbers_string[1:],font,text_rect,(255,0,0),0,0)
            text_box.set_colorkey(text_box.get_at((0, 0)))  
            screen.blit(text_box,text_rect.topleft)            
                        
                      
    
                
        pygame.display.flip()
        
        clock.tick(40) #limits to 40 FPS
	
    
def main():
    run()
    
#runs main if called via other naming convention
if __name__ == '__main__': main()