Creating a Super Old-School Text-Based Jane Austen Game Using Python

Written by dantecualesjr | Published 2018/07/14
Tech Story Tags: coding | python | jane-austen-game | jane-austen

TLDRvia the TL;DR App

We started the Computer Science portion of our curriculum in Lambda School this week by covering the basics of Python and Object-Oriented Programming (OOP). So technically, we are now half-way through the course. Time certainly flew by so fast! It seemed only yesterday that I wrote my very first Medium article about becoming a software engineer.

Anyway, fun fact: Did you know that Python was named after the British comedy group “Monty Python”? You probably knew that already. I didn’t, so it was amusing for me when I found out about it last week while reading the language’s history. Guido van Rossum, the creator of Python, was guided by the principle that Python ought to be fun.

And you know what? For the most part, I certainly had fun using Python this week, even though it was my first time to learn it. I say “for the most part” because our Sprint Challenge today was a very tough nut to crack.

It helped that I already had some familiarity with JavaScript. I would even say that Python was easier for me to learn because I already was exposed to JavaScript beforehand. They are very similar in their logic. For example, Python also has arrays called “lists”, objects called “dictionaries”, if statements, for loops, while loops, and so on.

The main difference between the two is probably their syntax. For instance, Python uses white-spaces and indentation whereas JavaScript utilizes curly braces.

So one of the projects we did this week was to edit the codes of a “text adventure game”. You know, those super old-school text-based games that utilized, well, text instead of graphics. I was able to complete it, but in order to understand how things really worked under the hood, I had to create my own text-based game.

And I called it “Darcy’s Proposal”, based on Jane Austen’s novel Pride and Prejudice. As the name suggests, the object of the game is pretty straightforward, and that is for the main character, Mr. Darcy, to find Elizabeth Bennet (the heroine in the story), successfully propose to her, and win her hand in marriage. (If you haven’t read the book yet, that will sound like the most boring plot for a game in history. But I’m a huge Austen fan, and that novel is my favorite of all time, so that plot sounds exciting to me, and when you’ll get around to reading and appreciating Jane Austen, you’ll know what I mean.)

Of course, this game will only appeal to men, so it might be cool to create a counterpart game for girls, like say “Lizzy’s Refusal”, wherein the player’s goal is to keep on refusing Mr. Darcy’s proposal until she deems him worthy of her hand (i.e., when he loses his pride, arrogance, and so on.)

It was easy to build because all I did was use dictionaries (objects) and classes.

Our main project for the week, the Sprint Challenge, was about creating a clone of the classic Atari game called Breakout.

It was a lot harder to make. The challenge was to build a product that has all, or most, of the features in Breakout. So there has to be a paddle at the bottom of the screen that the player can control, and of course there has to be a ball that bounces between the paddle, the walls, and the blocks at the top of the screen. These blocks have to vanish once the ball hits them, and so on.

Most of the codes were already provided to us, especially the ones that gave the “collision” functionality between the objects. All we needed to do was create the objects for paddle and blocks. There already was a super (parent) class for Block in the file, so I created a Paddle subclass (or child class) that inherited the attributes of the parent class. I did the same thing for the blocks on top of the screen. Then, I configured the code accordingly or in such a way as to make those objects display in the game’s play area.

These two projects of mine are still works in progress, though. Mr. Darcy still has to deliver his proposal to Lizzy Bennet and the blocks in the Breakout clone still need to disappear once they’re hit by the ball. But these games gave us a lot of opportunity to understand Python in a deeper way.

***

Lambda Ambassador Program

I’ve signed up for Lambda School’s Ambassador Program because I literally cannot stop talking about my school. If you’re interested in getting into their Full Stack Web Development and Software Engineering course, go here: https://mbsy.co/lambdaschool/37941124.


Published by HackerNoon on 2018/07/14