CHEMCRAFT

Monogame    C#     1 month    2020  

ABOUT

CHEMCRAFT is a 2D adventure game based on collecting, battling, and breeding (“reacting”) chemical compounds. The game follows the story of a young chemist, Marie Furie, who shrinks to the molecular scale and finds herself in a world where chemical compounds are alive and conscious. She quickly befriends one such compound, and thus embarks on a journey of curiousity, friendship, and discovery.

[1] Architecture

A mix of DAG and layered architecture is implemented for the organization of classes. As a data-driven game, xml files are used to load large files such as maps, dialogue trees, and NPC attributes. Inputs for the UI are event-driven and a state machine is used for different screens and event in the game, such as conversation trees or battle events. 

[2] Tile Map Class

The graphics, movement, and collisions in the game are heavily based on a tile-system. Every map is loaded into the game in xml by specifying the corresponding tiles as visual-text format.

As a tile-based collision system, the collision logic is straightforward. The code first finds the 4 surrounding tiles of the player bounding box to the nearest point in the tile grid. Then, by using a helper function GetTile(x,y) I  find the tile type of that coordinate to determine whether the tile is collidable, and if so what shape. Triangular collisions are not a basic shape in the XNA framework, so worked out an intersection helper function as such: 

public bool Intersects(Circle circle)
{
Vector2 v = circle.Center – Corner;
Vector2 vi = v – (v / v.Length() *
circle.Radius);
Vector2 vii = new Vector2(
vi.X, Offset + (Slope) * vi.X);

float distanceSquared = vi.LengthSquared();
float internalSquared = vii.LengthSquared();

return (distanceSquared < Length*Length
&& distanceSquared <= internalSquared);
}

Anything can be set as a tile in the tile map class. Tiles not only include environmental assets, but also includes classes for npc characters, portals, collectible chemical compounds, and pickups. Colliding into these types of tiles can trigger conversations, battles, teleporting into another map, or unique events. Note that all art assets have been developed my myself in Photoshop and Illustrator.

chemical
portal
pickup
npc

[3] Concept and Future Developments

The rules of the game is based on the rules of chemistry. The “breeding” system between chemicals is based on chemical reactions between organic compounds. The evolution of chemicals is based on the number of carbon atoms in the molecule, and its special abilities are based on the functional groups attached to the chemical. A rudimentary battling and reaction system is applied in the demo, but more content needs to be integrated to flesh the game out. Future developments are upcoming for this project!

Sources

Many thanks to Jamie McMahon for providing informative Monogame tutorials!