Ejemplo n.º 1
0
class Map(object):
    scenes = {
        'phone_call': Levels.PhoneCall(),
        'date_decision': Levels.DateDecision(),
        'fancy_bar': Levels.FancyBar(),
        'weird_pub': Levels.WeirdPub(),
        'ice_skating': Levels.IceSkating(),
        'game_won': Levels.GameWon(),
        'date_transition': Levels.DateTransition(),
        'her_place': Levels.HerPlace(),
        'game_over': Levels.GameOver(),
        'game_over_dead': Levels.GameOverDead(),
    }

    def __init__(self, start_scene):
        self.start_scene = start_scene

    def next_scene(self, scene_name):
        val = Map.scenes.get(scene_name)
        return val

    def opening_scene(self):
        return self.next_scene(self.start_scene)
Ejemplo n.º 2
0
def main(screen):
    pygame.mixer.init()
    pygame.mixer.music.load(BGMPATH)
    pygame.mixer.music.play(-1, 0.0)
    pygame.font.init()
    font_small = pygame.font.Font(FONTPATH, 18)
    font_big = pygame.font.Font(FONTPATH, 24)
    for num_level in range(1, Levels.NUMLEVELS + 1):
        if num_level == 1:
            level = Levels.Level1()
            is_clearance = startLevelGame(level, screen, font_small)
            if num_level == Levels.NUMLEVELS:
                showText(screen, font_big, is_clearance, True)
            else:
                showText(screen, font_big, is_clearance)
Ejemplo n.º 3
0
def game():
    global _state
    stop = False
    while not stop:
        if _state == 'main menu':
            _state = Menues.main_menu()
        elif _state == 'play':
            _state = Levels.play('l', 'd')
        elif _state == 'highscores':
            ##            _state = Menues.highscores()
            pass
        elif _state == 'quit':
            pygame.quit()
            quit()
        elif _state == 'settings':
            ##            _state = Menues.settings()
            pass
Ejemplo n.º 4
0
def victory(Levels, level):
    running = True
    next_level_button = pg.Rect(0, 0, 400, 100)
    next_level_button.center = (renderer.disp_Width / 2,
                                renderer.disp_Height / 2 + 200)

    while running:
        renderer.victory_View(next_level_button)
        for event in pg.event.get():
            if event.type is pg.QUIT:
                pg.quit()
            elif event.type == pg.KEYDOWN:
                if event.key == pg.K_ESCAPE:
                    running = False
            elif event.type == pg.MOUSEBUTTONDOWN:
                (mx, my) = pg.mouse.get_pos()
                if event.button == 1:
                    if next_level_button.collidepoint(mx, my):
                        current_level(Levels[Levels.index(level) + 1])
                        return False
Ejemplo n.º 5
0
def ask_question(turn):
    key = {1: Levels.level_1(), 2: Levels.level_2(), 3: Levels.level_3(), 4: Levels.level_4(), 5: Levels.level_5(), 6: Levels.level_6(), 7: Levels.level_7(), 8: Levels.level_8(),
           9: Levels.level_9(), 10: Levels.level_10()}

    Q, choices, ans = key[turn]

    # Prints the question
    print(Q)

    # Shows the multiple choices
    for key, value in choices.items():
        print(key, ':', value)
    print("\n")
    # return the correct answer
    return Q, choices, ans
Ejemplo n.º 6
0
def use_lifeline(Response, choices, ans):
    # Remove 2 wrong answers
    if Response == '50:50':
        ans_key = 0
        i = 0
        for key, value in choices.items():
            if choices[key] == ans:
                ans_key = key
                break
            else:
                i += 1

        indices = list(range(0, 4))
        indices.remove(i)
        remove = random.sample(indices, 2)
        letter_key = {0: 'A', 1: 'B', 2: 'C', 3: 'D'}

        for num in remove:
            choices[letter_key[num]] = ' '

        # Shows the multiple choices
        for key, value in choices.items():
            print(key, ':', value)

        return choices

    # skip the question
    else:
        print('You use the "Skip" Help!! Here is the new question!!')
        key = {11: Levels.level_11()}
        Q, choices, ans = key[11]

        print(Q)
        for key, value in choices.items():
            print(key, ':', value)
        print("\n")

        return choices
Ejemplo n.º 7
0
def main():#Run entire game
	player = chr.Player()
	lvl.level_one(player)
	
	if player.health>0:#run the next level if the player isn't dead
		print "Holy shizzle, your health is still %d\n" %player.health
		lvl.level_two(player)
		
		if player.health >0:#run the next level if the player isn't dead
			print "Holy shizzle, your health is still %d\n" %player.health
			lvl.level_three(player)
			
			if player.health >0:
				print """
				You have won the game!! You have defeated your greatest sins!\n
				You make your way through the portal, back to sanity. """
				time.sleep(60)#wait one minute
				
			else:
				print "You have lost. You is dead! You lost to Envy, the most unforgiving sin.\n"
				print "Restart game? (y/n)"
				restart = raw_input(">")
				if restart == 'y':
					main()
				else:
					sys.exit()
			
		
		else:
			print "You have lost. You is dead! You lost to Gluttony, the grossest sin\n"
			print "Restart game? (y/n)"
			restart = raw_input(">")
			if restart == 'y':
				main()
			else:
				sys.exit()
	else:
		print "You have lost. You is dead! You lost to Pride, the most abundant sin\n"
		print "Restart game? (y/n)"
		restart = raw_input(">")
		if restart == 'y':
			main()
		else:
			sys.exit()
Ejemplo n.º 8
0
 def __init__(self,ps,n):
     self.ps=ps
     self.uos=[]
     self.ucs=[]
     self.ur={}
     self.fx=[]
     self.level=(n-1)%10+1
     self.world=(n-1)//10+1
     manualspawn=False
     self.load("%s-%s"%(str((n-1)//10+1),str((n-1)%10+1)))
     for r in self.w:
         for obj in r:
             if obj and obj.updates:
                 self.uos.append(obj)
             elif obj and obj.name=="Sink":
                 self.washing=True
             elif obj and obj.name=="Spawn":
                 try:
                     ps[obj.d].place(obj.x,obj.y)
                     self.dest(obj)
                     self.spawn(ps[obj.d])
                 except IndexError:
                     self.dest(obj)
                 manualspawn=True
             if obj and obj.ticks and obj.__class__ not in self.ucs:
                 self.ucs.append(obj.__class__)
             if obj and not obj.exists:
                 self.dest(obj)
                 self.uos.append(obj)
     self.size=len(self.w),len(self.w[0])
     if not manualspawn:
         for n,p in enumerate(ps):
             self.spawn_p(p)
     self.orders=[Levels.new_order(self.level,self.world)]
     self.tonextorder=int(self.orders[-1].time*self.reordermult)
     self.returned=[]
Ejemplo n.º 9
0
def main():  #Run entire game
    player = chr.Player()
    lvl.level_one(player)

    if player.health > 0:  #run the next level if the player isn't dead
        print "Holy shizzle, your health is still %d\n" % player.health
        lvl.level_two(player)

        if player.health > 0:  #run the next level if the player isn't dead
            print "Holy shizzle, your health is still %d\n" % player.health
            lvl.level_three(player)

            if player.health > 0:
                print """
				You have won the game!! You have defeated your greatest sins!\n
				You make your way through the portal, back to sanity. """
                time.sleep(60)  #wait one minute

            else:
                print "You have lost. You is dead! You lost to Envy, the most unforgiving sin.\n"
                print "Restart game? (y/n)"
                restart = raw_input(">")
                if restart == 'y':
                    main()
                else:
                    sys.exit()

        else:
            print "You have lost. You is dead! You lost to Gluttony, the grossest sin\n"
            print "Restart game? (y/n)"
            restart = raw_input(">")
            if restart == 'y':
                main()
            else:
                sys.exit()
    else:
        print "You have lost. You is dead! You lost to Pride, the most abundant sin\n"
        print "Restart game? (y/n)"
        restart = raw_input(">")
        if restart == 'y':
            main()
        else:
            sys.exit()
Ejemplo n.º 10
0
def gameloop():

    x, y = display_w * 0.07, display_h * 0.43
    x_change, y_change = 0, 0
    time_counter = 0
    ship_status = 0
    loop_idx = 0

    explosions = []
    live = 3
    point = 0
    gun, gun_count, gun_type = bomb_img, 3, 0
    ammos = []
    enemy_ammos = []

    gameExit = False

    while not gameExit and live > 0:
        gameDisplay.fill(bg_color)

        loop_idx = (loop_idx + 1) % int(FPS / 3)
        gif_idx = loop_idx // int((FPS / 6))

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                gameExit = True

            if event.type == pygame.KEYDOWN:
                if event.key in [pygame.K_UP, pygame.K_w]:
                    y_change = -ship_speed
                elif event.key in [pygame.K_DOWN, pygame.K_s]:
                    y_change = ship_speed
                if event.key in [pygame.K_LEFT, pygame.K_a]:
                    x_change = -ship_speed
                elif event.key in [pygame.K_RIGHT, pygame.K_d]:
                    x_change = ship_speed
                if event.key == pygame.K_SPACE:
                    ammos.append([int(x + 50), int(y + 15)])
                # # # if event.key == pygame.K_q:
                # # #     if gun_type==0:
                # # #         pass
            if event.type == pygame.KEYUP:
                if event.key in (pygame.K_UP, pygame.K_DOWN, pygame.K_w,
                                 pygame.K_s):
                    y_change = 0
                if event.key in (pygame.K_LEFT, pygame.K_RIGHT, pygame.K_a,
                                 pygame.K_d):
                    x_change = 0

        if ship_collision(x, y, level1, []) and ship_status == 0:
            ship_status = 1
            exp_x, exp_y = x, y
            x, y = display_w * 0.07, display_h * 0.43
            time_counter = pygame.time.get_ticks()
            live -= 1

        for enemy in level1:  # Shooting enemy
            for ammo in ammos:
                if ammo[0] + 10 > enemy.x and ammo[0] < enemy.x + enemy.width:
                    if ammo[1] + 5 > enemy.y and ammo[
                            1] < enemy.y + enemy.height and ammo[
                                0] < display_w - 5:
                        ammos.remove(ammo)
                        enemy.hp -= 1
                        point += 5
                        if enemy.hp <= 0:
                            level1.remove(enemy)
                            point += 5
                            explosions.append(
                                Levels.Explosion(enemy.x, enemy.y))

        x += x_change if x + x_change > display_w * 0.04 and x + x_change < display_w * 0.9 else 0
        y += y_change if y + y_change > display_h * 0.08 and y + y_change < display_h * 0.9 else 0
        for ammo in ammos:
            fire_ammo(ammo[0], ammo[1])
            ammo[0] += ship_speed * 1.4
            if ammo[0] > 1000: ammos.remove(ammo)
        for enemy_ammo in enemy_ammos:
            fire_ammo(enemy_ammo[0], enemy_ammo[1])
            enemy_ammo[0] -= ship_speed * 1.4
            if enemy_ammo[0] < -100: enemy_ammos.remove(enemy_ammo)
        for exp in explosions:
            explosion(exp.expx, exp.expy, exp.idx // 4)
            exp.idx += 1
            if exp.idx == 8: explosions.remove(exp)
        for idx_enemy, enemy in enumerate(level1):
            if level1[idx_enemy -
                      1].x < enemy.spawn and enemy.x > -100 and enemy.hp > 0:
                enemy.x = enemy_funcs[enemy.enemy_type](gif_idx, enemy)
            if enemy.y_move and enemy.x < display_w:
                if not (enemy.y < display_h * 0.65 and enemy.y >
                        display_h * 0.15) and enemy.y > display_h * 0.5:
                    enemy.yspeed = enemy.speed
                elif not (enemy.y < display_h * 0.65 and enemy.y >
                          display_h * 0.15) and enemy.y < display_h * 0.5:
                    enemy.yspeed = -enemy.speed
                enemy.y += enemy.yspeed

        if ship_status == 0:
            ship(x, y)
        elif ship_status == 1:
            explosion(exp_x, exp_y, gif_idx)
            if pygame.time.get_ticks() > time_counter + 300:
                ship_status = 2
        elif ship_status == 2:
            col_ship(x - 10, y - 10, gif_idx)
            if pygame.time.get_ticks() > time_counter + 2700:
                ship_status = 0

        show_live(live)
        show_point(point)
        show_gun(gun, gun_count)

        pygame.display.update()
        clock.tick(FPS)
Ejemplo n.º 11
0
 def build_single_level(self):
     game = CirkitGame()
     Levels.get_level_3(game)
     return game
Ejemplo n.º 12
0
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode([1920,1080], pygame.FULLSCREEN)
bgm = pygame.mixer.Sound("sound/bgm_dia.ogg")
pygame.display.set_caption("#FAITHAGE")

# Used to manage how fast the screen updates
clock = pygame.time.Clock()

# -------- Other Useful Things Here --------
# Hide the mouse cursor
# pygame.mouse.set_visible(False)

# more vars
Levels = Levels()
bg_dia_castle = pygame.image.load("art/bg_dia_castle.jpg").convert()
main_menu = pygame.image.load("art/bg_start_screen.jpg").convert()
ui_icons = pygame.image.load("art/ui_overlay.png").convert()
ui_icons.set_colorkey((255,255,255))
ui_icons_top = pygame.image.load("art/ui_overlay_top.png").convert()
ui_icons_top.set_colorkey((255,255,255))
click_sound = pygame.mixer.Sound("sound/fx_test.ogg")
click_sound.set_volume(0.1)
dialogue_file = open("dialogue_new.txt")

backgrounds = [pygame.image.load("art/bg_plains.jpg").convert(),
               pygame.image.load("art/bg_forest.jpg").convert(),
               pygame.image.load("art/bg_hills.jpg").convert()]
game_bg = backgrounds[0]
Ejemplo n.º 13
0
import Home
import Solve
import Levels
import Play

# default screen is Home
screen = 1

while screen <= 4:

    if screen == 1:
        screen = Home.main()
    elif screen == 2:
        lvl = Levels.main()
        if lvl == 5:
            break
        screen = Play.main(lvl)
    elif screen == 4:
        screen = Solve.main()
Ejemplo n.º 14
0
un_PNL = None

# print(new_order(common_pb2.NEW_ORDER,2,common_pb2.BID,"A001.PSE",1,0,True,common_pb2.LONG))
# print(new_order(common_pb2.NEW_ORDER,2,common_pb2.ASK,"A001.PSE",1,123,False,common_pb2.LONG))


if __name__ == '__main__':
    channel = grpc.insecure_channel(MARKET_CHANNEL)  # 57500

    # symbol="A001.PSE"
    # cur=Status.status(symbol)
    last_price = {}
    center_price = {}
    symbol = "A001.PSE"
    counter = 0
    A1Level = Levels.Levels()

    lastp = dict()
    while 1:
        stub = broker_pb2_grpc.MarketDataStub(channel)
        response = stub.subscribe(common_pb2.Empty())
        for market_data in response:
            # print(market_data)
            for i in market_data.instruments:
                if i.symbol == symbol:
                    instrument = i
            print(instrument.last_price)
            bidlevels=list(instrument.bid_levels) # price;volume;order_count
            for i in range(1,len(bidlevels)):
                if instrument.last_price-0.1<bidlevels[i].price<instrument.last_price and bidlevels[i].volume>=50:
                    # todo if position then dump position here
Ejemplo n.º 15
0
	def __init__(self,fichero):
		self.__Levels=Levels()
		self.__extremes=Extreme_Interval(fichero)
		self.__total=0
Ejemplo n.º 16
0
def main():
    #Main Program "

    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    pygame.display.set_caption('TargetGolf')
    framerate = 60  # I set this framerate to use later
    screenWidth, screenHeight = screen.get_size()

    #Create levels
    level_list = []
    level_list.append(Levels.Level_01(screen))
    level_list.append(Levels.Level_02(screen))
    level_list.append(Levels.Level_03(screen))
    level_list.append(Levels.Level_04(screen))
    level_list.append(Levels.Level_05(screen))

    level_list.append(None)

    # Set the current level
    current_level_no = 0
    current_level = level_list[current_level_no]
    # Keep track of scores
    strokes = 0
    sheet = scoreSheet(screen)

    loop = True
    while loop:
        if current_level == None:
            # Draw end screen
            finalScore = sum(sheet.getScore())
            screen.fill((0, 0, 0))
            font = pygame.font.SysFont('arial', 30)
            text1 = [
                font.render("Thank you", 1, (255, 255, 255)),
                font.render("for", 1, (255, 255, 255)),
                font.render("playing!", 1, (255, 255, 255))
            ]
            for i, t in enumerate(text1):
                w, h = t.get_size()
                screen.blit(t, (int(screenWidth / 6 - w / 2),
                                int(screenHeight / 2 + (i - 1) * h)))
            text2 = [
                font.render("Final score: " + str(finalScore), 1,
                            (255, 255, 255)),
                font.render("Try again", 1, (255, 255, 255)),
                font.render("for a", 1, (255, 255, 255)),
                font.render("better score!", 1, (255, 255, 255))
            ]
            for i, t in enumerate(text2):
                w, h = t.get_size()
                screen.blit(t, (int(screenWidth * 5 / 6 - w / 2),
                                int(screenHeight / 2 + (i - 1) * h)))
            sheet.drawSheet()
            for event in pygame.event.get():
                if event.type == QUIT:
                    loop = False
                if event.type == MOUSEBUTTONDOWN:
                    #Reset levels and scores
                    # The levels need to be made again here so it resets the ball position and the finished attribute
                    level_list = []
                    level_list.append(Levels.Level_01(screen))
                    level_list.append(Levels.Level_02(screen))
                    level_list.append(Levels.Level_03(screen))
                    level_list.append(Levels.Level_04(screen))
                    level_list.append(Levels.Level_05(screen))

                    level_list.append(None)
                    current_level_no = 0
                    current_level = level_list[current_level_no]

                    strokes = 0
                    sheet = scoreSheet(screen)
            # Update the screen and wait for the next frame (without the delay the game runs way too fast)
            pygame.display.update()
            pygame.time.delay(int(1000 / framerate))
            continue
        # This for loop checks the pygame events: things like user inputs get turned into those events
        for event in pygame.event.get():
            # This event handles close the window
            if event.type == QUIT:
                loop = False
                # This event handles when the user quits
            if event.type == MOUSEBUTTONDOWN:
                mousePos = pygame.math.Vector2(event.pos)
                current_level.click(mousePos)
                strokes += 1

        screen.fill(
            current_level.background
        )  # set a background on top of everything that was drawn last frame

        # Update the physics
        current_level.update()

        # Draw all the objects
        current_level.draw()

        if current_level.finished:
            sheet.drawSheet(strokes)
            strokes = 0
            current_level_no += 1
            current_level = level_list[current_level_no]
            wait = True
            while wait:
                for event in pygame.event.get():
                    if event.type == MOUSEBUTTONDOWN:
                        wait = False

        # Update the screen and wait for the next frame (without the delay the game runs way too fast)
        pygame.display.update()
        pygame.time.delay(
            int(1000 / framerate)
        )  # The delay function takes a time in milliseconds, the framerate is in frames per second so the delay time t = 1000/ framerate

    # If we leave the game loop; quit
    pygame.quit()
Ejemplo n.º 17
0
 def __init__(self,width,height,heroObj,getLevel,testLevel=None):
     level=Levels()
     self.getLevel=getLevel
     if(testLevel!=None):
         self.arr=testLevel
     else:
         if(self.getLevel==1):
             level.level1()
         elif(self.getLevel==2):
             level.level2()
         elif(self.getLevel==3):
             level.level3() 
         elif(self.getLevel==0):
             level.level1() 
         self.arr=level.getLevel()
     self.gravity=level.getGravity()
     self.width=width
     self.height=height
     self.cols=10
     self.rows=10
     self.grid=[0*self.cols for i in range (self.rows)]
     self.margin=10
     self.rowHeight=self.height//12
     self.colWidth=self.width//9
     self.tilt=1.6
     self.hero=heroObj
     self.dummyHero=MoveHero()
Ejemplo n.º 18
0
import file_ops
import Levels

#file_ops.create_log_entry("test")
#file_ops.create_basic_cal_file()
#file_ops.read_cal_file()

print Levels.get_level_in_arc_sec(65000)
Ejemplo n.º 19
0
def SwLevel(Nomber):
    global back, Level, ArBack, sdvig, Middle, Front, fon, evid
    # Задний Фон
    if Nomber == 1:
        back = world('background/Mountain.png', 0, 0, 0, 0)
        fon = back.image
        back.image = pygame.transform.scale(fon, (width + 100, height + 500))
        evid = evidence.clues(template.First_clue)
        evid.create_clues()
        Level = Levels.level(template.First_collevel, template.First_Grlevel)
        Level.create_level(hero)
        ArBack = pygame.sprite.Group()
        Middle = pygame.sprite.Group()
        Front = pygame.sprite.Group()
        for i in range(int(Level.level_width / 587) + 1):
            front = world('background/everfree/front.png', 587 * i,
                          height - 600, 0, 0)
            front.x = front.rect.x
            front.y = front.rect.y
            Front.add(front)

        for i in range(int(Level.level_width / 587) + 1):
            midd = world('background/everfree/middle.png', 587 * i,
                         height - 600, 0, 0)
            midd.x = midd.rect.x
            midd.y = midd.rect.y
            Middle.add(midd)

        for i in range(int(Level.level_width / 587) + 1):
            bac = world('background/everfree/back.png', 587 * i, height - 600,
                        0, 0)
            bac.x = bac.rect.x
            bac.y = bac.rect.y
            ArBack.add(bac)
        #Levels.first_level(hero)
        back.sdvig = Level.level_width / 1600  # 1600 - длинна бэкграунда

    if Nomber == 2:
        Level = Levels.level(template.Second_collevel, template.Second_Grlevel)
        Level.create_level(hero)
        evid = evidence.clues(template.Second_clue)
        evid.create_clues()
        back = world('background/ponyville/sky.png', 0, 0, 0, 0)
        fon = back.image
        back.image = pygame.transform.scale(fon, (width, height))
        #print("Уровень фона на 2 уровне: " + str(back.rect.y))
        #sdvig = Level.level_width / 800  # 800 - длинна бэкграунда
        ArBack = pygame.sprite.Group()
        Middle = pygame.sprite.Group()
        Front = pygame.sprite.Group()

        for i in range(int(Level.level_width / 1916) + 1):
            front = world('background/ponyville/front.png', 1894 * i,
                          height - 500, 0, 0)

            front.x = front.rect.x
            front.y = front.rect.y
            Front.add(front)

        for i in range(int(Level.level_width / 2045) + 1):
            midd = world('background/ponyville/middle.png', 2045 * i,
                         height - 280, 0, 0)
            midd.x = midd.rect.x
            midd.y = midd.rect.y
            Middle.add(midd)

        ArBack.add(back)
    if Nomber == 3:
        back = world('background/tron/canterlot_throne_room_background.png', 0,
                     0, 0, 0)
        fon = back.image
        back.image = pygame.transform.scale(fon, (width, height))
        Level = Levels.level(template.Therd_collevel, template.Therd_collevel)
        Level.create_level(hero)
        evid = evidence.clues(template.Therd_collevel)
        evid.create_clues()