Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package;
- import kha.Framebuffer;
- import kha.Color;
- import kha.Image;
- import kha.Scaler;
- import kha.System;
- import kha.Scheduler;
- import kha.Assets;
- class Project {
- public static inline var screenWidth = 800;
- public static inline var screenHeight = 600;
- private static var bgColor = Color.fromValue(0x000000);
- private var backBuffer:Image;
- private var initialized:Bool = false;
- private var frames:Int;
- private var x:Float;
- private var not:Bool;
- public function new()
- {
- System.notifyOnRender(render);
- Scheduler.addTimeTask(update, 0, 1 / 24);
- Assets.loadEverything(function()
- {
- initialized = true;
- //font = Assets.fonts.Inconsolata_Regular;
- //trace(font.height(24));
- });
- backBuffer = Image.createRenderTarget(screenWidth, screenHeight);
- }
- public function update():Void
- {
- if(not)
- {
- x = not ? screenWidth / 2 : -screenWidth / 2;
- not = !not;
- }
- }
- public function render(framebuffer:Framebuffer): Void
- {
- /*if (!initialized)
- {
- trace("Initializing...?");
- return;
- }*/
- trace("Initializing...?");
- frames += 1;
- // clear our backbuffer using graphics2
- var g = framebuffer.g2;
- g.begin();
- g.clear(bgColor);
- //g.font = font;
- //g.fontSize = 24;
- g.color = Color.fromValue(0xFF0000); // red text
- //sg.drawString("Hello, world!", 50, 20); // Draw "Hello, World!" at (50, 20)
- g.drawRect(10,200, 100, 20);
- g.drawLine(10,10,200,100);
- g.end();
- /*
- framebuffer.g2.begin();
- Scaler.scale(backBuffer, framebuffer, System.screenRotation);
- framebuffer.g2.end();
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement