Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/levelfive.py
diff options
context:
space:
mode:
Diffstat (limited to 'levelfive.py')
-rw-r--r--levelfive.py147
1 files changed, 147 insertions, 0 deletions
diff --git a/levelfive.py b/levelfive.py
new file mode 100644
index 0000000..82f6cca
--- /dev/null
+++ b/levelfive.py
@@ -0,0 +1,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()