Skip to content

Instantly share code, notes, and snippets.

View jonathanhirz's full-sized avatar

Jonathan jonathanhirz

View GitHub Profile
results = Collision.testShapes(sprite_collider, Main.block_collider_pool);
for(collision in results) {
if(collision.separation.y > 0) {
sprite.pos.y = collision.shape2.position.y - 10 - sprite.size.y/2;
v_velocity = 0;
is_in_air = false;
}
}
@jonathanhirz
jonathanhirz / Main.hx
Created April 4, 2015 21:26
function(res)
function load_isometric_tiledmap() {
Luxe.loadText('assets/isotiles.tmx', function(res){
tiled_iso = new TiledMap( { tiled_file_data:res.text, pos : new Vector(256,128) } );
@jonathanhirz
jonathanhirz / ComponentShip.hx
Created March 1, 2015 00:11
collider fixed!
var flameHitResults : Array<CollisionData> = Collision.testShapes(engineDamageFlameCollider, StateGamePlay.asteroidColliderPool);
if(flameHitResults.length > 0) {
for(hit in flameHitResults) {
for(asteroid in StateGamePlay.asteroidPool) {
if(hit.shape2.name == asteroid.name) {
asteroid.destroy();
asteroid = null;
StateGamePlay.asteroidColliderPool.splice(StateGamePlay.asteroidColliderPool.indexOf(hit.shape2), 1);
hit.shape2.destroy();
}
@jonathanhirz
jonathanhirz / ComponentShip.hx
Created February 28, 2015 23:59
collider stuff
// finally some collision checks!!
var shipHitResults : Array<CollisionData> = Collision.testShapes(shipCollider, StateGamePlay.asteroidColliderPool);
if(shipHitResults.length > 0) {
shipHitCount++;
trace("ship hit " + shipHitCount);
}
var flameHitResults : Array<CollisionData> = Collision.testShapes(engineDamageFlameCollider, StateGamePlay.asteroidColliderPool);
if(flameHitResults.length > 0) {
for(hit in flameHitResults) {
for(asteroid in StateGamePlay.asteroidPool) {
:base {
center-x: screen.center-x;
center-y: screen.center-y;
w: <= screen.w * 0.6;
h: <= screen.h * 0.6;
w: >= 280;
w: <= 500;
h: >= 160;
@jonathanhirz
jonathanhirz / ColorTweenComponent
Last active August 29, 2015 14:07
ColorTweenComponent()
import luxe.Component;
import luxe.Sprite;
import luxe.Color;
import luxe.Vector;
import luxe.tween.Actuate;
class ColorTweenComponent extends Component {
var sprite : Sprite;
@jonathanhirz
jonathanhirz / ColorRollComponent()
Created October 11, 2014 00:42
ColorRollComponent()
import luxe.Component;
import luxe.Sprite;
import luxe.Color;
import luxe.Vector;
import luxe.tween.Actuate;
class ColorRollComponent extends Component {
var sprite : Sprite;
var rad : Float = 0;
@jonathanhirz
jonathanhirz / starFieldLuxe3
Last active August 29, 2015 14:07
starFieldLuxe3
import luxe.Component;
import luxe.Sprite;
import luxe.Color;
import luxe.Vector;
import luxe.utils.Maths;
class StarComponent extends Component {
var sprite : Sprite;
@jonathanhirz
jonathanhirz / starFieldLuxe2
Created October 9, 2014 05:29
starFieldLuxe2
override function ready() {
for(i in 0...numberOfStars) {
starSprite = new Sprite({
name : 'star'+i,
size : new Vector(16, 16),
rotation_z : 45.0,
color : new Color().rgb(0xffffff),
pos : new Vector(Std.random(Std.int(Luxe.screen.w)), Std.random(Std.int(Luxe.screen.h)))
}); //starSprite
@jonathanhirz
jonathanhirz / starFieldLuxe1
Last active August 29, 2015 14:07
starFieldLuxe1
var starSprite : Sprite;
var numberOfStars : Int = 300;