Showing posts with label unity. Show all posts
Showing posts with label unity. Show all posts

Tuesday, October 15, 2013

Chinese checkers on a spherical board



Do you like board games ? Do you like to experiment new game concepts ?

If you answered yes to one of these questions, I think you will appreciate this article. Indeed, here I offer you a variation of the chinese checkers game... on a spherical board ! This was already done for chess, but I think it is the first time for chinese checkers. So, just stop to speak now and have a game.

Choose to play against a friend on the same computer (Human VS Human), against the machine (Human VS AI), or just see the machine against herself. Then, drag the screen to navigate around the sphere and just follow instructions :


Content displayed within Unity Web Player


This project was a good opportunity for me to learn more about Unity 3D, C#, data structures and IA.

First I built the board in 3D Studio Max (from the geosphere primitive) and then I imported it into Unity. The most boring part in my C# code was to write a parser able to analyze the mesh board structure and generate automatically the core graph data structure. Indeed, it was out of question to generate the graph structure "by hand" ; I wanted a flexible solution, able to work quickly with new board designs without any long and boring new configurations. So maybe the next version of the game will offer you a large set of original boards, with some strange topologies...

Then I built my game code following a very simple MVC pattern. If you are curious about how we can apply MVC to board games, I think it will be interesting for you to look into my package structure. Maybe you could think that this is a very large package for such a simple game, but I always work in a way that allow me to extend my projects. Here my package structure is suitable to add new boards, new AI, new game modes...


  • [_] chineseCheckers
    • [_] controlers
      • [_] ai
        • AIControler
        • DistanceTable
      • [_] human
        • HumanControler
      • AbstractControler
      • MoveData
    • [_] data
      • CellData
      • DataManager
    • [_] games
      • AbstractGame
      • AIVsAIGame
      • HumanVsAIGame
      • HumanVsHumanGame
    • [_] gui
      • [_] elements
        • InGameHud
        • Menu
      • GameGui
    • [_] navigator
      • DragNavigator
    • [_] parser
      • BoardParser
    • [_] view
      • Cell3D
      • CellColors
      • Pawn
      • View
[_] FOLDER
CLASS

Finally, I coded an AI, trying to keep it very simple and CPU-light. I will explain the algorithm in a future article, but you can see now that it is very fast (so fast that I must slow-down the run in order to keep the "AI vs AI" game comprehensible).

I hope you enjoyed the game !


Friday, July 5, 2013

Doraemon into Unity3D !

Do you know Doraemon ?

If no, and if you like 2D cartoon animation, you must discover this series, knowing that you can find a lot of resources on Youtube....

If yes, maybe you will be happy to now that I did a little demo playable online here !

Click in the game below, and then control Doraemon using LEFT/RIGHT arrows and SPACE of your keyboard:

Content displayed within Unity Web Player


So what are the features of this demo ?

First, I used Unity3D (free version). If you don't know what is Unity3D, you can imagine it as a mix between Flash and 3D studio Max. Because the software is fully 3D oriented, you could ask me the question : why use it to do 2D content ??? Then I would answer that Unity is so powerful ! Fully hardware accelerated, can target a lot of plateforms (Win, Mac, web, Android...) and is delivered with the sophisticated NVIDIA PhysiX engine.
So the challenge here was to build a 2D engine from a 3D engine, and I must admit that with some perseverance, the result is quite good ! But it was not an easy task to keep control of the engine while contraigning it in 2D and keeping the essential liveliness for a 2D game.

Second, I built my own graphicals assets. For the Doraemon animations, I picked some episodes and captured some interesting animation sequences (idle, run, jump and fall). Then I redrawn each images of the sequences into Flash, exporting them using the "Generate sprite sheet" tool. Finally, I wrote my own C# classes in order to replay my Flash animations into Unity.

Doraemon running sprite sheet

I hope you liked this demo. If you are a Unity user and you would like to build your 2D engine like me (without 3rd party plugin) maybe I can give you some advices:
  • don't use the "Character controller" component ; it seems not relevant for a 2D game (because of the capsule collider)
  • instead, use the combination of the "Box collider" and "Rigidbody" components for your character
  • then, avoid any generated friction and bouciness between your character and other objects in the world
  • code your character to move appropriately using directly the "velocity" property of your "Rigidbody" component
  • to detect if your character has his feet on the floor, you must use the "OnCollisionStay" method. By computing the dot product between the normal contacts and the (0, 1, 0) vector, you can know if one contact occurs below the character