DEV Community

Javier Escobar
Javier Escobar

Posted on

My second Side Project: Monopoly Game

This is the second post of a series that will tell a story of my evolution as a programmer. After Visual Basic, I coded in C no-stop for about two years.

It happened again, I could not find the code, screenshots or the binaries of these projects. ☹

I was freshmen in college when I was introduced to the C programming language, the one that was taught by the moment before learning C++ or Java in the advanced courses.

Learning C was not as straightforward as I though... I had a hard time dealing with malloc, calloc and pointers. But I got the trick eventually.

I also managed to be placed as 2nd in a programming marathon. The winners were from advanced courses.

At summer vacations, I wanted to challenge myself coding something cool and then I remembered my algorithm teacher told us we can do anything with C. Everything is C, our PlayStation games, Linux and Windows so if you get to learn C in depth, you could be able to do amazing stuffs.

A Monopoly Game

I build a console game. The famous Monopoly/Tourist game:

These were the features and challenges that this game supposed to me:

  • Game logic: I had to learn the basics of gaming. A game is usually an infinite loop asking for input, making random or programmed logic, and constantly giving a motivation to continue playing. A do-while loop and a bunch of stuff inside.
  • Choosing between console or 3D: At the time, I was experimenting with the Allegro gaming library. I tried every sample and tutorial and managed eventually to make a few scenes. I remember I got to render a Yu-Gi-Oh pyramid using textures and background sound. And I thought that maybe I could do a 3D version of the Monopoly game. But before that, I'd make the console version to learn and limit the basics and then port it to a 3D version. Challenge accepted!
  • The monopoly version: There must be hundreds of versions of the game so I implemented a customizable one. The properties, currency denomination, limits, prizes, cards, and everything else could be loaded from a configuration file. I built a common Caracas (Venezuela) edition of the game with Bolivares as its currency.
  • Real Artificial Intelligence: And by real AI, I meant making the game the less predictable and challenging possible with real random number generation for the dice 🎲 and cards. Also, I implemented some logic to try to make the game the most perpetual I could evaluate if a card could give a player far more advantage over the other players. So before flipping it, the game could try to flip another one less 'benevolent'. 🤭
  • Stunning graphics: Those were not that stunning, but they were great! I used the stdio.h from Borland C which had the ability to print colored text in the console so the dice, the player figurines, and the board would change among blue 💙, red ❤, green 💚 or yellow 💛 depending whose player is its turn. In order to provide the maximum resolution possible using only ASCII code, I managed to render only the portion of the board where the player was passing through.
  • The 3D version: I could not complete the 3D version. I manage to code the dice, the board and the moving figurines but I needed time to add the game logic and design the money and cards bitmaps. College started again, and I had to deal with a lot of math, statistics and course projects. I also got a boyfriend so when I was not studying, I was enjoying his company. 👨🏽‍🤝‍👨🏽🌈

By the time I was very happy with C. I thought it was pretty awesome and that I could build better apps than I could with Visual Basic. I felt like I were coding the Matrix! 🤣

I knew the existence of C++ and got some ideas of what OOP actually was but I knew I would learn it in the next courses so I took my time to master C properly before that.

Thanks for reading! I may update this post later with references and images of what I was talking about.

Top comments (0)