-
Notifications
You must be signed in to change notification settings - Fork 10
1. Opening a window
Let's see how to setup Kha and get a blank screen to show up. The reference tutorial is not really needed here since Kha handles this stuff for us perfectly.
To use Kha we need git and node. Afterwards, open a terminal/command line (preferably in empty directory to keep things clean) and clone empty project:
git clone --recursive https://github.com/Kha-Samples/Empty
If you are looking for an IDE, get Kode Studio which comes fully packed for Kha development. Afterwards you can drag and drop the cloned folder into Kode Studio.
Next, go to /Sources
directory and open Empty.hx
. We will add a rendering function that just clears the screen.
package;
import kha.Framebuffer;
import kha.Color;
class Empty {
// ..
public function render(frame:Framebuffer) {
// A graphics object which lets us perform 3D operations
var g = frame.g4;
// Begin rendering
g.begin();
// Clear screen to black
g.clear(Color.Black);
// End rendering
g.end();
}
// ...
}
You can access complete sources here.
Now on to running our code - simply drag and drop the project folder into Kode Studio and hit Run(F5).
Alternatively, we can build the project manually - open terminal/command line in project folder(where your khafile.js
resides). With Kha you can target pretty much every platform out there, but for simplicity let's do HTML5 build. To build, type:
node Kha/make html5
To start local server, type:
node Kha/make --server
Open 127.0.0.1:8080
in your browser and black screen will show up!