Tuesday, 11 November 2014

Implementing graphics

Working on my Sim tonight has been a trial. The graphics setup that I have been using is heavily based on the Game Programming videos by TheCherno on You tube. Up until now I have been able to add graphics for the Tables in my gym using a simple render method, but tonight I set out to add a background array of tiles to represent the ground and walls. At first I wanted to figure some of it out on my own based on the memory of implementing this method previously. It turns out I wasn't as prepared to work through the code as I'd like. Revisiting the video tutorials I started to write down and analyze the code a little better. Working out the way that each design decision fed into another, I was able (with a little tweaking) to get my code running and bring up a simple grid of tiles.

The next step involved creating a "map" from pixels, where the colors represented tiles of different types that the program could read in and create the full map from. Using hexadecimal colors and a small (64px X 64px) "map", I was able to feed this into the level loader and move around the screen with the avatar. Lining my tables up was a second issue which meant I had to rethink and refactor my code to take the tables from an Array and build an Arraylist instead. Once the level loader read my map and encountered a "table" tile, it added a new Table instance to my ArrayList and set its x and y variables to match the tile.

Here the dark lines represent walls and the orange pixels are Tables

The next task will be to work on collision so that solid objects will be impassable. I will later add features for the sprites so that the level loader will determine if a table has adjacent tables and extending the length and capacity of the table accordingly. This will also involve some new sprites and logic to determine orientation, waiter interaction points etc. Once I get around to AI, I hope that the tile grid based system will work in my favor!

I imagine that in the final version of this program, the levels will be generated and packed before release rather than having the program read from the image files. Perhaps creating the initialized level and serializing it so that it can be read into memory, preventing tampering. If my final implementation also includes using a bitmap style mapping system, it may open up the door for creating my own modding tools or level editor, placing walls, computers, tables and other features that are checked by the program for compatibility against a set of game rules.

Larger level with Waiter star icon as placeholder. All tables occupied by debug mode options

Smaller level with pixel map overlay. Green pixel represents the Waiter starting position

No comments:

Post a Comment