• G
    gamedevbynight

    Yeah the aspect ratio coult possibly change.

    But thanks again Robert, Scaler.transformXDirectly and Scaler.transformYDirectly did the job.

    posted in Kode read more
  • G
    gamedevbynight

    Hi all,

    I have problems with backbuffer, screen resize and mouse position.

    I create a backbuffer for rendering everything in the size 800/600 and then scale it to the framebuffer like in the kha shmup tutorial or in Lewis Leptons Kha Tutorial #23

    	framebuffer.g2.begin();
    	Scaler.scale(backbuffer,framebuffer,System.screenRotation);
    	framebuffer.g2.end();
    

    everything works great!

    I am also using the full-page canvas from the wiki (https://github.com/Kode/Kha/wiki/HTML5)

    Now i want to add a rectangle under the mousecursor on click.
    To calculate the mouse coordinates to the backbuffer coordinates i do

    	var normalizeX:Float = x / System.windowWidth() * Game.backbuffer.width;
    	var normalizeY:Float = y / System.windowHeight() * Game.backbuffer.height;
    

    everything works fine if the backbuffer size = window size.
    if change the windowsize it's acting wrong. What am I missing?

    Here is a Kodegarden example http://kodegarden.org/#193ab6da06c02f70892cc3bfd7a957c8f3efaf41
    just run it and change the size of the browser window.

    or here is a example of my work with the full-page canvas http://jug.korbel.tech/

    Thanks for the tips and help! 🙂

    posted in Kode read more
  • G
    gamedevbynight

    Thanks Robert! That helped! 🙂

    I should have ask earlier... before i put hours in possible workarounds! 😃

    posted in Kode read more
  • G
    gamedevbynight

    I'm using the Method Image.at() and everything works fine in HTML5. When I run the same code with windows target, it doesn't work. The method Image.at() returns 0.

    That's okay, that's what the code is doing on Windows target. Is there any plan to integrate this in teh future for windows targets. Or is there another possibility to get the Pixel information from a Image/Asset?

    Thanks for the help! 🙂

    posted in Kode read more
  • G
    gamedevbynight

    Ah you fixed Kodegarden. So here is my example:
    http://kodegarden.org/#281412cec3c5fc41fc17324233c07548ac5dc456

    In my opinion i should see a blue screen.

    posted in Kode read more
  • G
    gamedevbynight

    I tried Kodegarden, but it stopped working for me. Neither in Chrome, Firefox or Edge I can see anything im writing. And if I download the Project nothing has happend. It's still the code from the beginning. Lubos Lencos Tutorials doesn't work too...

    so here is my short Codeexample:
    package;

      import kha.Color;
      import kha.Framebuffer;
      import kha.System;
      import kha.Scheduler;
      import kha.Image;
      class Main {
    
    static var image:Image;
    
    public static function main() {
    	System.init({title: "Kode Project", width: 800, height: 600}, function() {
            // Avoid passing update/render directly so replacing
            // them via code injection works
    		Scheduler.addTimeTask(function () { update(); }, 0, 1 / 60);
    		System.notifyOnRender(function (framebuffer) { render(framebuffer); });
    
    		image = Image.createRenderTarget(800,600);
    		var g1 = image.g1;
    		g1.begin();
    		for(x in 0 ... 800)
    		{
    			for(y in 0 ... 600)
    			{
    				g1.setPixel(x,y,Color.Black);
    			}
    		}
    		g1.end();
    
    	});
    }
    
    static function update(): Void {
    
    }
    
    static function render(framebuffer: Framebuffer): Void {
        var graphics = framebuffer.g2;
        graphics.begin();
    	graphics.color = Color.Blue;
        graphics.fillRect(0,0,800,600);
    	graphics.drawImage(image,0,0);
        graphics.end();
    }
    

    }

    I would have expected a Bluescreen because I'm drawing an transparent Image on a blue rectangle. All I get is a black screen.

    posted in Kode read more
  • G
    gamedevbynight

    Hm my 2D array had an error. I fixed it and now my Image gets drawn.

    Now I have a new problem.
    Transparent pixel are black and not tranparent is this an issue or is it my fault?

    posted in Kode read more
  • G
    gamedevbynight

    I got a 2D Array for x and y with colorvalues and want to use Graphics1.setPixel() to create a new Image,
    I want to draw this image in my rendermethod.

    This is the Code to load the Image:

        img1 = Image.createRenderTarget(image.width,image.height);
        img1.lock();
        var graphics1 = img1.g1;
        graphics1.begin();
        
        for(x in 0 ... image.width)
        {
            for(y in 0 ... image.height)
            {
                var color:Color = pixels[x][y];
                graphics1.setPixel(x,y,color);
            }
        }
        graphics1.end();
        img1.unlock();
    

    And my renderMethod looks like this:

      public function render(graphics:Graphics)
      {
            graphics.drawImage(img1,0,0);
      }
    

    The graphics in the rendermethod is a graphics2 object.

    my Problem is: Nothing happens. In the debugger the Image of img1 is null.
    Isn't it possible to draw a image with the pixelcolorvalues in Graphics2?

    posted in Kode read more

Looks like your connection to Kode Forum was lost, please wait while we try to reconnect.