Skip to content

Instantly share code, notes, and snippets.

View jonathanhirz's full-sized avatar

Jonathan jonathanhirz

View GitHub Profile
@jonathanhirz
jonathanhirz / tiled_property
Created January 22, 2017 00:58
tiled_property
static public function tiled_tile_has_property( _tilemap:TiledMap, _layer:String, _position_x:Float, _position_y:Float, _property:String ) : Bool {
var tile_coordinates = _tilemap.tile_coord(_position_x, _position_y);
if(_tilemap.inside(Std.int(tile_coordinates.x), Std.int(tile_coordinates.y))) {
var current_tile_id : Int = _tilemap.tile_at_pos(_layer, _position_x, _position_y).id - 1;
for(tiled_tileset in _tilemap.tiledmap_data.tilesets) {
for(tiled_tile in tiled_tileset.property_tiles) {
if(current_tile_id == tiled_tile.id) {
return tiled_tile.properties.exists(_property);
}
@jonathanhirz
jonathanhirz / Main.hx
Last active May 28, 2016 23:28
Luxe.renderer.clear_color
override function ready() {
Luxe.renderer.clear_color = new Color().rgb(0x57a4f3);
} //ready
@jonathanhirz
jonathanhirz / hxcpp_crash
Created December 16, 2015 01:29
crash report - release builds crash on run, OS X
Process: adrifter [32903]
Path: /Users/USER/*/adrifter.app/Contents/MacOS/adrifter
Identifier: com.jonathanhirz.adrifter
Version: 0.0.1 (1)
Code Type: X86-64 (Native)
Parent Process: node-mac [32205]
Responsible: Terminal [340]
User ID: 501
Date/Time: 2015-12-15 17:28:33.031 -0800
@jonathanhirz
jonathanhirz / Monster.hx
Created August 22, 2015 20:49
monster_movement
override function update(dt:Float) {
velocity.x += acceleration.x * dt;
monster.pos.x += velocity.x * dt;
velocity.y += acceleration.y * dt;
monster.pos.y += velocity.y * dt;
if(Luxe.input.inputdown('right')) {
acceleration.x = move_speed;
}
override function update(dt:Float) {
if(Luxe.time - count_time > 0.5) {
count_time = Luxe.time;
fps_text.text = 'FPS: ' + Std.int(1.0 / Luxe.dt);
}
} //update
import luxe.options.GeometryOptions;
import luxe.Vector;
import phoenix.Batcher;
import phoenix.geometry.Geometry;
import phoenix.geometry.Vertex;
class TriangleGeometry extends Geometry {
public function new(?options: TriangleOptions) {
@jonathanhirz
jonathanhirz / PlayState.hx
Created June 30, 2015 21:11
gesluxe zoom gesture work around
override function onenter<T>( _value:T ) {
earth = new Sprite({
texture : earth_texture,
pos : new Vector(Luxe.screen.w/2, Luxe.screen.h),
});
transformGesture = new TransformGesture();
transformGesture.events.listen(GestureEvent.GESTURE_BEGAN, onTransformGesture);
transformGesture.events.listen(GestureEvent.GESTURE_CHANGED, onTransformGesture);
for(layer in map1.layers) {
if(layer.name == 'collider') {
layer.visible = false;
}
}
override function config(config:luxe.AppConfig) {
config.preload.textures.push({ id:'assets/star.png' });
config.preload.textures.push({ id:'assets/ship.png' });
config.preload.textures.push({ id:'assets/beam.png' });
return config;
} //config
// -=COLLISION RESOLUTION =-
results = Collision.testShapes(sprite_collider, Main.block_collider_pool);
for(collision in results) {
trace(collision.unitVector);
if(draw_collider) {
debug_text.visible = true;
debug_text.text = 'separation: ' +collision.separation;
} else {
debug_text.visible = false;
}