Skip to content

inc0der/khapunk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Khapunk

Khapunk is a port of Haxepunk ( which is a port of Flashpunk... )
Haxepunk credits go to : Matt Tuttle

Make sure you read the Wiki pages

Khapunk is currently under development!. But please fork and improve!

Should work on every kha backend as long they are up to date.

  • Tested on
    • HTML5
    • Android
    • Windows (DX9 and OpenGL)
    • Any up to date backend should work.

TODO

  • Input

    • Mouse and keyboard
    • Joystick/Gamepad
    • Touchsupport
  • Masks are done except for Pixel based masks...I have to figure that one out

  • All Graphic object

    • Graphic
    • Tilemap
    • Spritemap & Atlasmap*
    • Graphicslist
    • PunkImage ( Originally known as Image )
    • Backdrop
    • Emitter
    • Particle/Particletype
    • TiledImage
    • [0] TiledSpritemap
    • Text
  • Debug console

  • Create example pack

###How To:###

#!haxe

package;

import com.khapunk.Engine;
import com.khapunk.Entity;
import com.khapunk.graphics.PunkImage;
import com.khapunk.KP;
import com.khapunk.Scene;
import kha.Game;
import kha.Canvas;
import kha.Loader;

class Empty extends Game {
	
	var engine:Engine;
	var kpScene:Scene;
	var ent:Entity;

	
	public function new() {
		engine = new Engine();
		super("KhaPunk");
	}
	
	override public function update():Void 
	{
		engine.update();
	}
	
	override public function render(buffer:Framebuffer):Void 
	{
		engine.render();
	
		//Scale and draw our backbuffer into our screen buffer.
		startRender(buffer);
		Scaler.scale(Engine.backbuffer, buffer, kha.Sys.screenRotation);
		endRender(buffer);
		
	}
	
	override public function init():Void 
	{
		engine.setup();
		Loader.the.loadRoom("MyRoom", onLoaded);
	}
	
	function onLoaded() : Void
	{
		//Create scene;
		kpScene = new Scene();
		//Init a graphic object
		var g:PunkImage = new PunkImage(Loader.the.getImage("myImage"));
		//create entity and add graphic
		//Set this entities graphic to g
		ent = new Entity(100, 100, g);
		//Add entity to scene
		kpScene.add(ent);
		//Set current scene
		KP.scene = kpScene;
	}
	
	
}

###Shaders###

With Graphics2 and Graphics4 Khapunk is able to use shaders with ease. To use a shader simply compile and link your shader:

#!haxe

	//Program object
	var myProgram:Program = new Program();
	myProgram.setVertexShader(new VertexShader(Loader.the.getShader("vertex.vert")));
	myProgram.setFragmentShader(new FragmentShader(Loader.the.getShader("fragment.frag")));
	
	//Standard kha vertex shader attributes
	//Check kha/Shaders/painter-image.vert.glsl for example
	var structure:VertexStructure = new VertexStructure();
	myProgram.add("vertexPosition", VertexData.Float3);
	myProgram.add("texPosition", VertexData.Float2);
	myProgram.add("vertexColor", VertexData.Float4);
		
	//Links and compiles our shader
	program.link(structure);
		

Then simply assign the program to your graphics:

#!haxe

	myBuffer.g2.begin();

	myBuffer.g2.program = myProgram;
	//set uniform
	myBuffer.g4.setFloat(
		myProgram.getConstantLocation("myUniform"),
		10.0
	);

	
	//Drawcalls
	myBuffer.g2.end();
	

Your shaders should be placed in projectRoot/Sources/Shaders/

Shaders should have the naming convention: myFrag.frag.glsl and myVert.vert.glsl respectively.
To load your shader use Loader.the.getShader with ".glsl" omitted.


Tiled

tmx loader can be found here https://bitbucket.org/stalei/khapunktiled

Nape physics

Nape scene and entity can be found here https://bitbucket.org/stalei/khapunk-nape/


Check out the Demo!


MIT License

Copyright (C) 2014 Sidar Talei

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

a port of HaxePunk, itself a port of FlashPunk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haxe 94.8%
  • GLSL 5.2%