One Game Per Day – Day8

Today’s game has been inspired by a r/gameideas/ thread on reddit by /u/TheJonesy. I figured I could give him credit in the game’s name so hear is the first day of work on Jonesy IDE.

Game 8 – Jonesy IDE (Day1)

Write code to interact with the game and solve puzzle.

Write code to interact with the game and solve puzzle.

Play Jonesy IDE!! – WebPlayer

Idea :

The idea is a mix-up of the ideas found on the Reddit thread. The objective would be to have puzzle that are solved by entering command in the command line. I would like to make the command line really feel and designed like a language. Eventually, a full editor could be added to allow more control to the player. There’s a lot of work to do before then.

You can use the Help() function to have a list of all currently implemented functions. The commands that would be implemented are things like Create(Door,”Door1″, [2,2])  then Door1.Open. Another idea would be SetTrigger(Button1, Door1) then, you could press the Button1 to automatically open the door1.

If the code design get powerful enough to create an editor, the levels could be generated by the in-game code and allow player to edit the generation of a level to solve a puzzle or create custom maps for fun.

In simple, I want to create an interface language, Rod#, that will allow control of the Unity API at runtime.

Design :


The principal scripts of my project are the following :

–  GameManger.cs : Responsible for the initialization and managing of the overall game. Not deleted on scene loading.
–  LevelManager.cs : Responsible for the initialize and managing of a level.
Compiler.cs : Evaluate the syntax of the code and evaluate the type of command to be executed
Linker.cs : Execute the commands(functions for now)  called by the compiler
– Function.cs : Class for each function. Contains its name, definition, inputs, input types…
– FunctionType.cs : This is where I create and store the List of function. The values should be imported from outside the game eventually(JSON or XML)
– Controller2D.cs : Control and animate the 2D player.

To make it short :

When a Function is entered, the Compiler look at the syntax and evaluate the type of command to execute. The Linker execute said command.

Command Window

I started design my own command window at first but realized the NGUI example close to what I wanted so I imported it and modified it to my taste. I added a button that call the same Callback as pressing Enter on the Command line input. This Callback give the command to the compiler that then verify and execute the line of code if its valid.

Call a function from its name in a string

This took me a while to get working. For each Function that are defined in FunctionType, a C# function is defined with the same name in the static class Linker. The function name is feeded to the linker that then execute it.

The first answer of this SO question got me started but didn’t touch the specific of a static function in a static class. The answer on this second SO question put me on the right tracks with the BindingFlags. A look at the MSDN documentation for MethodBase.Invoke answered the rest of the problems.

Here is how I do it for the _functionName function with no argument that is called from the static class Linker:

 using System.Reflection; // For MethodInfo and BindingFlags

 object[] _arguments = new object[] {};
 MethodInfo theMethod = typeof(Linker).GetMethod(_functionName);
 theMethod.Invoke(null, BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public, null,null, null);

Next day of work:

There is so much to do in this game :

  • Allow function to take inputs
  • Create an object system that will allow player to access property of some objects (i.e : Box1.Collider = false; Player.Controller = true)
  • Create an interface to see documentation and allowed function call
  • I’m interesting in prototyping early some kind of IntelliJ system to have real-time code completion offered to the player
  • Add more level that would be solved by code

Conclusion :

This is no simple task, the objective is to design a language that works on top of Unity/C#. It will be interesting to see the console accept more function as time goes by. This project will require me to learn a lot of design language theory which is good for my overall low-level programming knowledge.

One Game Per Day – Day7

For today’s game, I was looking to make some kind of 2D MOBA and I started to browse to find some assets to base my game on. Instead, I found a really nice set of really low-pixel Hexagon tileset by Pixel32. I started to think of a couple ways I could use the sprites and decide to make a game with it. Here is the result of the first day.

Game 7 – God of HexCity (Day1)

God of HexCity

Procedural world generation with basic city placement and land growth.

Play God of HexCity!! – WebPlayer

(* World generation can take a couple seconds to fully generate. City growth is limited to 7 cells for this version)

Idea :

The idea for this game is to make a twist on the classics like Simcity, Civilization or Colonization(one of my all-time favorite). The objective is to have an automated simulation between different cities that would fight to prosper and grow bigger while fighting for resources and land. Everything should be as scientifically accurate as possible. I would like to generate map from temperature,wind,humidity model that would yield different type of land for different position on the map. Depending on the position of the player, different source of energy would be available such as wind or solar.

The player is a god that look at the evolution happening. He can make change happens on the world, remove land from a player or grow one city’s land. He can change water to land or desert to moutain. He can add wheat close to a city to save it from famine. He could also put cloud above a city that heavily rely on solar power. However, each modification has a cost. Player will need to  manage his mana and perhaps, research new skills before being able to use them.

I see different type of games. A sandbox where player could look at the world evolve and have total, free control over it. A campaign where the player would have to make sure that its city take over the whole map by helping it grow faster than its enemy. Another mode could be some kind of skirmish, where you have to research new technology and use mana, but without having to make a city win, for the pure pleasure of modifying their behavior.

Design :


The principal scripts of my project are the following :

–  GameManger.cs : Responsible for the initialization of all system
–  GridManager.cs : Generate the grid, setup cells on creation and deal with the interaction with the cell and the mouse.
WorldGenerator.cs : Algorith that calculate the type of tile for each cell. This is where the Perlin algorithm is evaluated.
Cell.cs : Each cell on the screen have a cell. It contains the tile definition aswell as cell’s owner and eventually temperature,wind,humity…
Tile.cs : A tile is a type of land(i.e Desert,Deep Water) and is associated with a sprite for rendering. It also contains some info such as if walking on the cell is possible.
TimeSystem.cs : This was a script developped in Game3 – DigDeepInc and I imported it. It divide a day in 1440 minutes and allow to step more than one minute per frame for proper simulation.
Simulation.cs : This is the script that evaluate the action of each city at each minute.
City.cs : Information about the city of each player. It’s size, the number of villager, its current energy…

To make it short :

At start, GameManager Initialize the game. GridManager call WorldGenerator to obtain the map to draw. It then build the grid by instantiating each Cell and assigning it a Tile. Grid generation is made over many frames to show the player the advancement of generation.

Each frame, TimeSystem step over X minutes and call Simulation.TimeTick() every time. At the end of the frame, it call Simulation.FrameTick() to render the result of the simulation only once.

Procedural Generation

During this project, I learned about the wonders of Mathf.PerlinNoiseI didn’t know Unity had a built-in PerlinNoise that allowed such easy generation. It doesn’t give total control over the generation but it allow for a quick implementation which was perfect for me. I used this implementation from Answer Unity3d :

int mapheight = 15:
int mapwidth = 30;

Vector2 shift = new Vector2(0,0); // play with this to shift map around
float zoom = 0.1; // play with this to zoom into the noise field

for(int x = 0; x < mapwidth; x++)
for(int y = 0; y < mapheight; y++)
Vector2 pos = zoom * (new Vector2(x,y)) + shift;
float noise = Mathf.PerlinNoise(pos.x, pos.y);
if (noise<0.5f) map[x,y] = 0; // water
else if (noise<0.6f) map[x,y] = 2; // sand
else if (noise<0.9f) map[x,y] = 1; // land
else map[x,y] = 3; // mountain

By using random values for shift you move around and get different part of the perlin noise everytime. By using random values for zoom, you end up more or less bumpiness in the map and allow to change from let’s say, many small islands or a big land with some water around it. Here are some results that are ordered by increasing the zoom from left to right.

3 Different procedurally generated map. The zoom is increased from left to right.

3 Different procedurally generated map. The zoom is increased from left to right.

Next day of work:

Here is what I’d be interested in working on for the next day on this game :

  • Make a menu before map generation to allow customization of map from the player(Size, number of player on the map, bumpiness vs mountains…)
  • Now that procedural generation is working and the data structures are in place, I am ready to implement the simulation and make the city look for wood, foods, water. Make them grow in population/size, ect…
  • Give basic power to the player’s god like changing a tile, adding certain item on a tile
  • Refine procedural generation and optimize the grid generation for bigger map. Instead of using 1 cell = 1 sprite, I could create a chunk sprite with different tile mapped on it.
  • Start working on the save/load system. I will probably introduce a seed for regeneration of the world at load and only update change to the world after loading.

Conclusion :

Another really interesting project! I love procedural generation. It’s like AI, you can play your game and surprise yourself by the results! I can see this game going somewhere. The low-pixel tileset is really nice and give a particular look to the game. Thanks to Pixel32 for the amazing free arts!

One Game Per Day – Day6

So I finished my 5 games in 5 days! Why stop now?

So here is Game6! I really like playing this one.

Game 6 – BombAround

Drop bomb and break the boxes! Play with a friend or vs AI only!

Drop bomb and break the boxes! Play with a friend or vs AI only!

Play BombAround!! – WebPlayer

(* You can enter the world and move around while looking at sun/moon moving but there isn’t real gameplay in it yet)

It’s a simple Bomberman-clone. On explosion bomb only can only make fire on 1 cell around, you can’t get any upgrade for more bomb/longer fire.

There are some problems with collision detection. Between player and wall and even between player and fire. I will need to look into that because I don’t undertand what is happening.

I spend a bit of time tuning the AI and it’s really nice playing against it. It can be improved but at least it doesn’t kill himself too much!

I’ll add more information on this game soon.

One Game Per Day – Day5

Here we are the last day of the 5 game in 5 day. I decided to go for something bigger for this last game.  Sadly, I didn’t come up with a good gameplay. I wanted to  put a good 3-4 more hours of work, but I fell asleep. Duh. So what I have is a prototype for a game, consider it a tech demo. I would like to make a survival game in this environment based on energy and resource management.

Day 5 – HexLife

Look at the sun and moon rise in the sun on this 3D Hex world!

Look at the sun and moon rise in the sun on this 3D Hex world!

Play HexLife!! – WebPlayer

(* You can enter the world and move around while looking at sun/moon moving but there isn’t real gameplay in it yet)

Idea :

For this game, I wanted to use the Grids plugin to create a 3D world. This was the first core mechanic of the game. I decided to make it a survival game where you have to move around gathering food and resources to make your camp. Howevery, I spent most of the time on the environment/world generation/interface and couldn’t tie it up with the game play in time.

How I did it :

The 3D world is generated by a Perlin Noise image. It wouldn’t be too hard to implement my own perlin algorithm to have a new random map everygame. I created a sun and made them turn around the world.

I imported my TimeSystem class from my Day3’s Game DigDeepInc and used the same minute system for simulation purpose. Every minute, the game reduce the food value of the player. If he has no more food, he start to lose health and would eventually die at 0.

Every minute, the new sun/moon position are calculated and the temperature/light world of the light are calculated with sin and cos (Note that current model is off, the  number in the screen doesn’t really make sense)

Lesson learned :

  • Again, Grids is an awesome plugin. Bringing my tile system in 3D hasn’t been too hard and I want to keep improving with it.
  • I wanted the game environment to feel real even with the hexagonal blocks. I spent a while playing with lights/skybox and flares to give a good feeling. I enjoy the result and definitly learn how to work with those unity’s tool.

What’s Left :

There is a lot left in this game. I would like to make a realistic life simulation out of it. Light and temperature models would need improvement. I would see other models added such as winds and clouds.

I also need to add gatherable ressources. Be able to make building with the ressources(i.e fire to keep own player temperature). Make the player’s temperature change according to the outside temperature.

Conclusion :

I thought too big for this game and it shows. Maybe not falling asleep and putting 3-4 more hours would’ve make something better but that’s what happened.

All in all, this is still a protoype. Playing in the world give an idea of what it could be. I wished my last game would’ve been better but well, I went big and it didn’t pay off! I’ll definitly come back and give a second day of work to this game and see where I could bring it to.

One Game Per Day – Day4

Day4’s objective were a bit different. The goal was to make a game using the awesome Grids plugin made by the guys at Gamelogic. Gamelogic is the company that posted the original 30 games in 30 days that made me embark on this 5 game in 5 days challenge. After Day1, they emailed me and gave me a copy of the Grids plugin. This is really awesome from them and what else could I do than make a game with it? This game has been made with zero-prior experience with this plugin apart from reading the documentation and looking at examples yesterday.

This game has probably been my biggest challenge since the beginning of the week. Starting a one-day game without knowing the workflow of a new plugin is a really daunting challenge.

Day 4 – GridWar

Send your unit towards the enemy castle, steal spawner along the way and win this turn-by-turn game!

Send your unit towards the enemy castle, steal spawner along the way and win this turn-by-turn game!

Play GridWar!! – WebPlayer

(* The game is Player versus Player. There are currently no AI, you control both Red and Blue player)

Idea :

This game had to use a grid mechanic to use the Grids plugin. I didn’t really have a design in mind until late in the project. I just played with the plugin until I could generate a nice grid. The shape of cell used in the grid(Pointy Hexagon) was determined by some assets I already had. When making a game in a day, you don’t want to lose time searching for assets.

After I got my grid with textured cell, I settle for a type of game I like a lot that has seen different version over time. The goal is to send your units to conquer cells and capture the enemy castle. I went for a turn-by-turn version instead of real-time to allow 2 player on the same computer.

How I did it :

Obviously, I start by making a grid with the Grids plugin. The grid can be in any shape as long as the cells are Hexagon tile. Afterward, I specify position for both player’s castle and I create the neutral spawner and set the owner/unit value of each cell

When a cell is clicked, the game state change and wait for the player to click on another cell. If it’s an ally cell, half of the units are transfered to the other cell. If it’s enemy, half of the units are sent to try and steal the enemy cell. If the stolen cell is a castle, the game is won!

Lesson learned :

  • The principal thing I learne was to use the Gris plugin and how to work with grid in general.
  • I had some problem to sort the different layers. Unity2D and NGUI layer can’t be sorted on a same root/camera. You can only put NGUI in front or behind the Unity sprite, not in front AND behind. If there is a way, I’m interesting in knowing it.
  • Learning a new API is always a good way to learn different software structure. I learned different things along the way such as the use of IEnumerable.

What’s Left :

I’m pretty happy with the final outcome of the game. I tried to put as much polishing as I could. I’m really happy that I had time to implement a proper menu with different levels.

There are many more complex building that could be added to the game for a better gameplay(walls, structure in a bottleneck that lose unit every turn…). Also, I only scratched the grid shape creation. It is really, really easy to make various complex shape with the Grids plugin. I’ll try to add many more as soon as I can!

Lastly, I feel like adding an IA for this game would be a really interesting topic. The game could also use more than 2 players and easily be networked.

Conclusion :

Making a game in 1 day while learning a new plugin has been a big challenge. I’m really happy with the result especially considering how late the actual gameplay has been implemented in the game.

Grids is an awesome plugin that I will use in many games and I would recommend to anyone interested in a robust grid solution.

One Game Per Day – Day 3

It seems you’ve done well in yesterday’s game! You now have enough money to start your own company and manage a swarm of mech instead of driving one yourself. This might seems boring to some, but who doesn’t want to be rich? Lots of job ahead, get to it!

Day 3 – DigDeepInc

Buy and upgrade your robots to send the mining.   Don't mine at night, it's forbidden by the law. Ready to make some money ?

Buy and upgrade your robots to send the mining. Don’t mine at night, it’s forbidden by the law. Ready to make some money ?

Play DigDeepInc!! – WebPlayer

*(Game use a 1066*600 pixel size(16:9) webplayer)

Idea :

The idea for this game is to make a Tycoon game that heavily rely on the interface. It is some kind of spin-off of Day2’s game, DigDeep.

How I did it :

This game has been hard to start because I had trouble nailing the design I wanted to go for. I started by implementing a basic UI and starting to work on the time mechanic and it became a core system of the game. The game has 3 speed + a pause system. The game time is based around minute going from 0-1440 each day. The minute is displayed as standard hour(5h43) for the player. When the speed is changed, the real-life second needed to pass 1 game minute is diminished(currently 1sec=1min at Speed 1 and 0.0075sec= 1min at Speed3).

Every frame update, the time elapsed since last update is compared to the time needed for each in-game minute.  At low speed, many frame are needed for 1 minute and everything is pretty simple. However, when going at high time rate, a in-game minute take less time than a frame update. The amount of minute to be spent on the particular frame is calculated and  each minute are triggered one by one to test for event(Such as illegal mining at night) and give player money if its Mech are mining.

The rest is basically a lot of UI desig which always takes me a lot of time.

Lesson learned :

  • This game was highly UI driven and I greatly improved my workflow between Unity2D and NGUI. I tried to focus on making a clean project with a robust relation between the code and UI so it is easily scalable afterward.
  • It has been my first attempt at making a UI from a spritesheet taken on internet instead of simple buttons. This is somewhere where I can see my workflow improve. I’m still looking for the best way to take a spritesheet and make all sprite available. Unity2D sprite editor can be a quick way to do it but I can’t find a way to put each sprite in an NGUI Atlas afterward. I’ll keep looking into that.
  • I was having some problem getting a nice interface that would scale well with different size. I decided to make it pixel perfect and fix the size in the WebPlayer. Trying different solution for this gave me a good idea of NGUI’s option for scaling of the interface.

What’s Left :

The basic mechanic are there but the game would need more content to be interesting. Random event would also give a less monotonous gaming experience for the player. Rapid-prototyping also means more shortcuts and hardcoded value. Making the game to a more data-driven state would make it more scalable and easier to maintain.

There are currently no research available and the land size has no impact. The objective is to force the player in maintaining a good ratio between area and Mech forcing him to buy one or another he has too much of the other.

Conclusion :

The conclusion for this project is simple to me. UI takes a lot of time. I’m not sure if there are secret way to easily make good and robust UI but I would like to know them! Until then, I’ll keep trying different ways of building my UIs until I feel I’m really comfortable with it. I usually put most of the UI code in the same script. This time, I spread it around and let different script drive different part of the UI. It went well, but it’d be interested to see how well it scales.

This game looks really interesting to me. I like tycoons and I see many ways to improve it. I’ll definitely get back at it eventually!

One Game Per Day – Day 2

Second day in this personal challenge and second game made! In the morning of day2, I had a weird bug when I tried to build the webplayer. It took a while to debug and I started this second game kinda late. Considering this, I’m  pretty happy with the results even if I hoped to add more feature! It seems that someone liked how you controlled the ship in Day1’s game, 3DRunner,  because they decided to give you a robot-miner for today’s game. Make good use of it and gather lots of cash, it might come useful for Day3’s game!

Day 2 – DigDeep

DigDeep Game

Dig down, Gather Ressources, Sell them and Upgrade your miner!

Play DigDeep!! – WebPlayer

Idea :

I wanted to make some kind of 2D miner game. Along the way, the project started to look like an old classic, Motherload.

How I did it :

I started this project by creating a class for GroundGeneration. When the scene is loaded, an array is filled with number representing the type of tile to be displayed.  The map is then iterated to create all sprite one by one in the scene. Each sprite has its one GameObject for now. It would have been more efficient to create Chunk that contains many sprites. However, for rapid prototyping sake, I took the first option and I’m glad I did. The detection/destruction of each tile has been really simple to implement. When the player is moving in a direction, Physics2D.OverlapCircle() is created in the player’s moving direction. If it collide with a tile, the tile is destroyed and added to the player inventory.

Lesson learned :

  • I’m starting to have a good grasp of Unity2D workflow. I haven’t used 2dCollided and Collision2D a lot so I learn that on the way.
  • This was the first time I created procedurally generated content for 2D. The instantiation of sprite was a bit tricky at first but everything came along nicely.

What’s Left :

I would have like to add the option to buy upgrade for the miner in the shop. I also wanted to be able to buy new, bigger and more valuable land from the shop . Lastly, I wanted to use animation for the player’s miner but I haven’t took the time to do it. There is just so much you can do in a 10h period!

Conclusion :

The coding of this second game went pretty well. It took more time than I thought to setup the world generation but it went fine. I’m getting a good idea on how I want to start and structure my projects as I’m starting project over and over. I already have day3 game setup in my mind. I’ll get to it right now because it will be pretty UI-Heavy, and interface is a good place to lose a lot of time.

One Game Per Day – Day 1

Sunday night, I was browsing some GameDev Subreddit on my cellphone and stumbled on a thread that caught my attention.It was talking about Rapid Game Prototyping. I found myself reading 3 articles about game prototyping and found it really interesting. Here they are :

Rapid Game Prototyping: Tips for Programmers (Links to the other 2 in the first paragraph)
How to Prototype a Game in Under 7 Days
How we made 30 games in 30 days

My reaction after reading the articles: I can do that.

So here I am, prototyping 5 games in 5 days. I started my first game yesterday at 9h00 AM and spent around 8-10 hours on it. The goal was to have a simple game at a working level , and I’m proud to say I did it! Game definitly need some polishing but it will do it! So without more waiting, here’s my game!

Day 1 – 3DRunner

3D Runner world

3D Runner world

Play 3DRunner!! – WebPlayer

Idea :

Make a simple 3D Runner with procedurally generated world, Temple Run being the most known example in the genre right now. I also wanted to create all assets(Tracks,Ship, Obstacles) myself for this project so it was even harder to fit in a single day.

How I did it :

I started by creating a LevelManager that would put tracks in the world at start of level. I then Created a World GameObject and made it move at a continually increasing speed. This way, I only had to attach all Tracks and Obstacle to the world and they automatically started moving.

This way, the player is not moving and it is really simple to control. Everytime the tracks are created, a difficulty is randomly evaluated between 0 and 1. Depending on the result, tracks might be created with obstacles or holes in it.

Lesson learned :

  • I learn to use Cououtines and Yield. This is a powerful tools that I wish I used before.
  • I improved my Blender/Unity workflow. The ship and tracks weren’t too complicated to create but it took a bit of time and it’ll be easier next time.
  • I used the Particle System for the rockets fire. Playing with it going in different directions always make me more comfortable with it.
  • Overall runner experience. How to generate world, give a nice feeling to the player, Saving highscore…
  • I got a weird bug while trying to build to webplayer. Everything worked well in editor but I couldn’t build at all. Here are the error I got :

“An asset is marked as dont save, but is included in the build: UnityEditor.HostView:OnGUI()”
“Building – Failed to write file: sharedassets1.assets UnityEditor.HostView:OnGUI()”

When I searched for this bug, people said to reimport assets and try to force the refresh of the bugged asset/script. However none of what I tried worked until I found a link that gave me the answer. It was the NGUI Built-In font Lucia Grande. I changed it and everything worked. I decided to put it here in case other get this error.

What’s Left :

Polishing, definitly. Adding a background and some models on the side would improve the speed feeling to the player. The interface could be a bit more polished and I could add some functions to customize the speed/difficulty for the player.

Also, at a certain speed, it’s impossible to fall in the holes even if there are no tracks. I tried to make gravity bigger but it didn’t completly solve the issue. I would need to think of a better way to evaluate player’s dead if he should fall down a hole.

Conclusion :

For a first game I’m really happy with the result. Making assets myself took some time but it was worth it. The WebPlayer build bug took me almost an hour this morning so I’m already late for my next game, so I should get started right now, I’m not even sure what game I want to build right now!!