Skip to content

Instantly share code, notes, and snippets.

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>;

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.

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).
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
@triplefox
triplefox / Empty.hx
Last active November 10, 2015 07:15
Graphics1 problem
package;
import kha.Framebuffer;
import kha.Game;
import kha.Image;
import kha.Loader;
import kha.Configuration;
import kha.Scaler;
import kha.Color;
#include <stdio.h>
#include <stdlib.h>
int collide(int data[25], int collision_mapping[3]) {
int collision = 0;
int i0 = 0;
for (i0 = 0; i0 < 25; i0++ )
{
collision += collision_mapping[data[i0]];
}
@triplefox
triplefox / gist:a052f52b11b664cce31f
Created March 24, 2015 19:16
Snippets from Urobo
/* Urobo, a videogame engine. Strength through self-reference.
* By James Walter Hofmann.
*/
/***********
ENUMS
***********/
enum AttributeType
{
luastate.register("matchEntity", proc (state : PState):cint {.cdecl.} =
var i1 = (state.tointeger(-1)); state.pop(1)
var i0 = (state.tointeger(-1)); state.pop(1)
if not game.matchtile:
let arch0 = game.entity[game.matcha].d[0]
let arch1 = game.entity[game.matchb].d[0]
if (arch0 == i0 and arch1 == i1):
state.pushboolean(cint(true))
discard """
Slactuate - a rude tweening library.
Copyright © 2015 James W. Hofmann
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense,
type Thing = ref object
x* : float
var t0 : Thing; new(t0);
var r0 : ref float = cast[ref float](addr(t0.x))
t0.x = 10.0
doAssert(r0[] == 10.0)