Giter VIP home page Giter VIP logo

pyl_spinner's Introduction

Press Your Luck!

Press Your Luck Logo: https://vignette.wikia.nocookie.net/gameshows/images/9/94/Press_Your_Luck_2019_Logo.png/revision/latest?cb=20190510203222

A pygame program that behaves like the classic 80s game show "Press Your Luck" (which was rebooted again in 2019).


Setup

To install

See pygame installation command below

To run

Make sure you're within the directory of the module

export PYTHONPATH=$PYTHONPATH:.

To clone

git clone https://github.com/azoght/pyl_spinner

How to play

ScreenShot

Click "Start Spin", wait, and click "Stop Spin" when you think you've landed on your lucky prize!

ScreenShot

This game uses the power of random to generate prizes.

Land on a blue square and you win some money...

ScreenShot

...but land on a whammy and your money goes down to zero! Like the original game's rules say, if you get four Whammies, your game stops. "Game over!" will be printed on the console.

ScreenShot

The number of spins you get in a game is also random (unlike the original game where you answer questions to earn spins) and your spin count will show up on screen. You can hack this by changing the spins variable in main.py.

Because I had problems with toggling while coding this project, there are two seperate buttons to start and stop spinning.

The final prize of the game in dollars won't be printed on the pygame window, but rather on the Python console.


Random number generation system based on probability

When landing on a blue square, the minimum prize is $1000 and the maximum prize is $1000000 (a million dollars!).

The random prize generation system works in a way that you have a bigger chance of winning smaller amounts of money, as well as a 25% chance of getting a whammy.

To do this, the handy-dandy random number generator outputs a number between 1 and 1000 many times a second, until the stop button is clicked. If the output is 750, the reward will be set to a million. If less, the reward will be 1000 minimum and 500000 maximum. If more, a Whammy is generated! Here's the full function:

def spinReward() -> int:
    r = random.randint(1,1000)
    if r >= 1 and r <= 369:
        return 1000
    if r >= 370 and r <= 559:
        return 2000
    if r >= 560 and r <= 659:
        return 2500
    if r >= 660 and r <= 704:
        return 5000
    if r >= 705 and r <= 725:
        return 10000
    if r >= 725 and r <= 734:
        return 20000
    if r >= 735 and r <= 739:
        return 25000
    if r >= 740 and r <= 743:
        return 50000
    if r >= 744 and r <= 745:
        return 100000
    if r >= 746 and r <= 747:
        return 250000
    if r >= 748 and r <= 749:
        return 500000
    if r == 750:
        return 1000000
    else:
        return 0

BONUS: Whammy GIF!

Unlike the original, only one Whammy animation is used: a GIF I borrowed from the Internet, but must give David Frangioso the credit for (Frangioso is behind all the Whammy art I've inserted to this program).

I made a function that plays this Whammy GIF, really quickly:

def playGif(frames: [], frame: int, x: int, y: int):
    global s
    s = False
    fn = "files/ezgif-2-890a93be7cdd-gif-im/" + frames[frame][0]
    img = pg.image.load(fn)
    for a in range(frames[frame][1] * 50):
        window.blit(img, (x,y))
    s = True

Note: pg is my nickname for the pygame package in this program.

All you need is Pygame!

The random package is built-in, so the only package you'll need to download to run this program sucessfully is pygame. To install through terminal:

pip install pygame 2.0.0.dev6

Who's ready to press their luck? Try playing along with the game when it airs Sunday nights @ 9.

pyl_spinner's People

Contributors

azoght avatar

Watchers

Tony Zoght avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.