Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch now!Tune in to Hackster Holidays, Ep. 6 now!
Vale OrtegaErik Welsh
Published

Who said it? Taylor Swift vs. Shakespeare Trivia

This fun trivia game tests your pop culture and literary knowledge! Pretty easy, right... ? Build this fun game and see for yourself!

IntermediateFull instructions provided10 hours131
Who said it? Taylor Swift vs. Shakespeare Trivia

Things used in this project

Hardware components

PocketBeagle
BeagleBoard.org PocketBeagle
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Adafruit SPI Screen
×1
Adafruit Arcade button
×2
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Schematics

System Block Diagram

Power Block Diagram

Taylor vs. Shakespeare Trivia Game Housing Box

Code

Taylor Swift vs. Shakespeare Trivia Code

Python
This is the main script code that pulls from other class files available in the GitHub repository
import time
import random
from threaded_button import *
from spi_screen import *

# Sample quotes (add more as needed)
SHAKESPEARE_QUOTES = [
    "My tongue will tell the anger of my heart, or else my heart concealing it will break",
    "All the world's a stage, and all the men and women merely players",
    "Love is merely a madness",
    "How can it be said that I am alone when all the world is here to look at me?",
    "My pride fell with my fortunes",
    "And yet, to say the truth, reason and love keep little company together nowadays",
    "Speak low, if you speak love",
    "I do believe her, though I know she lies",
    "True love never did run smooth",
    "And I'll stay... forgetting any other home but this",
    "All that glisters is not gold",
    "Men's eyes were made to look and let them gaze",
    "When I was at home, I was in a better place",
    "In black ink my love may still shine bright",
    "By the pricking of my thumbs, something wicked this way comes",
    "There is nothing either good or bad, but thinking makes it so",
    "These violent delights have violent ends",
    "My love as deep. The more I give, the more I have, for both are infinite.",
    "I will confess to you that I love him.",
    "Sad hours seem long",
    "He...shuts up his windows, locks fair daylight out, and makes himself an artificial night.",
    "You and I are past our dancing days",
    "The course of true love never did run smooth",
    "The greatest thing you'll ever learn is just to love and be loved in return.",
    "Love is not love which alters when it alteration finds"
    
    
    # Add more Shakespeare quotes...
]

TAYLOR_SWIFT_QUOTES = [
    "Did I close my fist around something delicate? Did I shatter you?",
    "Do you miss the rogue who coaxed you into paradise and left you there?",
    "Past the curses and cries, beyond the terror and the nightfall",
    "Now my eyes leak acid rain on the pillow where you used to lay your head",
    "I meet you where the spirit meets the bones, in a faith-forgotten land",
    "Your touch brought fourth an incandescent glow, tarnished but so grand",
    "Now you hang from my lips, like the gardens of Babylon",
    "I wish to know the flaw that makes you long to be magnificently cursed",
    "Take me to the lakes where all the poets went to die, I don't belong, and my beloved neither do you",
    "I sit here and wait, grieving for the living",
    "Staring out an open window, catching my death",
    "Can't not think of all the cost, and all that will be lost",
    "In the cracks of light, I dreamed of you",
    "All we are is skin and bone, trained to get along",
    "Did the twin flame bruise paint you blue?",
    "Falling feels like flying until the bone crush",
    "Is it romantic how all my elegies eulogize me?",
    "You are an expert at sorry and keeping the lines blurry",
    "I wounded the good and I trusted the wicked",
    "Eyes like sinking ships on water, I almost jump in",
    "You, with your swords and weapons that you use against me.",
    "I break free and leave us in ruins, take this dagger in me and remove it.",
    "I greet you with a battle hero's welcome."
    # Add more Taylor Swift quotes...
]

ALL_QUOTES = [(quote, "Shakespeare") for quote in SHAKESPEARE_QUOTES] + [(quote, "Taylor Swift") for quote in TAYLOR_SWIFT_QUOTES]

# Create instantiation of the buttons
        
class QuoteGame:
    def __init__(self):
        self.delay = 0.1
        self.finaldelay = 5
        self.gamedelay = 0.4
        self.startdelay = 2
        self.display = SPI_Display()
        time.sleep(self.delay)
        print("Shakespeare or Taylor Swift?")
        self.display.text(["Shakespeare", "or Taylor Swift?"], justify=CENTER, align=CENTER)
        time.sleep(self.startdelay)
        self.button_0 = ThreadedButton("P2_2") #shakespeare
        self.button_1 = ThreadedButton("P2_8")
        
        self.button_0.set_on_press_callback(self.guessShakespeare)
        self.button_1.set_on_press_callback(self.guessTaylor)
        
        self.button_0.start()
        self.button_1.start()
        
        self.guess_flag = True
        self.counter = 0
        self.total = 0
        

    def load_new_quote(self):
        self.current_quote, self.correct_answer = random.choice(ALL_QUOTES)
        print("\n" + self.current_quote)
        self.display.text("{0}".format(self.current_quote), justify=CENTER, align=CENTER, wrap=True)
        time.sleep(self.gamedelay)

    def guess(self, author):
        if author == self.correct_answer:
            print(f"That was indeed {self.correct_answer}!")
            self.display.text(["That was indeed", "{0}".format(self.correct_answer)], justify=CENTER, align=CENTER)
            time.sleep(self.gamedelay)
            self.counter = self.counter + 1
            self.total = self.total + 1
        else:
            print(f"That was a tricky one! It was actually {self.correct_answer}.")
            self.display.text(["That was a tricky one!", "It was actually", "{0}".format(self.correct_answer)], justify=CENTER, align=CENTER)
            time.sleep(self.gamedelay)
            self.total = self.total + 1
        self.guess_flag= True
        

    def run(self):
        
        while True:
            start_time = time.time()
            while time.time() - start_time < 60:
                if self.guess_flag == True:
                    self.load_new_quote()
                    print("\nChoose the author:")
                    print("1. Shakespeare")
                    print("2. Taylor Swift")
                    self.guess_flag= False
                time.sleep(0.1)
            time.sleep(3)    
            self.display.text(["Game Over!", "Your Score:", "{0} / {1}".format(self.counter,self.total)], justify=CENTER, align=CENTER)
            time.sleep(self.finaldelay)
            self.display.text(["Let's Play Again!","Shakespeare","or Taylor Swift?"], justify=CENTER, align=CENTER)
            time.sleep(self.startdelay)
            self.display.text("{0}".format(self.current_quote), justify=CENTER, align=CENTER, wrap= True)
            
            
            

    def guessShakespeare(self):
        self.guess("Shakespeare")

    def guessTaylor(self):
        self.guess("Taylor Swift")
        
if __name__ == "__main__":
    game = QuoteGame()
    game.run()

README file for Taylor Shakespeare Trivia

Python
README file
# Who said it? Taylor Swift vs. Shakespeare Trivia Game

This is a portable trivia game device, set to start upon plugging into power source. The game consists of 60-second mini-games, during which the user has limited time to attribute as many quotes as accurately as possible to either pop star Taylor Swift or playwright and poet Shakespeare.

## Table of Contents

- [Features](#features)
- [Set Up](#setup)
- [Usage](#usage)


## Features

This device features interactive components that engage with the user during play time. These include:
-Button
-LCD Screen

## Set Up
A device description with build instructions, including proper wiring of electronics and hardware components, can be found in the following Hackster page: [Who said it? Taylor Swift vs. Shakespeare Trivia](https://www.hackster.io/vlo1/who-said-it-taylor-swift-vs-shakespeare-trivia-fd3cca) 

## Usage

To start the game, simply plug in the Trivia Box into a wall outlet using a USB to wall adaptor. After approximately 30 seconds, the game will start automatically and the user will be prompted to start playing on the LCD screen.

Taylor Swift vs. Shakespeare Trivia Code

Link to github repository of game code

Credits

Vale Ortega

Vale Ortega

1 project • 0 followers
Erik Welsh

Erik Welsh

33 projects • 18 followers
Thanks to Erik Welsh.

Comments