0.1.0
Major 2D Update
This update includes many new and refined elements directed at 2D games!
TileMap
New TileMap and TileSet importers are available for the open source Tiled app's JSON formats.
Completely overhauled TileMap, TileSet, and TileMapComponent. TileMap and TileSet are now resources and can be loaded like a Texture or Geometry:
let tileSet = TileSet(path: "TileSet.tsj")
let tileMap = TileMap(path: "TileMap.tmj")
// Convenince init for TileMapComponent
let entity = Entity(components: [
TileMapComponent(
tileSetPath: "Resources/TileSet.tsj",
tileMapPath: "Resources/TileMap.tmj"
),
])
You can now modify tiles in a TileMapComponent
in real time:
let tileMapCoordinate = TileMap.Layer.Coordinate(column: 10, row: 15)
let newTile = TileMap.Tile(id: tileSetTileID, options: [])
entity[TileMapComponent.self].layers[0].setTile(tile, at: tileMapCoordinate)
TileMapComponent
now supports animations:
entity[TileMapComponent.self].layers[0].animations.append(
TileMapComponent.Layer.TileAnimation(
coordinate: TileMap.Layer.Coordinate(column: 7, row: 12),
frames: [
TileMap.Tile(id: 5, options: []),
TileMap.Tile(id: 6, options: []),
],
duration: 1.5
)
)
StateMachine
A StateMachineComponent and StateMachineSystem are now available.
You can find an in-depth example on StateMachine usage at GateEngineDemos/JRPG.
Scripting
Gravity is now available as a scripting language in GateEngine.
Using Gravity in Swift:
let gravity = Gravity()
// Compile the script
try gravity.compile(scriptURL)
// Run the main function of the gravity script
let result = try gravity.runMain()
// print the result returned from `func main()`
print("Result:", result)
// Get a var by name and print it's value
print(gravity.getVar("myGravityScriptGloabalVar")!)
// Run an existing `func` in the gravity script
try gravity.runFunc("myGravityScriptFunction")
You can find an in-depth example on gravity scripting usage at GateEngineDemos/JRPG.
Keyboard
Keyboard buttons no longer return an optional and the button returned will always represent the key requested.
Previously if you requested a ButtonState for a searchable key, like .shift(.anyVariation) which represents the left or right shift buttons, the button would return either the left shift, right shift, or nil depending on if any were pressed.
Now the button will always be what you requested and will check each variation only when isPressed is checked.
This is a simple intuitive change and you probably expected this to be happening all along, but now it really is happening 😅
// previously
if input.keyboard.button(.shift(.anyVariation))?.isPressed == true { }
// New
if input.keyboard.button(.shift(.anyVariation)).isPressed { }
System
Errors thrown and in resource states are now an instance of GateEngineError
.
This will allow more precise error handling as seen in this example:
if case let .failed(error) = resource.state {
switch error {
case let .failedToLoad(reason):
// Load a different resource
// or change the game to function without this one
default:
fatalError("Unhandled error \(error).")
}
}
GateEngine Demos
New demos are available in the GateEngineDemos repository: