All Projects → Hexworks → Mixite

Hexworks / Mixite

Licence: apache-2.0
A GUI agnostic hexagonal grid library. Supports a multitude of grid layouts including hexagonal, triangular, rectangular and more.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Mixite

Egui
egui: an easy-to-use immediate mode GUI in pure Rust
Stars: ✭ 5,980 (+3376.74%)
Mutual labels:  game-development
Rhubarb
A WebSocket library optimized for multiplayer JS games, works on WebWorkers with binary data.
Stars: ✭ 167 (-2.91%)
Mutual labels:  game-development
Dinocompose
Chrome's Dino T-Rex game developed in Jetpack Compose
Stars: ✭ 170 (-1.16%)
Mutual labels:  game-development
Ebitenui
User interface engine and widget library for Ebiten
Stars: ✭ 159 (-7.56%)
Mutual labels:  game-development
Awesome Wgpu
A curated list of wgpu code and resources.
Stars: ✭ 162 (-5.81%)
Mutual labels:  game-development
Netcode
A protocol for secure client/server connections over UDP
Stars: ✭ 2,121 (+1133.14%)
Mutual labels:  game-development
React Native Game Engine
A lightweight Game Engine for React Native 🕹⚡🎮
Stars: ✭ 2,114 (+1129.07%)
Mutual labels:  game-development
Opentk
The Open Toolkit library is a fast, low-level C# wrapper for OpenGL, OpenAL & OpenCL. It also includes windowing, mouse, keyboard and joystick input and a robust and fast math library, giving you everything you need to write your own renderer or game engine. OpenTK can be used standalone or inside a GUI on Windows, Linux, Mac.
Stars: ✭ 2,284 (+1227.91%)
Mutual labels:  game-development
Porymap
Map editor for pokeemerald, pokefirered, and pokeruby
Stars: ✭ 164 (-4.65%)
Mutual labels:  game-development
Expo Voxel
🎮🌳 Voxel Terrain made in React Native. ∛
Stars: ✭ 169 (-1.74%)
Mutual labels:  game-development
Rubeus
A cross platform 2D game engine written in C++ for beginners
Stars: ✭ 159 (-7.56%)
Mutual labels:  game-development
Unitypausemenu
This is an open source Unity pause menu created for the game New Horizons, and it's completely free because of how a pause menu is a core component of a game, while the unity asset store was lacking in such an asset (until this was released on the asset store).
Stars: ✭ 160 (-6.98%)
Mutual labels:  game-development
Slither.io Clone
Learn how to make Slither.io with JavaScript and Phaser! This game clones all the core features of Slither.io, including mouse-following controls, snake collisions, food, snake growth, eyes, and more. Progress through each part of the source code with our Slither.io tutorial series.
Stars: ✭ 168 (-2.33%)
Mutual labels:  game-development
Ecs
Thoughts about entity-component-system
Stars: ✭ 158 (-8.14%)
Mutual labels:  game-development
Rimlight
Customizable rimlight shader for Unity that includes pulsation and noise scrolling. Give your scenes that extra oomph!
Stars: ✭ 170 (-1.16%)
Mutual labels:  game-development
Fxgl
Stars: ✭ 2,378 (+1282.56%)
Mutual labels:  game-development
Awesome Love2d
A curated list of amazingly awesome LÖVE libraries, resources and shiny things.
Stars: ✭ 2,191 (+1173.84%)
Mutual labels:  game-development
04 battletank
An open-world head-to-head tank fight with simple AI, terrain, and advanced control system in Unreal 4. (ref: BT_URC) http://gdev.tv/urcgithub
Stars: ✭ 172 (+0%)
Mutual labels:  game-development
Alimer
Cross-platform game engine.
Stars: ✭ 172 (+0%)
Mutual labels:  game-development
Unity resources
A list of resources and tutorials for those doing programming in Unity.
Stars: ✭ 170 (-1.16%)
Mutual labels:  game-development

Mixite

Mixite is a hexagonal grid library. The motivation behind it is to have an optimized, simple and usable library for drawing hexagonal grids without being tied to any GUI framework.

This means that you can use Mixite on Android, your backend or your desktop app.

There is a REST-based web example which you can tinker with here. (not recommended, this is under rewrite)

You can also check out the mixite.example.swt project here.

Mixite currently supports a maximum grid size of 1000 * 1000 (1.000.000 cells) with the default implementation but you can provide your own storage implementation to alleviate this limitation.

Disclaimer for Java users: There is no need to worry, Mixite works in exactly the same way as Hexameter worked before. Java interop is seamless, you only have to change the imports / project dependency.

As always with Maven Central artifacts: previous versions of Hexameter also work, they are not affected.


Need info? Ask us on Discord | or Create an issue | Support us on Patreon


Getting started

This library uses Amit's guide to hexagonal grids. The coordinate system used by this library is the Cubic coordinate system. Please check here for further details.

Hexagonal grids come in flat topped and pointy topped shapes. The grid can have several layouts:

  • Hexagonal: the width and height of a this layout has to be equal and both have to be an odd number.
  • Triangular: the width and height of a this layout has to be equal.
  • Rectangular: no special rules
  • Trapezoid: no special rules
  • Custom: your own implementation of GridLayoutStrategy

All layouts have width and height values of at least 1. You can consult HexagonalGridLayout if you need further details.

This library is not tied to any GUI implementation. All operations provided by the API work using the most abstract concept possible.

Basic usage

Importing Mixite

Let's start by adding Mixite as a dependency.

Maven

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url> <!-- Mixite uses Jitpack repository -->
  </repository>
</repositories>
...
<dependency>
  <groupId>com.github.Hexworks.mixite</groupId>
  <artifactId>mixite.core-jvm</artifactId>
  <version>2018.2.0-RELEASE</version>
</dependency>

Gradle

allprojects {
  repositories {
    maven { url 'https://jitpack.io' } // Mixite uses Jitpack repository
  }
}
...
dependencies {
  implementation 'com.github.Hexworks.mixite:mixite.core-jvm:2018.2.0-RELEASE'
}

Note that if you are using Javascript you need mixite.core-web: 'org.hexworks.mixite:mixite.core-web:2018.2.0-RELEASE'

You can also use the latest preview versions, more info here.

Creating a grid

You can use the HexagonalGridBuilder to create a HexagonalGrid:

HexagonalGridBuilder<DefaultSatelliteData> builder = new HexagonalGridBuilder<>()
  .setGridHeight(9)
  .setGridWidth(9)
  .setGridLayout(HexagonalGridLayout.RECTANGULAR)
  .setOrientation(HexagonOrientation.FLAT_TOP)
  .setRadius(30.0);
HexagonalGrid<DefaultSatelliteData> grid = builder.build();

You can also use it to create a HexagonalGridCalculator for you which supports advanced operations on HexagonalGrids:

HexagonalGridCalculator<DefaultSatelliteData> calc = builder.buildCalculatorFor(grid);
calc.calculateDistanceBetween(sourceHex, targetHex)

Drawing a grid

Method Grid.getHexagons returns an iterable collection of hexagons. Each Point represents a coordinate in 2D space that can be transformed for rendering.

for (Hexagon<DefaultSatelliteData> hexagon : grid.getHexagons()) {
  for(Point p : hexagon.getPoints()) {
    // Do you stuff with point.coordinateX, point.coordinateY
  }
}

Manipulating your grid

There are basically only one operation for manipulating your data on the grid: The Hexagon#setSatelliteData(T data) operation with which you can add your own arbitrary data to a Hexagon object. This means that once created a HexagonalGrid is immutable apart from the satellite data you add.

There is also a HexagonalGrid#clearSatelliteData() method for clearing all satellite data from your grid.

The implementation of the HexagonalGrid is lazy. This means that it only stores data which is absolutely necessary to keep in memory (the coordinates and your satellite data). Everything else is generated on the fly. The only limiting factor of a grid at the moment is the coordinates (which consume memory) and the satellite data.

GUI example:

You can find a simple GUI example in the mixite.example.swt project. Run it by doing the following steps.

  1. Clone the project: git clone [email protected]:Hexworks/mixite.git
  2. cd to the newly created mixite folder: cd mixite/
  3. build the project: ./gradlew clean build (or gradlew clean build on Windows)
  4. run the created uberjar: java -jar mixite.example.swt/build/libs/mixite.example.swt.jar

Supported operations

  • Querying the characteristics of the HexagonGrid
  • Fetching all the Hexagon objects from the grid
  • Getting a subset of Hexagons (using cube or offset coordinate range) from the grid
  • Checking whether a Hexagon is on a grid or not
  • Getting a Hexagon by its grid coordinate (cube)
  • Getting a Hexagon by its pixel coordinate
  • Getting the neighbors of a hexagon (also by index)

Advanced operations

  • Calculating the distance between two Hexagons
  • Calculating the movement range from a Hexagon to an other
  • Rotating a Hexagon
  • Calculating a ring from a Hexagon
  • Draw a line from a Hexagon to an other
  • Checking visibility of a Hexagon from an other
  • Adding custom data to a Hexagon
  • Clearing all custom data from the HexagonalGrid

Check these interfaces for more details:

Usage tips

  • You can add satellite data (any arbitrary data you have) to a Hexagon. By implementing the SatelliteData interface you gain operations like visibility checking
  • Mixite comes with a sensible default implementation of SatelliteData so if you don't want to add extra data you can use DefaultSatelliteData.
  • You can use your own implementation of HexagonDataStorage for storing your Hexagons
  • Mixite comes with a sensible DefaultHexagonDataStorage implementation which stores all data in memory
  • You don't have to fetch all Hexagon objects by using the getHexagons method. You can query Hexagons by a range using offset or cube coordinates

Road map

  • Path finding with obstacles (blocking movement)
  • Movement range with obstacles and movement cost calculation
  • Android example

License

Mixite is made available under the Apache2 License.

Credits

Mixite is created and maintained by Adam Arold

I'm open to suggestions, feel free to comment or to send me a message. Pull requests are also welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].