horizon.tech

Building a Two-Player Game with Horizon

In this tutorial we'll show you how to build a two-player game with Horizon.

Horizon can even be used as a game engine. Imagine a game with a fixed game board representing a map. The map has various circles with a value. Each user has a fixed set of resources--game pieces and values. Here's how to use Horizon to differentiate roles between two players--for example, giving players the ability to place 'pieces' on a board, moving through a game state from start to victory condition.

Step 1: Assemble your game board

Your game board can be on the blank canvas or the map. Make sure you set a maximum zoom level and a center snapshot to restrict the game board. Remember that each table allows you to add 2D markers and even 3D symbols.

Step 2: Build the 'board location' and 'user state' tables

Board locations and space types might represent different places for game pieces that might be used by a user to accumulate points, etc. The main key is that each type with distinct logic is attached to a different table, with the schemas representing the necessary data for each.

Users will likely each have a card representing their state--hands in a deck, a point counter, etc. These can be stored and made available.

Step 3: Create a plugin that maps player 1 and player 2 as a user within a simulation.

Horizon's upcoming feature will allow data mapping not just between a plugin and a space, but between a plugin and each simulation. Spaces might have the same starting state, simulations can store distinct states within memory.

Here you create a plugin that allows for each simulation to map a user to each player. Player 1 and 2.

Step 4: Create turn menus with buttons

In a given turn a user might have the opportunity to perform certain actions. For any actions which require unique UI at a certain turn, make the UI sample which allows the user to make the action.

Step 5: Trigger the game start in a simulation, storing initial state.

Your plugin should trigger a game beginning with a simulation being started. On each simulation start, one player's session will likely require an update. The turn order has to be tracked in your plugin so that user actions only cause changes when it is the player's turn to make a move (some games aren't turn based, in any case user actions must be tracked per user and changes must be made to specific user sessions).

Step 6: Make changes to game state and set the win condition at any point

Each hook will likely make changes to the game state, ensuring that the game evolves along its path. Additionally, your plugin will need to check the win condition in order to declare a winner a victory.

Step 7 (optional): Store game results and delete simulations on game completion.

Your game space or workspace is an ideal location to store game results, such as win-loss ratios, players, and game results.

Step 8 (optional): Share your game.

You can share your game with a starting map by making your space and plugin available for download, or allow for multiple maps by only sharing the plugin. You can even sell your game, either within our official plugin and app store or managed on your own!

horizon.tech

A low-code platform for data collection, schema management, data visualization, and publishing.

© 2024 - 2025 Yrbia LLC, Delaware. All rights reserved.