Inspiration

I spent most of my childhood (it is not over; I am just 17) at the arcade. I would jump with excitement whenever the game machines spit out tickets, and it did not matter how many of them there were. After shedding blood, sweat, and tears at the arcade I would proudly march out to exchange the tickets for weirdly colored pencils and erasers. Then the pandemic happened, and all arcades closed. I was devastated, yet happy cause it was easier to pass exams now! Me and my friends resorted to playing games like Fortnite, Valorant, and Apex Legends, but the kid in me felt unsatisfied. I did not work towards the idea of creating my arcade games at the time because my grandparents fell ill. I felt a slap of reality. I recently read an article about how gaming arcades were on the verge of dying in Japan, and this left me completely devastated. I soon found out about this hackathon and decided to attempt to recreate my favorite arcade game – ping pong.

What it does

The game is as simple as it can get. The program detects your left and right hands and allows you to control the bats by simply moving up and down. The game can be played by either 1 or 2 people . The bottom of the screen displays individual scores. Once the game is over, a cumulative score is displayed and players are asked to press R to restart the game.

How we built it

I built NewFangled using Python. The program accesses a user's camera using cv2, to make the user interface more attractive I added a background image. User's hands are detected using the HandDetector from cvzone.HandTrackingModule.

            if hand['type'] == 'Left':
                img = cvzone.overlayPNG(img, imgBat1, (50,y1))
                if 59<ballPos[0]<59+w1 and y1 < ballPos[1] < y1+h1:
                    speedX = -speedX
                    ballPos[0] += 3
                    score[0] += 1

The program adds the user's score and moves the ball if the ball hits the user's bat. The same is done for the right hand as well.

            if hand['type'] == 'Right':
                img = cvzone.overlayPNG(img, imgBat2, (1195,y1))
                if 1195-50<ballPos[0]<1195-30 and y1 < ballPos[1] < y1+h1:
                    speedX = -speedX
                    ballPos[0] -= 30
                    score[1] += 1

Eventually, the program detects when the player misses a hit on the ball and terminates the game. After which it displays an appropriate message to restart the game.

    if ballPos[0]<40 or ballPos[0]>1200:
        gameOver = True

    if gameOver:
        img = imgGameOver
        cv2.putText(img, str(score[1]+score[0]).zfill(2), (585, 360), cv2.FONT_HERSHEY_COMPLEX, 2.5,(200, 0, 20), 5)

    cv2.imshow('Image', img)
    key = cv2.waitKey(1)
    if key == ord('r'):
        ballPos = [100, 100]
        speedX = 13
        speedY = 13
        gameOver = False
        score = [0, 0]
        imgGameOver = cv2.imread('/Users/aadi/Desktop/Resources/gameOver.png')

Challenges we ran into

I am a beginner. I had computer science at school, but classes were conducted in Java. I did not know anyone who had expertise in Python, so everything I have created is work of my own. The hardest part was finding the right resources in this infinite realm of the internet. There were often instances when I thought that it was impossible to make my idea into something tangible, but things seemed to work out by the end.

Accomplishments that we're proud of

I am extremely happy with my progress. I have learned so much in such little time! I would like to thank the organizers of this hackathon for the amazing free content they put out. For someone like me who did not have anyone to guide them through their programming journey, the resources the competition put out were amazing!

What we learned

I learned so much! I learned things that I never thought I could, things that I felt were out of my realm. I thoroughly enjoyed watching FreyHacks live streams on Twitch and Youtube such as Intro to web development, exploring Python with Codedex, and building a desktop app using electron. The hackathon has successfully sparked my interest in JavaScript, and I look forward to learning more!

What's next for NewFangled

NewFangled is open to a magnitude of interesting things. I hope to recreate more popular arcade games such as flappy birds, asteroids, space invaders, etc. It would be really interesting to implement gesture controls to these games and hopefully create an app where these games can be easily accessed.

Built With

  • cv2
  • cvzone.handtrackingmodule
  • python
Share this project:

Updates