Hot reload / live coding?

is this possible? (this is a killer feature to me! :smiley: )

1 Like

Yes, it is working!! And it is a killer feature, you can use it (as far as I can see right now) to modify your update loop.

(ā€¦and change your game rules :open_mouth:, that really is a killer feature, Iā€™m currently wondering why Iā€™m not using it more often :thinking: ).

So, but just as depicted in the article, no class field refactoring etc.

Iā€™m pondering how can you inject some code to be only executed once, since you can only hot-reload what is inside of update (I guess? :thinking: )


(btw welcome back, rahil :wink: :sun_with_face: )

1 Like

Oh this is an idea how you can inject code only once I guess

class HotReload01 extends hxd.App {
    var hotreload_version : Int = 0;
    static function main() { new HotReload01(); }
    override function init() {}
    override function update(dt:Float) {

        if( hotreload_version == 0 ) // for every new hot-reload increase 0 by one here (by hand)
            callOnce();

        // your game rules here ...
    }
    
    function callOnce() {
        // some code here ... (to only be executed once)
        // like e.g.: player.lifepoints = 1000
        hotreload_version++;
        trace('Hot-reload is now version = $hotreload_version');
    }
}

after every recompile you just change this line of code by hand to
if( hotreload_version == 1 )
if( hotreload_version == 2 )
if( hotreload_version == 3 )
ā€¦

1 Like

Ahhhhh @AlienBuchner !!! <3 <3

Yesā€¦ itā€™s been a few lifetimes. I had to move country post-pandemic. Life happens. Itā€™s all so stupid. Iā€™m still not settled!

But recently, I was playing an old game ā€œTetris Attackā€ (Puzzle League series) emulated through a physical arcade cabinet; It re-ignited my love for games. I thought about quickly re-making it in Haxe/Heaps but i discovered it was already remade in love2d/lua: panelattack.com. Anyway, itā€™s got me in the mood for making and perfecting some old forgotten classic multiplayer competitive games. :smiley:

Thatā€™s such great news about hot reloading!!! You must be a pro game maker by now! Wow. :smiley:

Glad to hear from you!