Skip to content

Instantly share code, notes, and snippets.

View RafaelOliveira's full-sized avatar

Rafael Oliveira RafaelOliveira

View GitHub Profile
@RafaelOliveira
RafaelOliveira / layer_atlas.py
Last active April 21, 2017 08:32
Python script for Gimp to save the layers info in a file like a texture atlas
#!/usr/bin/python
# How to use:
# In Windows and Linux there is .gimp-xx folder in your home folder
# save the file in .gimp-xx/plug-ins/
# For Mac search in Google where to save Gimp plugins
# The menu is Image -> Save layer atlas
from gimpfu import *
@RafaelOliveira
RafaelOliveira / Screenshot.hx
Created March 24, 2017 19:01
Create a screenshot in Kha (only HTML5)
// Ported from https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.tools.ts
// Don't seems to work in KodeStudio, only in a browser.
// It creates a new window with the image. If you can't save the image, try to right click in the image
// and choose to open in a new tab.
#if js
package;
import js.html.Window;
package;
import kha.Color;
import kha.Image;
import kha.System;
import kha.graphics2.Graphics;
class Backdrop
{
public var image:Image;
@RafaelOliveira
RafaelOliveira / Project.hx
Created January 9, 2017 15:16
structInit
package;
import kha.Framebuffer;
import kha.Scheduler;
import kha.System;
import kha.Image;
@:enum
abstract T0(Int) {
var a = 0;
function render(framebuffer: Framebuffer): Void {
var w1 = framebuffer.width / 2;
var h1 = framebuffer.height / 2;
var w2 = framebuffer.width / 3;
var h2 = framebuffer.height / 3;
var w3 = framebuffer.width / 6;
var h3 = framebuffer.height / 6;
@RafaelOliveira
RafaelOliveira / Rectangle.hx
Last active June 4, 2017 02:52
Method to check collision and separate two rectangles
package;
class Rectangle
{
public var x: Float;
public var y: Float;
public var width: Int;
public var height: Int;
public function new(x:Float = 0, y:Float = 0, width:Int = 0, height:Int = 0):Void
@RafaelOliveira
RafaelOliveira / ButtonCallback.hx
Last active July 28, 2016 19:40
A button that call a function when clicked
class Button
{
public var x:Int;
public var y:Int;
public var width:Int;
public var height:Int;
public var onClick:Void->Void;
public function new(x:Int, y:Int, width:Int, height:Int)
{
@RafaelOliveira
RafaelOliveira / Game.hx
Last active December 7, 2015 21:07
Kha without assets
package;
import kha.Framebuffer;
import kha.graphics2.Graphics;
import kha.Image;
import kha.input.Keyboard;
import kha.Key;
import kha.Scaler;
import kha.System;
package;
import js.Browser;
import js.html.TouchEvent;
class JsTouch
{
public static var down:Bool = false;
public static var move:Bool = false;
public static var x:Float;
@RafaelOliveira
RafaelOliveira / gist:86ee9bde7f9b3921b955
Last active July 28, 2016 19:48
OpenFL native extensions for Mobile Apps
Battery Status:
Camera: https://github.com/bazzisoft-openfl-extensions/camera
Contacts:
Device Info: https://github.com/hyperfiction/HypSystem (not tested)
Device Motion (Accelerometer):
Device Orientation (Compass):
Geolocation:
Open Browser: https://github.com/bazzisoft-openfl-extensions/interop
Media Playback:
Media Capture: