Advertisement
Guest User

Untitled

a guest
May 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.58 KB | None | 0 0
  1. package;
  2.  
  3. import kha.Framebuffer;
  4. import kha.Color;
  5. import kha.Image;
  6. import kha.Scaler;
  7. import kha.System;
  8.  
  9. class Project {
  10.     public static inline var screenWidth = 800;
  11.     public static inline var screenHeight = 600;
  12.     private static var bgColor = Color.fromValue(0x000000);
  13.     private var backBuffer:Image;
  14.     private var initialized:Bool = false;
  15.     private var frames:Int;
  16.     private var x:Float;
  17.     private var not:Bool;
  18.    
  19.     public function new()
  20.     {
  21.         /*
  22.         System.notifyOnRender(render);
  23.         Scheduler.addTimeTask(update, 0, 1 / 60);
  24.        
  25.         Assets.loadEverything(function()
  26.         {
  27.             initialized = true;
  28.             //font = Assets.fonts.Inconsolata_Regular;
  29.             //trace(font.height(24));
  30.  
  31.            
  32.  
  33.         });
  34.         */
  35.  
  36.         backBuffer = Image.createRenderTarget(screenWidth, screenHeight);
  37.        
  38.     }
  39.  
  40.     public function update():Void
  41.     {
  42.         if(not)
  43.         {
  44.             x = not ? screenWidth / 2 : -screenWidth / 2;
  45.             not = !not;
  46.         }
  47.     }
  48.  
  49.     public function render(framebuffer:Framebuffer): Void
  50.     {
  51.         /*if (!initialized)
  52.         {
  53.             trace("Initializing...?");
  54.             return;
  55.         }*/
  56.  
  57.         frames += 1;
  58.  
  59.         // clear our backbuffer using graphics2
  60.         var g = framebuffer.g2;
  61.         g.begin();
  62.         g.clear(bgColor);
  63.  
  64.         //g.font = font;
  65.         //g.fontSize = 24;
  66.         g.color = Color.fromValue(0xFF0000); // red text
  67.  
  68.         //sg.drawString("Hello, world!", 50, 20); // Draw "Hello, World!" at (50, 20)
  69.        
  70.         g.drawRect(x,200, 100, 20);
  71.         g.drawLine(x,10,200,100);
  72.        
  73.  
  74.         g.end();
  75.  
  76. /*
  77.         framebuffer.g2.begin();
  78.         Scaler.scale(backBuffer, framebuffer, System.screenRotation);
  79.         framebuffer.g2.end();
  80.         */
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement