Skip to content

Instantly share code, notes, and snippets.

roadmap
i can easily call the game "complete" at this point
everything functions, it's playable, the sounds will need another pass but that'll come in in two weeks
* add section on deployment
* add contributor's guide
* add a sound and image asset pack
* add a "final project" project
* revise all the API docs

Project Setup

How should I get started with Kha?

There are two ways to work with Kha, the "haxelib" way and the "standalone" way. The haxelib way is familiar to existing Haxe users. The standalone way allows a project's whole environment to be maintained without accidentially losing important dependencies, and so it is less dependent on the "Haxe ecosystem".

In both cases, your workflow after installation is:

  1. Run khamake to compile the assets and project metadata for a target platform(html5, windows, etc.)
  2. Test and debug using additional compilers and IDEs appropriate to your target(e.g. Visual Studio, Unity editor, browser).

Testing the Project

The preferred targets for Kha development are Flash and HTML5. Debugging functionality and test iteration times are best on these targets. For these targets you may use either your web browser or the standalone Flash Projector.

For a Windows build the most straightforward option is Visual Studio. khabuild will try to autodetect the version you are running and generate a VS solution file for you. Then open the solution in the IDE, select Debug or Release and do debugging and profiling from within VS.

Publishing the Project

You are ready to show your game to somebody, but you need to get it running on their device. This section will depend on your target, but Kha has kept the process simple.

class AssetCacheData {
public var anim_aset : LifeVector<AnimationAsset>;
public var anim_inst : LifeVector<AnimationRenderable>;
public var hscript : Map<String, HScriptModule>;
public var blob : Map<String, Blob>;
public var image : Map<String, Image>;
public var sound : Map<String, Sound>;
public var font : Map<String, Font>;
public var video : Map<String, Video>;
import kha.Assets;
import kha.Image;
import kha.Sound;
import kha.Blob;
import kha.Video;
import kha.Font;
enum KhaAssetRequest {
KARBlob(k : String);
KARImage(k : String);
{
"haxe.haxeDiagnosticDelay": 2000,
"editor.quickSuggestionsDelay": 1000,
"editor.suggestOnTriggerCharacters": false,
"git.enabled": false,
"files.autoSaveDelay": 1000000000
}
package ludamix;
import haxe.ds.Vector;
class T /*toolbox*/
{
public static inline var TAU = 6.28318530718;
public static inline var EPSILON = 0.0000001;
public static inline function lerpF(r0 : Float, r1 : Float, z : Float) : Float { return (r0 + (r1 - r0) * z); }
package ludamix.bmfont;
import haxe.ds.Vector;
import ludamix.bmfont.BMFont;
using ludamix.MapPair;
class BMFontRenderPage<T> {
public var data : BMFontPage;
public var image : T;
@triplefox
triplefox / FlatXML.hx
Created May 29, 2017 10:01
Flattens all the nuances of Haxe's Xml implementation into an enum, where it's much easier to capture data.
import Xml;
/* Flattens all the nuances of Haxe's Xml implementation
into an enum, where it's much easier to capture data. */
enum FlatXMLNode {
Element(
name : String,
attribute : Map<String,String>,
children : Array<FlatXMLNode>);
# initialize a new allegro-pascal project
my $projectname = "newproject";
my $allegropas-src = "allegro.pas-5.2.a3-src-pas/lib";
if $projectname.IO.e {
say "project $projectname already exists";
} else {
mkdir $projectname or die "$!";
try {