Last active
December 7, 2015 21:07
-
-
Save RafaelOliveira/1cb2cb4ab8c13a3cc0d4 to your computer and use it in GitHub Desktop.
Kha without assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import kha.Framebuffer; | |
import kha.graphics2.Graphics; | |
import kha.Image; | |
import kha.input.Keyboard; | |
import kha.Key; | |
import kha.Scaler; | |
import kha.System; | |
class Game | |
{ | |
var backbuffer:Image; | |
var g:Graphics; | |
public function new() | |
{ | |
backbuffer = Image.createRenderTarget(800, 600); | |
g = backbuffer.g2; | |
var k = Keyboard.get(); | |
k.notify(keyDownListener, null); | |
} | |
function keyDownListener(key:Key, char:String):Void | |
{ | |
} | |
public function update():Void | |
{ | |
} | |
public function render(framebuffer:Framebuffer):Void | |
{ | |
framebuffer.g2.begin(); | |
Scaler.scale(backbuffer, framebuffer, System.screenRotation); | |
framebuffer.g2.end(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var project = new Project('Game'); | |
project.addSources('Sources'); | |
return project; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import kha.Scheduler; | |
import kha.System; | |
class Main | |
{ | |
public static function main() | |
{ | |
System.init("Game", 800, 600, initialized); | |
} | |
private static function initialized():Void | |
{ | |
var game = new Game(); | |
System.notifyOnRender(game.render); | |
Scheduler.addTimeTask(game.update, 0, 1 / 60); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment