Skip to content

Instantly share code, notes, and snippets.

View KinoAR's full-sized avatar
🏠
Working from home

Kino KinoAR

🏠
Working from home
View GitHub Profile
@KinoAR
KinoAR / ExternExample.hx
Created April 18, 2021 13:15
Example extern class taking from our own LunaTea development code.
package;
//Expose metatag is used to make sure that when the code is being referenced in the target language it'll be exposed
//for user's to override. I use this in JS to allow for modification, which is core to RPGMakerMV/MZ.
//Native metatag is used to make sure that when the code is compiled it uses the proper name.
//Native works both on classes and fields, which you can see for the x, y fields below.
@:expose("Point")
@:native("Point")
extern class Point extends pixi.core.math.Point {
/**
@KinoAR
KinoAR / PathingExample.hx
Created April 11, 2021 17:21
How To Setup Pathing For a FlxSprite
import flixel.util.FlxPath;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.util.FlxColor;
class Player extends FlxSprite {
public var walkPath:Array<FlxPoint>;
public function new(x:Float, y:Float) {
super(x, y);
@KinoAR
KinoAR / BuildMacroExample.hx
Created March 29, 2021 00:07
Build Macro Example in HaxeFlixel
package;
// Path to your own depot file
@:build(macros.DepotMacros.buildDepotFile('assets/data/database.dpo'))
class DepotData {}
@KinoAR
KinoAR / CollisionDetection.hx
Last active March 26, 2021 02:45
HaxeFlixel collision detection with groups example.
import flixel.FlxState;
import flixel.group.FlxGroup;
import flixel.FlxSprite;
import flixel.FlxG;
import flixel.util.FlxColor;
class PlayState extends FlxState {
//Creating the player, enemies, and npc group.
public var npcs:FlxTypedGroup<FlxSprite>;
public var enemies:FlxTypedGroup<FlxSprite>;
@KinoAR
KinoAR / InvincibilityDemo.hx
Last active March 17, 2021 22:04
Haxe Flixel invincibility demo on a player character.
import flixel.util.FlxColor;
import flixel.FlxSprite;
class Player extends FlxSprite {
// Whether the player is invicible or not
public var isInvincible:Bool;
//The amount of time to be invincible for in seconds
public static inline var INVINCIBLE_TIME:Float = 1.5;
@KinoAR
KinoAR / PauseSubState.hx
Created March 6, 2021 22:03
An example of a pause menu in HaxeFlixel. Note this won't just work in your game as it contains custom code.
package game.states;
import game.ui.TextButton;
/*
* Custom Pause Scene I made for my game.
*/
class PauseSubState extends FlxSubState {
public var pauseText:FlxText;
private var pauseExitSound:FlxSound;
@KinoAR
KinoAR / PlayState.hx
Created March 6, 2021 21:54
New scene in HaxeFlixel created using PlayState as an example.
/**
* Basic example of a scene used in the tutorial for HaxeFlixel as well.
*/
class PlayState extends FlxState {
override public function create() {
super.create();
add(new FlxText('Hello World', 32).screenCenter());
}
override public function update(elapsed:Float) {
super.update(elapsed);
@KinoAR
KinoAR / Main-New.hx
Created February 28, 2021 21:41
An example of creating a main entry point in Haxe in 4.2
//Module Level Main entry point in Haxe 4.2.0
function main() {
trace('Hello World');
}
@KinoAR
KinoAR / Main-Old.hx
Created February 28, 2021 21:39
Old way of creating a main entry point in Haxe
//Example of a main entry point in Haxe before 4.2
class Main {
public static function main() {
trace('Hello World');
}
}
@KinoAR
KinoAR / State.hx
Created February 21, 2021 01:47
State machine in HaxeFlixel
package game;
class State {
public var currentState:Float -> Void;
public function new(initialState:Float -> Void) {
currentState = initialState;
}