Ejemplo n.º 1
0
def afterScreen():
    global score, oldSec, oldMin, secLeft, air, cut, wallList, oldScore
    mouse.set_visible(True)
    startCount = 0  #Want to make sure that the user doesn't accidentally click start right after a game;
    #I am making a counter such that after a certain point the user can make a selection

    running = True
    while running:
        for evt in event.get():
            if evt.type == QUIT:
                return "exit"

        startCount += 1
        if startCount >= 120:

            if PlayAgain_Button.checkClicked() == True:
                #We must re-setup the core game variables as they have been altered in the past session
                oldSec = local(clock())[5]
                oldMin = local(clock())[4]

                air = []
                cut = []
                for i in range(choice([1, 1, 2, 2, 2, 3, 3, 4, 5])):
                    air.append(Fruit(randfruit()))

                song.play()
                return "Play"

            if MainMenu_Button.checkClicked() == True:
                return "Splash Screen"

            if Quit_Button.checkClicked() == True:
                return "exit"

        screen.blit(gameover_screen, (0, 0))

        scoreBlit = largeFont.render("Score: " + str(oldScore), True,
                                     wallList[colS])
        screen.blit(scoreBlit, (950, 350))

        PlayAgain_Button.drawButton(screen)
        MainMenu_Button.drawButton(screen)
        Quit_Button.drawButton(screen)

        display.flip()
Ejemplo n.º 2
0
def afterScreen():
    global score, oldSec, oldMin, secLeft, air, cut, wallList, oldScore
    mouse.set_visible(True)
    startCount = 0

    running = True
    while running:
        for evt in event.get():
            if evt.type == QUIT:
                return "exit"

        startCount += 1
        if startCount >= 120:

            if PlayAgain_Button.checkClicked() == True:
                oldSec = local(clock())[5]
                oldMin = local(clock())[4]

                air = []
                cut = []
                for i in range(choice([1, 1, 2, 2, 2, 3, 3, 4, 5])):
                    air.append(Fruit(randfruit()))

                song.play()
                return "Play"

            if MainMenu_Button.checkClicked() == True:
                return "Splash Screen"

            if Quit_Button.checkClicked() == True:
                return "exit"

        screen.blit(gameover_screen, (0, 0))

        scoreBlit = largeFont.render("Score: " + str(oldScore), True,
                                     wallList[colS])
        screen.blit(scoreBlit, (950, 350))

        PlayAgain_Button.drawButton(screen)
        MainMenu_Button.drawButton(screen)
        Quit_Button.drawButton(screen)

        display.flip()
Ejemplo n.º 3
0
def renew():
    book_num=request.get_json().get('no')
    username=request.get_json().get('username')
    bok=Book.query.filter_by(book_num=book_num).first()
    lend_time=int(bok.lend_time)
    if (lend_time+4924800) < int(time.time()) and (lend_time+5155199) > int(time.time()):
        a=time.local(time.time()+5155199)
        bok.lend_time=str(time.time())
        bok.return_time=str(a[0])+"-"+str(a[1])+"-"+str(a[2])
        db.session.add(bok)
        db.session.commit()
        response=jsonify({})
        response.status_code=200
        return response
    else :
        response=jsonify({})
        response.status_code=401
        return response
Ejemplo n.º 4
0
    def post(self, idx):
        # The activities the user attended
        user_id = idx  # idx = user_id
        applications = Application.objects(applicant_id=user_id)
        apply_activities = []

        if applications:
            for application in applications:
                activity_id = application.activity_id
                activity_id = activity_id
                status = application.status

                activity = Activity.objects(activity_id=activity_id).first()

                activity_name = activity.activity_name
                open_date = activity.open_date
                genre = activity.genre
                leader_name = activity.leader_name

                open_date_local = time.local(open_date)
                format_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                            open_date_local)

                apply_activity_dict = {
                    "Project_Name": activity_name,
                    "Deadline": open_date,
                    "Deadline": format_time,
                    "Major": genre,
                    "Leader": leader_name,
                    "Application Status": status
                }

                apply_activities.append(apply_activity_dict)

            return jsonify(apply_activities, 200)

        return jsonify("You don't have any applied acticities", 400)
Ejemplo n.º 5
0
def main():

    count = False
    counter = 0
    counter2 = 0

    #All of these variables had to be defined before the actual main() function so that they would not be reset
    #once we return to the function after pausing
    global mode, song, secLeft, oldSec, oldMin, pauseTime, air, cut, score, blade, oldScore

    mouse.set_visible(False)

    running = True
    while running:
        for evt in event.get():
            if evt.type == QUIT:
                return "exit"

        #'Updating fruit positions'
        for fruit in air:
            fruit.updatePos()

        #'Updating bit positions'
        for bit in cut:
            bit.updatePos()

        #'Interactions'
        #In case the user pauses for exactly a minute and they return back to the exact same second, we don't want the program to glitch out
        #Instead, I created two "if" options: if the current second value doesn't equal the previous recorded second value OR the current second value equals
        #the previous recorded second value however the minutes are different, then the seconds left counter should be decreased
        if local(clock())[5] != oldSec or (local(clock())[4] != oldMin
                                           and local(clock())[5] == oldSec):
            secLeft -= 1
            oldSec = local(clock())[5]
            oldMin = local(clock())[4]

        if secLeft <= 0:
            endScore = score
            running = False

        #After a fruit is cut, we want to randomly add more
        if count == True:
            counter += 1
        if count == False:
            counter = 0

        #Adding more based on a random time after a fruit is cut
        if counter >= choice(
            [10, 20, 20, 30, 30, 30, 50, 50, 100, 100, 100, 200, 200, 300]):
            for i in range(choice([1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5])):
                air.append(Fruit(randfruit()))
                count = False

        #We also want more fruits to appear even if the player isn't slicing: this randomly
        #adds more fruit to the "air" list after an interval of time
        counter2 += 1
        if counter2 >= choice([100, 100, 100, 200, 200, 300, 300, 400]):
            for i in range(choice([1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5])):
                air.append(Fruit(randfruit()))
                counter2 = 0

        #Determines what the current high score is
        if oldHS > score:
            highscore = oldHS
        else:
            highscore = score

        #'Checking for collision'
        for fruit in air:
            if fruit.checkCollide() == True:
                fruit.makeSound()
                if blade.blade_type == "kitchen":
                    point = choice([
                        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                        1, 10
                    ])
                    score += point
                else:
                    point = choice(
                        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]
                    )  #The fighting blade gives a higher change of getting 10 points on a slice (user doesn't need to know)
                    score += point
                del air[air.index(fruit)]
                cut.append(
                    Bits(fruit.fruit_type, fruit.x, fruit.y, fruit.angle,
                         fruit.vy))
                count = True

        #'Checking if buttons are clicked'
        if Pause_Button.checkClicked() == True:
            pauseTime = secLeft
            return "Pause"

        #'Deleting fruits from air list if they are off the screen'
        for fruit in air:
            if fruit.y > height:
                del air[air.index(fruit)]

        #'''Drawing'''
        screen.blit(wallpaper, (0, 0))

        #Fruits
        for fruit in air:
            fruit.drawFruit(screen)

        #Bits
        for bit in cut:
            bit.drawBits(screen)

        #Buttons
        Pause_Button.drawButton(screen)

        #Blade
        #A MODIFICAR
        blade.drawBlade(screen, mp())

        #Seconds left
        if secLeft % 10 == 0 or secLeft <= 9:  #Makes every interval or single digit second light up red
            timeCol = (255, 23, 34)
        else:
            timeCol = wallList[colT]
        secBlit = medFont.render(str(secLeft), True, timeCol)
        screen.blit(secBlit, (width // 2 - (secBlit.get_width() // 2), 15))

        #Current Score
        scoreBlit = largeFont.render(str(score), True, wallList[colS])
        screen.blit(scoreBlit, (50, 15))

        #High Score
        highBlit = smallFont.render("High Score: " + str(highscore), True,
                                    wallList[colHS])
        screen.blit(highBlit, (50, 88))

        #FPS
        fpsBlit = smallFont.render("FPS: " + str(fps.get_fps())[0:2], True,
                                   wallList[colFPS])
        screen.blit(fpsBlit, (1190, 15))

        display.flip()

    mouse.set_visible(True)
    mixer.stop()

    #oldScore is the score that will be drawn on the 'after' screen
    #score is set to 0, and secLeft is set to 60 for the next time the user plays
    oldScore = score
    score = 0
    secLeft = 60

    return "After"
Ejemplo n.º 6
0
def splashScreen():
    global oldSec, oldMin, startSec, secLeft, mode, game

    splashChoice = None
    drawSplashBits = False

    #For these three fruit objects, "loading" is set to True: we don't want the x and y values to update
    splashFruits = [
        Fruit("banana", True),
        Fruit("apple", True),
        Fruit("watermelon", True)
    ]
    for fruit in splashFruits:
        #This centers the fruit coordinates on the three photoshopped circles
        fruit.x = 653 + 225 * splashFruits.index(fruit) + 64
        fruit.y = 394 + 64
        fruit.vx, fruit.vy = 0, 0

    #Dictionaries of the fruit on the splash screen and the respective screens they lead to
    modes = {"banana": "Credits", "apple": "Play", "watermelon": "Options"}

    running = True

    #Same for the main() function: we are replacing the mouse with a knife therefore the cursor should be invisible
    mouse.set_visible(False)

    while running:
        for evt in event.get():
            if evt.type == QUIT:
                return "exit"

        #Updating fruit positions
        for fruit in splashFruits:
            fruit.updatePos()

        #Updating bit positions
        if drawSplashBits == True:
            splashChoice.updatePos()

        #If the bits fall off the screen, the mode is updated
        if drawSplashBits == True:
            if splashChoice.y > height:
                mode = modes[splashChoice.bit_type]
                if mode == "Play":
                    oldSec = local(clock())[5]
                    oldMin = local(clock())[4]
                    secLeft = 60

                    air = []  #List of everything in the air
                    cut = []  #List of fruits that have already been cut

                    for i in range(choice([1, 1, 2, 2, 2, 3, 3, 4, 5])):
                        air.append(Fruit(randfruit()))
                    song.play()

                running = False
                drawBits = False

        #Checking for collisions
        #splashChoice is whichever fruit they sliced; we need to stop drawing it as a normal fruit as it will only be drawn as bits
        for fruit in splashFruits:
            if fruit.checkCollide() == True:
                fruit.makeSound()
                splashChoice = Bits(fruit.fruit_type, fruit.x, fruit.y,
                                    fruit.angle, uniform(0.5, 1.5))
                del splashFruits[splashFruits.index(fruit)]
                drawSplashBits = True

        #Drawing everything
        screen.blit(splash_screen, (0, 0))

        for fruit in splashFruits:
            fruit.drawFruit(screen)

        #Only draws the bits while they are above the screen
        if drawSplashBits == True:
            if splashChoice.y < height:
                splashChoice.drawBits(screen)
        #A MODIFICAR
        blade.drawBlade(screen, mp())

        display.flip()

        fps.tick(60)

    return mode
Ejemplo n.º 7
0
def main():

    count = False
    counter = 0
    counter2 = 0

    global mode, song, secLeft, oldSec, oldMin, pauseTime, air, cut, score, blade, oldScore

    mouse.set_visible(False)

    running = True
    while running:
        for evt in event.get():
            if evt.type == QUIT:
                return "exit"

        'Updating fruit positions'
        for fruit in air:
            fruit.updatePos()

        'Updating bit positions'
        for bit in cut:
            bit.updatePos()

        'Interactions'
        #Instead, I created two "if" options: if the current second value doesn't equal the previous recorded second value OR the current second value equals
        #the previous recorded second value however the minutes are different, then the seconds left counter should be decreased
        if local(clock())[5] != oldSec or (local(clock())[4] != oldMin
                                           and local(clock())[5] == oldSec):
            secLeft -= 1
            oldSec = local(clock())[5]
            oldMin = local(clock())[4]

        if secLeft <= 0:
            endScore = score
            running = False

        if count == True:
            counter += 1
        if count == False:
            counter = 0

        if counter >= choice(
            [10, 20, 20, 30, 30, 30, 50, 50, 100, 100, 100, 200, 200, 300]):
            for i in range(choice([1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5])):
                air.append(Fruit(randfruit()))
                count = False
        #this randomly adds more fruit to the "air" list after an interval of time
        counter2 += 1
        if counter2 >= choice([100, 100, 100, 200, 200, 300, 300, 400]):
            for i in range(choice([1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5])):
                air.append(Fruit(randfruit()))
                counter2 = 0

        #Determines what the current high score is
        if oldHS > score:
            highscore = oldHS
        else:
            highscore = score

        'Checking for collision'
        for fruit in air:
            if fruit.checkCollide() == True:
                fruit.makeSound()
                if blade.blade_type == "kitchen":
                    point = choice([
                        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                        1, 10
                    ])
                    score += point
                else:
                    point = choice(
                        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]
                    )  #The fighting blade gives a higher change of getting 10 points on a slice (user doesn't need to know)
                    score += point
                del air[air.index(fruit)]
                cut.append(
                    Bits(fruit.fruit_type, fruit.x, fruit.y, fruit.angle,
                         fruit.vy))
                count = True

        'Checking if buttons are clicked'
        if Pause_Button.checkClicked() == True:
            pauseTime = secLeft
            return "Pause"

        'Deleting fruits from air list if they are off the screen'
        for fruit in air:
            if fruit.y > height:
                del air[air.index(fruit)]
        '''Drawing'''
        screen.blit(wallpaper, (0, 0))

        for fruit in air:
            fruit.drawFruit(screen)

        for bit in cut:
            bit.drawBits(screen)

        Pause_Button.drawButton(screen)

        blade.drawBlade(screen, mp())

        if secLeft % 10 == 0 or secLeft <= 9:
            timeCol = (255, 23, 34)
        else:
            timeCol = wallList[colT]
        secBlit = medFont.render(str(secLeft), True, timeCol)
        screen.blit(secBlit, (width // 2 - (secBlit.get_width() // 2), 15))

        #Current Score
        scoreBlit = largeFont.render(str(score), True, wallList[colS])
        screen.blit(scoreBlit, (50, 15))

        #High Score
        highBlit = smallFont.render("High Score: " + str(highscore), True,
                                    wallList[colHS])
        screen.blit(highBlit, (50, 88))

        #FPS
        fpsBlit = smallFont.render("FPS: " + str(fps.get_fps())[0:2], True,
                                   wallList[colFPS])
        screen.blit(fpsBlit, (1190, 15))

        display.flip()

    mouse.set_visible(True)
    mixer.stop()

    oldScore = score
    score = 0
    secLeft = 60

    return "After"
Ejemplo n.º 8
0
def splashScreen():
    global oldSec, oldMin, startSec, secLeft, mode, game

    splashChoice = None
    drawSplashBits = False

    #For these three fruit objects, "loading" is set to True: we don't want the x and y values to update
    splashFruits = [
        Fruit("banana", True),
        Fruit("apple", True),
        Fruit("watermelon", True)
    ]
    for fruit in splashFruits:
        fruit.x = 653 + 225 * splashFruits.index(fruit) + 64
        fruit.y = 394 + 64
        fruit.vx, fruit.vy = 0, 0

    modes = {"banana": "Credits", "apple": "Play", "watermelon": "Options"}

    running = True
    mouse.set_visible(False)

    while running:
        for evt in event.get():
            if evt.type == QUIT:
                return "exit"

        for fruit in splashFruits:
            fruit.updatePos()

        if drawSplashBits == True:
            splashChoice.updatePos()

        #If the bits fall off the screen, the mode is updated
        if drawSplashBits == True:
            if splashChoice.y > height:
                mode = modes[splashChoice.bit_type]
                if mode == "Play":
                    oldSec = local(clock())[5]
                    oldMin = local(clock())[4]
                    secLeft = 60

                    air = []
                    cut = []

                    for i in range(choice([1, 1, 2, 2, 2, 3, 3, 4, 5])):
                        air.append(Fruit(randfruit()))
                    song.play()

                running = False
                drawBits = False

        #Checking for collisions
        for fruit in splashFruits:
            if fruit.checkCollide() == True:
                fruit.makeSound()
                splashChoice = Bits(fruit.fruit_type, fruit.x, fruit.y,
                                    fruit.angle, uniform(0.5, 1.5))
                del splashFruits[splashFruits.index(fruit)]
                drawSplashBits = True

        screen.blit(splash_screen, (0, 0))

        for fruit in splashFruits:
            fruit.drawFruit(screen)

        if drawSplashBits == True:
            if splashChoice.y < height:
                splashChoice.drawBits(screen)

        blade.drawBlade(screen, mp())

        display.flip()

        fps.tick(60)

    return mode