Andrew Wegener's blog

Hong Kong thoughts

C++ Programming FINAL

Posted by Andrew Wegener on 15th November 2012

It’s finals week! I sound excited because I actually just finished my last exam!  Let me tell you about me C++ Programming final.  Our professor wanted us to modify an existing game.  This project is simply experiential and pretty open.  When I hear the word “mod”, I instantly think of Minecraft.  It seems like there are mods for Minecraft coming out all of the time.  So, I figured, it must be fairly simple.

I started off with research as usual.  I came upon a thing call Minecraft Coder Pack (MCP for short).  This was my key to modding this game.  Once I got it running, I realized it was all in Java…. issue.  However, I’m not a quitter.  I was almost willing to learn the Java language so that I could complete this mod, but once studying the source code, I realized it was not necessary.  Java and C++ are both object-oriented languages so they work pretty much the same.  The languages were similar enough so I could read the code and have a fair understanding of what it was doing.  A major issue is that there is over 8.5 billion lines of code in Minecraft, and finding the single line of code that changes what I want was pretty difficult.  Through forums and a whole lot of googling, these were some changes I was able to make:

Flipping the world upside down (found by accident!)

Huge creeper explosions! (or teeny tiny!)

Miltank the Pokemon!

Sunset (before)…

Sunset (after). Awesome!

Tepig the Pokemon!

I also changed the perspective, running speed, and jumping height so it was like a crazy acid trip or something.  A really great experience over all, perhaps over the break I can make a new mod on my brand new computer I bought!!!!! (pics hopefully to come later!) Have a great holiday season everyone!

Posted in C++ Game, C++ Programming | No Comments »

Assignment 6 – Windows Application in Visual Studio – TicTacToe

Posted by Andrew Wegener on 31st October 2012

Microsoft Visual was a new program for me at this point.  I did not enjoy this assignment.  However, now that I am over my frustration, I realize Professor Rueda’s intention.  He wants us to be frustrated!  No, seriously.  Through our frustration, we actually learn how to solve the problems we run into.  I don’t necessarily agree with his methods, but they might be effective… maybe.

Anyways, I tried.  I tried at least 9 times.  I spent literally all weekend from the first bus to school until the 8 or 10pm bus trying to find a game that would run.  However, it wasn’t until Sunday that I was able to get one to work – and it was the example shown in class…  I believe I still met the requirements, but it for sure wasn’t impressive.  I attempted to edit it, but it wasn’t in any form I was familiar with (it didn’t have the form window that shows the what the window will look like when it runs).  I was able to edit the colors slightly. Here are the differences in the code and the results they produced:

The above images show the original code and color scheme

The above images show the new code and color scheme

Unfortunately, this was all I was able to figure out how to change.  Like Thomas Edison said, I didn’t only get one solution for making a game (or light bulb in his case), but I discovered 1000 ways not to make one…. or something like that!  Stay positive!  Hopefully, I’ll be able to take away a little more from the next assignment!

Posted in TicTacToe, Visual Studio | No Comments »

Assignment 5B – Strategic Luck

Posted by Andrew Wegener on 31st October 2012

 

Yay! More C++ coding!  Well, judging from the pseudocode, this should be relatively easy, right? Wrong!  Just kidding.  Overall, it was pretty easy.  Let me explain:

The first part of the game is the generating of each players’ pieces.  This could be fairly simple.  However, the first set of rules I declared stated that:

1) Each player would receive ten pieces with randomly generated powers from 1-10.

2) The greater of the numbers will defeat the lesser.  The only exception is that 1 can defeat a 10.

These rules are flawed.  In theory, a player could receive ten 10s and be guaranteed to win (if the other player doesn’t have any 1s).  What I’m saying is that in some cases, it could be impossible for one player to win.  Lately, in my ITGM 351 Cognitive Art of Game Design class, Professor Rueda has been making us read about balance in games.  As it is, this game is not balanced.  It is important that games create the illusion of fairness to its players.  My solution to the imbalance was this code that determines the players’ powers:

I decided to set three randomly chosen pieces to certain powers.  This code ensures that each player will definitely have at least two 1s and one 10.  This virtually eliminates any predetermined victories or losses to either player, obviously extreme, outrageous cases can still occur but the chances are slim to none.  Also, the three random pieces are named Slot A, Slot B, and Slot C.  I added the “do… while” loops to make sure the same piece was not chosen for two slots.

The actual loop of the main game is less than 100 lines (including a fair amount of white space).  The majority of the code, in terms of lines, is from the function that displays the game board.  This function is a whopping 800+ lines.  All that remains are the random number generator function, the clear screen function, the directions, the title, and SPOILER ALERT!!!!!!….

(Highlight between the dashes to reveal the spoiler)

A GIANT PIKACHU!!!

One last thing I would like to mention… This was the first program I’ve written that I did a new (to me, at least) debugging technique.  All of the blue text are “comments” – the compiler just skips that line after the //.  Something weird was happening with the Slots and their values, so I inserted multiple cout statements telling the compiler to display the values of the slot variables.  So, if you want to play this game on “easy” mode, you could just delete the //s then the pieces values will be revealed to you.  Fun stuff!

The debugging technique and a better understanding of functions were the biggest experiences I took away from this assignment.  I have had many of my friends play this game and it’s hilarious seeing their excitement/frustration/satisfaction while playing.  For example, the game ONLY displays the enemy pieces, and ONLY when they are defeated (including in a draw).  I enjoyed this project and it went smoothly for me for the most part.

I am not allowed to post the .exe file, unfortunately.  Find my contact information and contact me. Maybe you’ll be lucky enough for me to send it to you!

Posted in C++ Game, C++ Programming | No Comments »

Assignment 7 – Compile an RPG in VS – WitchHunt

Posted by Andrew Wegener on 31st October 2012

After the previous assignment, I was about ready to give up on Visual Studio – AKA murder it.  I was so frustrated, I just wanted to make a very simple RPG and not worry about downloading anything.  So, I started make Zelda! It was such a trivial attempt that I didn’t even bother saving the project before Professor Rueda stopped me and told me to download an RPG game and compile it.  Tentatively, I gave in and began searching.

Here are some problems with this assignment: 1) Visual Studio GAMES are not easy to find. 2) RPG games are even harder to find. 3) RPG games tend to have many many many external libraries.  It took me at least 6 tries before getting one to work.  Thankfully, my classmate, Mariel, used to Linex (a fairly new term to me) so she is familiar with linking libraries and compiling programs.  She was able to download and compile a game by the next class which was about a week before it was due.  So, she was nice enough to help me out with downloaded and compiling my game.  After a couple failed (or too complex) attempts, we came across a Pokemon game.  If you’ve played Pokemon, you know there’s a lot of Pokemon, a lot of attacks, a lot of abilities, a lot of items, etc.  The Pokemon game I downloaded had hundreds of libraries full of much of this information.  Mariel walked me through how to link libraries and set up project files properly.  After I had to link all the libraries by hand (as opposed to clicking on a single folder), we realized that it was necessary to download a new compiler and access their libraries to get the game to work.  A brief attempt at finding these was unsuccessful, so I went back to searching.

I found a game called Hale.  I had everything copied into my project folder and was about to compile when I opened the last folder and realized it was in Java.  However, the linked files and everything still works fine, it’s just not the right language.  I’ve played the game for hours already – I think it’s really fun!  But sadly, it’s worth nothing if I do not find a C++ game.

It wasn’t long until I found another game.  This one is called Witch Hunt.  It’s an ASCII game written in C++ and works in Visual Studio.  This compilation was surprisingly smooth.  After Mariel’s help previously, I had a decent understanding on the basic requirements of compiling a game properly.

I am not sure if I’m doing something wrong, but early on in the game, it is necessary that you walk outside where monsters can attack you.  When this happens, I try escaping – then the game crashes.  Although this is frustrating, I DID get it compiled on my own!

This assignment, admittedly, taught me a lot.  Mariel was a huge help and now I’m curious as to what games I will be able to compile myself since I get so much enjoyment from playing Hale.  Hope the next Visual Studio project will be this successful!

Posted in C++ Game, C++ Programming, Visual Studio | No Comments »

Assignment 5A – Pseudocode – Strategic Luck

Posted by Andrew Wegener on 30th October 2012

StrategicLuckPseudocode

Here is pseudocode for my game which I call “Strategic Luck.”  While the first half is just notes and brief directions for my game, the bottom is pseudocode.  I learned that pseudocode is, simply put, a human-worded version of the code.  Basically, a sketch of what you predict the code will look like – or an outline.

I thought this was dumb.  I always imagine the code in my mind beforehand to make sure it’s feasible, this was only writing it down.  Turns out, even for how short and simple my pseudocode is, this was quite helpful.  It’s outlines the main loop of the game.  Aside from a few functions, syntax, and technicalities, the pseudocode is a simplified version of the code for my game.

Posted in C++ Programming | No Comments »

Assignment 4B – C++ – Lucky 7

Posted by Andrew Wegener on 10th October 2012

This is my first experience touching the C++ language.  Overwhelming while reading the chapters, but slightly more comprehensive once it became hands-on.  For this assignment, I wanted to create a short minigame from Mario Party 3.  Since my arrival in Hong Kong, my group of friends and I play Mario Party a couple times a week, so I thought this fit in well.  The game is simple – here is a screenshot of the instructions.

Basically, roll the dice, once or twice (rhyme!), and finish equal to or higher than the computer without falling off the staircase.

First, I needed a random number generator.  Here’s how to do that.

This says “I can pick a random number!” (above)

This is a nifty little formula to imitate rolling a die.  Melissa helped our class understand this.  So, someNumber = the random number (anything between + or – a “gazillion” (quoting Professor Rueda)).  diceRoll will equal the [huge random number "modulus" 6] + 1 . Modulus was a new term for me.  Simply put, it the remainder of the division of the following number.  For example, if the huge random number is 34821, mod (short for modulus) by 6.  To start, divide 34821 by 6.  The answer is 5803.5 . OR 5803 with a remainder of 3.  Therefore, 34821 % 6 = 3.  Some smart people figured out that dividing any integer by 6 will always have a remainder of 0-5, so, if you add 1 (like the formula does) you will always get a number 1-6 aka a dice roll.  Like Pikachu on toast.  Swag.

So let’s get started, first, I needed a game board to show the progress of the player and computer.  Rather than figuring the roughly 72 possibilities of where each player could be located, I can call on a function!  Check it out (below – click to enlarge this one)

It’s simply a series of If statements saying “if computer is here, and player is (or isn’t) here, show the player piece on this step”.  All it had to do is use the inputs of the computer’s height and the player’s height which are stored in global variables.

Now that rolling works, I wanted the computer to “cheat”.  Okay, yes it cheats – no quotation marks.  But not to the point that it always wins.  Here’s what I mean (below).

This says ” if it’s the computer’s (I call it Nemesis for no reason) second turn only, add it’s current height to the dice roll.  If it’s more than 7 (if it would fall off the staircase), say “I pass this turn.” and pretend it never rolled.” This  just means that the computer will never fall off the stairs but will always make use of it’s highest possible score.  So if the total is less than 7, it will state the roll and still move.

That basically sums it up.  Unfortunately, I’m not allowed to post my game for security reasons.  Lame.  This is not Pikachu on toast.  Oh well!  Play Mario Party 3 and play the Game Guy game Lucky 7!

Yay! I win!

 

Posted in C++ Game, C++ Programming | 1 Comment »

Assignment 4A – PS1 Game – Banjo Kazooie

Posted by Andrew Wegener on 9th October 2012

Two weeks before I left for Hong Kong, I had major reconstructive surgery on my knee.  While I was glued to the couch, I needed something to keep me busy.  What other than video games to save the day, right? :D This idea led to me hacking my Wii.  It was surprisingly easy!  I downloaded a GBA emulator with Pokemon Red along with an N64 emulator with an assortment of games including, but not limited to, Mario Party, Donkey Kong 64, Pokemon Snap, Yoshi’s Story, and of course, Banjo Kazooie (and the sequel, Banjo Tooie).  Although some of these games don’t work (example: Pokemon Snap you cannot turn the camera, the Pokemon sensor red light thing doesn’t light up, and every picture is black when you talk to Professor Oak after each run), Banjo Kazooie runs pretty well.  The opening cinematic doesn’t line up with the music properly, and there are a couple of color issues – the usually black shadows are orange for some reason – but overall the experience is virtually the same – fantastic.  Since I’ve been in Hong Kong, I’ve been playing during the little free time I’ve had.  Fortunately, my childhood memories of the game have served me well and I have completely finished the first 7 levels (100 note score, all moves learned, all jiggies, both empty honeycomb pieces, and even the cheato books!).  Rusty Bucket Bay is next, but before that, I had to make a Scratch version of Banjo Kazooie.  Quick tangent: I’m listening to music as I’m writing this, and a Banjo Kazooie sound effect just played (I downloaded about 300 sound effects from the game). Awesome timing!

Fortunately, I already had a side scrolling script AND gravity from Lunchbox’s experiments.  This saved me a bunch of time and helped me get started right away with the “fun” stuff and got me excited to work on this project.  This was assigned on a Wednesday, and that Friday we happened to have a make up class, and I practically was finished with about a C-grade project.  Anyway, I started with the sprites.  These are not my own sprites, however, I did edit each and every one of the 200+ (rough estimate) sprites I used.

Banjo!

Before I did any movement, I wanted a simple idle animation for Banjo.  The logic was quite simple for this.  The feeling of getting the script right on my first try felt nice :)

This is about as easy as it gets. Depending on the direction of Banjo, that direction of costumes would cycle through.  Oh, I also discovered the nifty little comments tool which is just like in C++ (I recently learned) how you initiate a comment with a simple “//” followed by the comment.  Cool stuff… for a nerd like me.

While Banjo is going through his Idle animation, Scratch checks to see if a button is being pressed every .1 seconds (defined by the Action variable).

This short but wide brick of script determines the value of Action.  This nested group of logic is too wide to fit on my Macbook screen, but it basically says Action = 0 when nothing is pressed.  If something is pressed, set Action to 1.  This variable’s only purpose is to trigger the Idle animation of Banjo.

From here, everything was pretty much redundant.  “(button) triggers (action x), but only while Banjo is doing (action w) but only if he isn’t doing (action y) or (action z).”

Here is an example: Banjo’s rolling script.  When ‘m’ (attack) is pressed while walking left (‘a’) and Banjo is NOT crouching or  jumping, then Banjo can roll until he is interrupted by crouching or jumping.  Banjo is allowed to jump from the middle of a roll attack in the N64 version.  (more Banjo Kazooie sound effects just played from my iTunes!)

This logic is pretty simple, but it’s my first enemy script (besides the football players in Football Frogger).  All it really says is until it’s defeated by Banjo’s attack, hurt Banjo if touched.  And when it’s defeated, it says “GRRR!” When gruntlingDeath is broadcasted, the honeycomb appears and shoots up and my fancy pants gravity script pull it back to the ground (and it bounces!).

I’m going to try to record some gameplay, so as Mumbo Jumbo says in Banjo Tooie….

Banjo Kazooie is finished! Collect the Jiggy to win!

IMG_1212

^^^^^^^^ click that link to see the gameplay and listen to the super catchy music!

Posted in C++ Programming, Scratch Games | No Comments »

Assignment 3 – Sega Game – Pikachu Racing

Posted by Andrew Wegener on 9th October 2012

For my third Scratch game, Professor Rueda asked for a Sega Genesis level game.  Through my research, I noticed many of these included side scrollers and functions such as jumping and/or gravity (or at least the illusion of it).  I started searching the web and the Scratch forums for how to accomplish these “advanced” techniques.  Turns out, it wasn’t too difficult – just some fancy variable and math tricks basically.  Before I came up with a concept for my game, I just began experimenting with these side scrolling and gravity scripts.  Using the default Scratch cat – I will call him “Lunchbox” the cat (I think it makes a great cat name) – I made the game scroll left and right and made Lunchbox jump (and bounce, but that was unnecessary).  Shown below are the scripts for those.

Lunchbox the cat! :)

Shown above is part of the logic on Lunchbox.  The If/Else statement at the top concerns the gravity and bouncing of Lunchbox when he/she lands.  While the bottom If statements affect the ScrollX variable which is explained below.

This short script is applied to each terrain sprite. It determines the placement of each sprite based off of Lunchbox’s input.  480 is the width of the screen, so when multiplied by one and added to the “position” of Lunchbox, you can figure that this brick of logic is actually the second piece of the level (the first piece would say set x to scrollX + 480 * 0).  It was confusing at first, but once I experimented with the values, it made more sense.

From here, I had no idea what to do.  I hadn’t even thought about what my actually game would be.  I enjoy Pokemon, so for no other reason than that, I decided to do a Pikachu racing game.  During my research, I realized many Sega games had multiplayer capabilities, so I wanted mine to have that feature, too.  I found some cute Pikachu sprites, and made Pikachu run.

When the space bar is pressed, RunPikaRun would be broadcasted.  Pikachu would jump 40 pixels and cycle through the costumes.  If space was pressed before the cycle finished, Pikachu would fall (it’s ADORABLE) and would stay there until space wasn’t pressed for 1.3 seconds.

AWW :}

I decided to add hurdles into the game to increase the difficulty and skill required to win.  I attempted using a ghost block, which worked – it was being detected – but wouldn’t function the way I wanted when Pikachu was commanded to jump.  However, the inevitable tripping at every hurdle was quite amusing and brought joy to the faces of my evil, Pikachu-abusing classmates.  Once Pikachu was running properly (badoom psh. Get it? Running?), sort of, I duplicated it and made a blue-cheeked Pikachu – Or Pikablue as I should have named it.  With different button commands, simultaneous play was available for head-to-head racing.

Go Pika!

Posted in C++ Programming, Scratch Games | No Comments »

Assignment 1 – Atari Game – Frogger

Posted by Andrew Wegener on 8th October 2012

Our first assignment was to create an Atari-like game.  We are using a free, new – well, new to me – program called Scratch.  It’s a great visual, easy to understand tool for learning programming.  No coding is necessary to create games, but it can be used to create mods and add custom blocks.

I started by doing research on some old Atari games.  My family used to own one a long, long time ago, but I hardly remember playing.  From the options I found, I chose Frogger.  I searched Frogger on the Scratch forum and found a simple, Atari-looking version of Frogger.  I downloaded it and tested it. It add increasing difficulty per level, lives, and sounds.  However, we couldn’t just submit a downloaded file.  I began editing sprites and realized I had to change the logic (code) of the game, too.  It was about this time that I decided to make a football game. I decided to portray one of the biggest rivalries in college football, especially from where I come from – Michigan State University’s Spartans and University of Michigan’s Wolverines.  Frogger = MSU player, cars = UofM defense, street = field, other side of the road = end zone, lives = downs.   The code for the defense was easy (shown below).

Humorously, the players still make car noises (it’s a scare tactic that they teach in the pros).  But to summarize, they are hidden, wait 0-5 seconds, appear on the left, go “vrrrooooom” while moving right (and animated legs which I did on my own –> big deal), then hide when the touch the each of the screen and begin waiting to appear on the left again.

When I finished making the players move, it was too predictable, therefore not as challenging as I wanted.  I changed the code to vary some of the defensive players so they were unrealistically good compared to the actual team (I’m biased. Clearly an MSU fan).  Shown below is the logic for the Wolverine that runs left instead of right like the others.

I believe by default the direction of all sprites is right, so the only change I made was “point in direction -90 [left]” and side the X position to 290 instead of -290 (start from the right instead of left).  Boom.  Variation.

One variation wasn’t enough for me.  I wanted to challenge myself and try to make a defenseman that would run back and forth without disappearing.  This meant I add to make my own logic from scratch (badoom psh – oh how I love nerd humor).  ”Bouncy Man” as I call him, was a bit more complex than the other defenders (shown below).

The biggest issue was setting the proper coordinates for Bouncy Man to turn around at.  Once that was worked out, he worked like a Pikachu on toast (aka good).

In addition, the Spartan was the same code as Frogger, just with a new sprite.  Lastly, I added the touchdown and game over sprites to appear when designated.  Over all, I like the game because it is never ending.  Each level is more difficult than the one before and the game only ends when you lose.

TOUCHDOWN! GO GREEN! GO WHITE! WOOOOOOO!!!!

Posted in C++ Programming, Scratch Games | No Comments »

Assignment 2 – NES Game – Duck Hunt

Posted by Andrew Wegener on 24th September 2012

Originally, I was thinking about remaking Tetris Attack, a game I received free when I purchased my SNES.  I repeat, my SNES, not NES.  After attempted to make Tetris Attack for a couple hours, I realized that I was thinking too modern.  Although it is probably possible to make using Scratch, I ran into issues early on with spacing and the foundational game play mechanics so I quit early on.  I looked up NES games on Wikipedia and saw Duck Hunt.  I was hooked. I thought about most of the mechanics and visualized how Scratch would be able to process them and figured I would be able to do it relatively easily.

I started with the crosshairs and making it follow the cursor. That was simple and it immediately got me excited for the rest of the game.  I referenced the ducks from the original game and made one of my own.  Then, it was time for the logic…

I got the duck to glide around, get shot, and do a cute animated fall, but my first main issue was the fall not being smooth.

The duck would fall, change, wait .2 seconds, change, wait .2 seconds, then fall and repeat again.

unsolved (above), solved (below)

To fix this, I made a broadcast command for the dead fall. This allowed the fall to be continuous, while the switch between costumes occurs.  Also, as shown, I animated the duck flapping it’s wings.

Once the duck was properly working, I made more. Yay ducks. Quack!

Speaking of quack, ducks are not mute creatures, so I had to add sounds.  The built in duck sound worked great for when the ducks appeared and the goose sound was fine for when the ducks got shot.

To increase difficulty, I added limited ammo.  You have one extra bullet than there are ducks.  That also means that I added levels. 4 total levels, maximum of 5 bullets. Each new duck was also 1000 more points than the last – meaning the last (4th) duck  is worth 4000 points.

Finally I added a start screen, game over screen, and a “You Win!” screen with the animated ducks flying around.  After a few more minor bug fixes, the game was basically flawless in terms of bugs.  With a few more hours before I would be calling it a night, I had the idea of a bonus level – “unlimited” ammo and many, many ducks.  Once adding a few extra ducks into the bonus level, I realized I had to change the code of each one.  I had to add a new variable and multiple new broadcasts/when I receive commands to EACH.  I was thinking of adding approximately 60 ducks on the single bonus level.  That would be roughly 60 new variables 120 new broadcasts (plus the When I Receive commands).  I attempted to shorten this process, but when I realized that with the process I was using, it was inevitable.  Maybe if I reconstructed all of my code, it would be possible.  But I already had a solid, bug-free game.  So I decided to cease my ambition and accept my game as it is.

IMG_1213

^^^^^^^ gameplay footage!

Posted in C++ Programming, Scratch Games | No Comments »