vendredi 11 décembre 2020

[DirectX12] Match 3 on my Game Engine

 I made a Match 3 game with my game engine with Direct X12

Gameplay

Like the a lot of game like Candy Crush, the idea is to match 3 identicals candy vertically or horizontally. To make it, player have to pick 2 adjacent candy to swap them. When this occur , the candys are destroy and all the candy above fall, and news candy are create if need

Special candy can be create if more than 3 candy are destroy

- If it'is 4 candys vertically , a new candy is create which will  destroy all the line on the location of the candy
- If it'is 4 candy horizontally, a new candy is create which will destroy all the column on the location of the candy
- If it's 5 or more than , a special candy is create. If the player match with a candy near the special candy. All the candy same that the candy match are destroy

Multi threading

The gameplay algorithm is not very difficult. But I think the matching algorithm can be parralized 

Instead of iterate on each slot of the grid. I use a thread pool, when on each threads I send each lines of the grid.


Joker bonus

Start Grid

Vertical bonus candy


dimanche 6 décembre 2020

[DirectX12] Collision Function

 Collision is essential for any game engine. Most entity have basic shapes (Triangle, Sphere, Quad).

Their is a lot of kind of intersection here is the result on my game Engine


Line Line Collision

Line Line Collision (False)

Quad Quad Collision

Quad Quad Collision

Point Collision (False)

Point Collision

Point in Sphere

Point not in Sphere

Ray Sphere Collision

Ray Sphere Collision (False)

Ray Triangle Collision

Ray Triangle not Collision

Sphere Sphere Collision

Sphere Quad No collision

Bounding Sphere
Sphere Quad Collision





 



    


jeudi 8 octobre 2020

Unity 2D Sample Game

Here is my first project in Unity . I first start to make 2D game sample in Pixel Art. This goal of this article is to display basic skill in Unity

Sprites are from this website :https://opengameart.org/

In this project I made :

- A platform game design with sprite tile palette
- Manager 2D collision
- Create a UI interface which manager life and coins 
- Create collectable likes lifes coins , open chest 
- Create a pattrolling snake enemy which can damage player but can also be kill (by jumping on his head like Mario)
- Transition between different scene and create a transition screens (fading screen)

Start game with health life, chest and snake !

Exit door to the next level

                                                            The door transition to the next level






lundi 7 septembre 2020

Child and Components

Game Object are a combination of Component (Collision or physics components) or childs game objects (Matrix palette or objects bind to another object)

For that , on each Game entity, I create 2 linked list when we can attach Components of Child games objects


The green ground is a "child" of the cube actor, the cube actor have a white collision component



mardi 1 septembre 2020

Space Partition DX12

 Grid Partition

Grid 5 x 5
                                                                            Grid 5 x 5


QuadTree

Quad Tree Level 1
Quad Tree Level 2

Quad Tree Level 3

   Quad Tree decomposition

Octree

Octree 


jeudi 13 août 2020

BTA Game : Enemy AI

 On this small subject, I focus on enemy AI. On a bta game, one of difficult task is to keep ai balancing.Enemy should not be too weak but also no to skillful.

Design 

I'am playing the latest  Devil May Cry on PS4, and I try to reproduce the enemy behavior. Enemy on this game are weak, they are mainly use for player to perfom combo. But they sometime have some reactions 

Architecture

I use a Finite State machine to present different states of the AI :

- Approach : Enemy approach player from a random distance
- Idle : It's will stay idle for some time. If the player come to close to him, it will sometimes attack. Always attacking will make him to strong.

Eneny will have 2 attacks : 

- Attack : It's will try perform an attack, to do that, its will come near to player and attack him
- Rush Attack : It's a special attack. Enemy will rush to the player know position to attack him. If the player move , enemy will attack on his last know position.

Because this enemy is a common enemy, it's shoud be more weak than strong

Standard Attack


Rush Attack
Rush Attack


mercredi 1 juillet 2020

RPG Game (UE4)

RPG in Unreal Engine 4

Here is the project of an rpg game "semi automatic turn by turn "

Note this project is not finished, and I have no intention to make a real game. It's just a demo , so the graphics or UI will not polish but I'am more interested to make a working gameplay

Game start


Gameplay

The player control a team of 3 actor (soldier,healer and magician).Each characters have skills, soldier have strong attack, healer can cure injuries and magician can cast magic attack.

After the waiting time is over (when the bar is full) actor player have differents actions

- Attack with a weapon an enemy
- Use Skill (heal or magic attack)
- Use Object
- Defense

The specifity is that each actions have cost value (maximum of 1 pts). So by example his is a combination of actions :

attack (0.25 pt) + attack (0.25 pt) + attack (0.25 pt ) + attack (0.25 pt) = 1.0
fire skill (0.5) + attack(0.25) + attack(0.25) = 1.0
Object (0.5) + Heal Skill (0.5) = 1.0
Defense = 1.0

Player's actors can use multiples actions in one turn. After that player input each action to 1, actor executes each actions

Healing action


Record actions

To avoid that player have to input the same sequence, last actions are saved and can be replay immediately with a menu.  Player can also save 2 configurations which he can program some actions (Like gambit in FF12)

Create command


IA Control

With the record of the actions and the possibility to record 2 actions, player can set theses actions on the actor to make them perform automatically in loop. Player can open menu to change the action setup.

If the actor player performs an action that he can't do (like no MP or the item), it's will replace by a defense move

auto command


Fastest Input

I recently play Persona 5 , and I like that each actions are set on a button. It's make the battle faster. That why on the game, each action are set on button. D Pad is to select directly target or ally. The only moment when there is a menu , it on select object or skill.

It's important to faster action during rpg battle to keep dynamic of the battle

shortcut on the left side 

dimanche 21 juin 2020

AI : Squad Unit

AI Squad demo

On a shooting game, player frequently face a multiple enemy which sometime act like a squad (team).
F.E.A.R (First Encounter Assault Recon) is a fps which have a "revolutionary" ai system. On this mini project,I try to integrate a ai system similar to the game

Analysis

Thing that I undestand from the paper "Three State and a plan : The AI from FEAR" by Jeff Orkin,it's that a AI can be summary 2 states  moving entities and perform animation (because I'am just using basic shape like triangle and quad, they will not have animations). So the idea is to make the transition less as possible. One other thing is to separat between goal , action , and reaction, that way designer and programmer have a maximum of modularity to create different action and goal

Sensor, Goal , and Action

To create a maximum goals, actions and reactions . I create each action and reaction (call "sensor") separately.

By example sensor , I create sensor call "View player" (player enter in ai sight) , " search ally" (ai can detect if he got allies around him)

By example actions, i create by example , "looking at position" (ai goes to inspect strange location), "attacking player" (shoots at player position) "go to cover" etc etc

An I create goals, goals is form by actions create previously, that way goal is create by juste combining different to create specific goal.

Squad Behaviors

AI agent work as a squad entity (thant mean it's form by multiples soldiers). AI Entity have role like soldier which follow order of a captain, a catpain which give orders to soldier.

Each goals is selected with a Behavior Tree (and black board) to select the best actions on each situations

Each AI entities need to gather all the information on the world to select actions.. if an agent detect by himself an information, it's update his blackboard but he also needs to share this informations with his colleagues. Worldstate is an instance share by all ai entities , each time a entity wants to say something to other ea, he put a message on this WorldState. His colleague just need to get the message to update theirs status.

By example, supose that the commando hear a fire shoot from the player, he wants to send soldiers to inspect the zone. He send an order on the world state (Call "FACT") , soldier can pull the order from the worldstate, if the order is more important than he current action, he will follow the new order from his boss. He then update the worldstate to tell his boss that he gots the informations.

The modularity by separating action and goal play a role in this example, because commando can give order goal to soldier but only soldiers with the goal can answer
the order.


Soldiers patrols

Soldiers inspect suspect location
soldiers attach the players


Direct X12 Game Engine

I start a game engine which are using OpenGL/ DirectX12 graphic api

All the IA on article below are using my game engine on OpenGL

Here is some pictures of CG graphics using Direct X 12. Theirs demo is from the book "3D game programming with Direct X12 " whici I implementend in my game engine

Basic shape



Textures shapes


Billboard with geometry shader

skining without texture for now
skybox

lundi 25 mai 2020

Beat them all (UE 4)

Presentation

On this project use with unreal Engine 4 , the idea is to reproduce a beat them all game like Devil May Cry (DMC).

Note this project is not finished, and I have no intention to make a real game. It's just a demo

Actions 

- Attack enemy, base on the timing of the input, theirs is different combo. On this project if the player input : attack, attack, wait the end of animation, then attack
.Player actor will perfom 2 more attack (like in DMC)
- Locking target and move around. Player can change target lock
- Player can fire projectile (UE 4 Logo) if a enemy is lock , projectile go direclty on target
- If the play walk during an certains amount of time, it's will run (Like in DMC 5)
- Player can jump and attack
- Charge attack (DMC) :  if the player input front + attack , player actor rush to the target if lock and attack
- Launch Attack (DMC) : if the player press back + attack, player will perform that launch enemy upward
- If the player does'nt touch anything , the player actor will perform a relax animation

Lock Action

Relax Action

Attack action

Run Action

Behavious Tree (BT) with Finite State Machine (FSM)

We can combine Behavious Tree and Finite State Machine. Each Leafs of the Behavious Tree are Finite State Machine system. That way we can get all advantages of this 2 AI techniques.

I use this paper A Character Decision-Making System for FINAL FANTASY XV by Combining Behavior Trees and State Machines by  Youichiro Miyake, Youji Shirakami, Kazuya Shimokawa,
Kousuke Namiki, Tomoki Komatsu, Joudan Tatsuhiro,Prasert Prasertvithyakarn, and Takanori Yokoyama(http://www.gameaipro.com/GameAIPro3/GameAIPro3_Chapter11_A_Character_Decision-Making_System_for_FINAL_FANTASY_XV_by_Combining_Behavior_Trees_and_State_Machines.pdf)use in Final Fantasy 15 , I didn't implement the tool but get the idea

Behavior Tree is an classical one and the FSM is based on this paper A Reusable, Light-Weight
Finite-State Machine by David Grez Graham (http://www.gameaipro.com/GameAIPro3/GameAIPro3_Chapter12_A_Reusable_Light-Weight_Finite-State_Machine.pdf) use on this game Drawn to Life: The Next Chapter.

On this sample project, Actor lives in a house and 3 neend : sleep, eat, wash (and play video game if he have nothing to do), it's like the Sims game.
Every time a leaft of the BT is selected, we goes in a FSM to accomplish actions by instance eat means take a meal, put it on oven and eat or for sleeping it's means switch of the light , sleep n and switch on the light when the actor sleeps enough



Score Behavious Tree (Goal Oriented Behaviors Score)

Behavious Tree actions are selected depend some conditions.One of the weakness is player can anticipate the action if he knows how to trigger this behavious
and on the developpement we need to add more and more condition when we are checking condtions

On this paper : Simulating Behavior Tree, A Behavior Tree/ Planner Hybrid Approach by Daniel Hilburn(http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter08_Simulating_Behavior_Trees.pdf)Use the in Jedi Academy Kinect.The idea is to make "simulation" of each action possible and select the best one. On my side, I add a score system to know which are the best actions

On this example, it's a shooter game. The AI Actor have to select the best actions depend on data:

Data are :

- Weapon : Handgun, Shotgun, Sniper . Weapon are more or less effective depend on the distance (Sniper is good for far target, where shotgun is good for close combat)
- Health
- Cover
- Health pack distance

Actions :

- Attach the player
- Go Cover or take health pack
- Go near or far the target to use more effectively weapons

With this method, user can add/remove conditions and can tweak more easier than a "classic" BT

Bot attack player with a sniper

Bot go near the player to use shotgun