Development Blog (semi)random.thoughts()

Experiments

Bye bye callbacks! Combining Combine and SpriteKit

Consider a simulation game. The game probably has some entities, wether it's cities, cells, soldiers or reindeer. Now consider it is a turn based game, where the simulation advances on a "tick" basis. Before and after the tick, the state of the simulation will have changed, so for instance your cells might have a different color and your reindeer might have moved. Your visualization should update accordingly.

Due to the complexity usually involved with simulation models, your modal is probably a self contained unit, that perhaps knows nothing about UI stuff. Or it shouldn't anyway, because why would it care? Can we use Combine with SpriteKit to simulate the "automagical updating" of SwiftUI. Yes we can!

Read More…

[Deprecated] SwiftUI as UI for SpriteKit games

Update 2020-06-23: in Xcode 12, Apple introduced a native solution for integrating SpriteKit and SwiftUI. Learn more here: https://www.hackingwithswift.com/quick-start/swiftui/how-to-integrate-spritekit-using-spriteview

———— Original post follows ————
For my HexMap project, I use SwiftUI to create the game's GUI.

Schermafbeelding 2019-10-31 om 21.47.33

In this tutorial, I'll show (with a simpler) example how I integrate SwiftUI and SpriteKit. Read More…

Loading and saving a game: GameplayKit and Codable protocol

GameplayKit is an Apple provided SDK that contains among others an easy-to-use Entity-Component system. I'm using it in a Roguelike I'm working on in my spare time, which I use to get a better grasp on developing in Swift.

While development in Swift with the Apple provided libraries is generally smooth sailing, getting saving and loading working was a lot more work. While most other features take me a few hours to implement, this one has taken days. This was mainly due to my lack of understanding of GameplayKit and (the limits) of protocol extension in particular. Because I could not found much (not enough for me?) information on this subject online, I'm sharing my experiences and solution here.

By no means is my solution the best, but at least it works. If you know of a better solution, the please let me know.

Read More…

Update: TrueSync no longer in active development

Last December, I did some experiments with deterministic lockstep technology from Photon – TrueSync.

I now learned that this product is no longer in development and will be integrated into their Quantum product. The link to TrueSync now points to the Quantum page. I can no longer find the TrueSync SDK.

You can find more details on their blog post: https://blog.photonengine.com/streamlined-photon-product-portfolio/

Experimenting with deterministic lockstep multiplayer

Years ago I created an experimental multiplayer game using the Unity engine. It couldn’t be simpler:

  • Just control a sphere to try and push the other spheres out of the “arena”;
  • Use Unity to do all the physics heavy lifting;
  • Just sync the rigidbodies across clients.
  • It never worked. And I now understand why it never worked.
Read More…

We value your privacy. This site collects only information required to provide you this Service. For more information, read our privacy policy.