Skip to content

Instantly share code, notes, and snippets.

@Yanrishatum
Last active August 27, 2024 13:42
Show Gist options
  • Save Yanrishatum/8034408c03785da177433f483a576c8e to your computer and use it in GitHub Desktop.
Save Yanrishatum/8034408c03785da177433f483a576c8e to your computer and use it in GitHub Desktop.
#Heaps pin megathread

Heaps discord pin megathread

This is a compiled and categorized list of the #Heaps channel in Haxe discord because we ran out of pins and searching them is a massive pain.

The Source links point to specific messages from Discord for more context/original text. If it has an asterisk (I.e. Source*) that means text was altered to update with current state of the engine as of writing (January 2024) or omitted, and source link may provide more context.

Warning: As of writing this (January 2024), this list is still very WIP but usable.

TODO:

  • Sort and categorize remaining posts
  • Re-verify everything to be up-to-date with current state of the engine
  • Reorder categories/content to be in order of usefulness/importance, rather than oldest->newest
  • Add proper markings on post sources and such.
  • Add descriptions to libraries
  • Add more example source links (like Deepnight jam games)
  • Update the FAQ
Changelog (Last update: 2024-05-26)
  • 2024-05-26
    • Added a bunch of libraries/samples provided by Nayata (Source)
    • Transferred 2 new pins by Spitko, by CLYDE
    • Added a few more libraries with Heaps support

A definitive guide

  1. If you're not already using Heaps, you probably shouldn't use Heaps
  2. See #1

— Spitko

Yes, we can and will meme.

General information

Spitko: As a general note, Heaps is not particularly community friendly. Development is driven largely by the two companies which use it. documentation is fairly sparse and often out of date. If you're not someone who is good at digging through code to figure out how things work, heaps might not be the best choice. | Source (2019)

Note: Due to departure of Deepnight from Motion Twin and them moving away from Haxe, it's now just one company - Shiro Games themselves.

Yanrishatum: On engine stability. Engine basics will remain the same more or less. If breaking changes would occur, it wouldn't be regular or would be well grounded. But in general things like scene, audio system, resource system etc should remain the same. However small unintended bugs can and likely will slip in as community usually uses parts of the engine neglected by Shiro. | Source*

Yanrishatum: What to expect from Heaps | Source*

  1. Poor documentation. h2d is the most documented part, at the cost of my sanity lol.
  2. Poor samples and explanation of how innards operate.
  3. In general you need to look for answers yourself, and not a be script kiddie who only can use stackoverflow. Skills at extracting information from source code is a must. Reading pinned messages here is a good idea as well.
  4. Due to how barebones engine is - you also need to know how to set up the game foundation. You can take shortcuts with gameBase and such, but you still better know that stuff.
  5. With 3D it's a nightmare due to Shiro 3D pipeline being somewhat obscure, especially on model import as well as animation system being not only antiquated but also very unwieldy to use. The forward rendering material setup (which is on by default) is likely currently broken as Shiro moved to PBR setup.
  6. Knowledge of how rendering functions is also a must. I.e. what shaders do, how graphics are rendered in general, etc.

I can't stress it enough: This engine is not for newbies, it's for people who know what they're doing. Newbies can try to use it, but it definitely won't be a pleasant experience, because there's no helping crutches to learn the ropes.

News/Articles

Tutorials/how-tos/tips

  • For HL/C and mobile, see dedicated section.

  • Deepnight

  • Video Heaps tutorials by Let's make games youtube channel | Source

  • Video Heaps tutorial by SabeDoesThings | Source

  • Heaps tutorial by Mezo | Source

  • !Sacramentix - how to setup hashlink ( for windows ) | Source

    Gif image

    gif

  • Crystal: On learning Heaps/programming in general | Source*

    For me, I learn everything coding related like this:

    1. Get sample code from internet (preferably one that exists in a single file)
    2. Get sample code working (if it doesn't work, get help from people, don't struggle yet)
    3. Go through the code, line by line, and comment what that code does. If you don't get it, add a TODO (this INCLUDES the build system if you're unfamiliar, in this case the compile.hxml file etc)
    4. When you get to the end of your file, go back through and see if you can reason about your TODOS

    If you don't know how something works, some ways to try and understand are:

    • A: Comment it out, and see what breaks
    • B: Play around with values and order of execution, see what changes
    • C: Look in the source code (inspect what the class is and see its methods)
    • D: Compare source code to other source codes (how does h3d.col.Polygon differ from h3d.prim.Polygon, for example)
    1. Extend the sample - try and combine this sample with other samples
    2. Modularise - try to take what you've got in your single-file project and break it up into new files, breaking things up into functions and parameters, taking care not to change the program
  • ZwodahS: TTF to SDF .fnt | Source*

    Just want to share this in case someone needs it. I was looking at finding a TTF lib, and started looking at all the discussions of TTF in this channel. Turns out Yanrishatum recommends to use SDF instead if we want to dynamically scale font.

    Following the threads/discussion, i found Fontgen (by searching from history). Couldn't get it to compile. I then follow the tracks to Msdfgen and MSDF-atlas-gen, but they do not generate the .fnt that we need for heaps.

    By following the issues, and following someone who also needed bmfont, I eventually found MSDF-bmfont-xml. It works great, out of the box, generates .fnt which is supported by heaps. It is also a node package, so you don't even need to build it yourself.

    You will need use .to(hxd.res.BitmapFont).toSdfFont(14, MultiChannel) to use the font instead of the usual toFont()

  • CLYDE: Improving HLSDL compat with various gamepads | Source

    Just a tip for anyone in the future trying to fix XBox controllers/gamepads on linux with bluetooth: SDL has an environment variable called SDL_GAMECONTROLLERCONFIG_FILE. If you specify this as gamecontrollerdb.txt, there is a publicly running controller mapping db Getting that txt file into your games working directory, setting the env variable, will fix a lot of controller problems

HIDE-related

  • Nightly builds of HIDE are available here: http://build.heaps.io:8080/hide/

  • donach: Compiling/debugging HIDE | Source (2020)

    Post | Note: Hidden due to being outdated

    Maybe this will help someone - in order to be able to run HIDE, I had to do the following:

    1. installed haxe from https://haxe.org/download/file/4.0.5/haxe-4.0.5-win64.exe/
    2. cmd:
    haxelib setup
    -> c:/HaxeToolkit/haxe/lib
    
    haxelib git hxnodejs https://github.com/HaxeFoundation/hxnodejs
    haxelib git heaps https://github.com/HeapsIO/heaps
    haxelib git hxbit https://github.com/HeapsIO/hxbit
    haxelib git hscript https://github.com/HaxeFoundation/hscript
    haxelib git castle https://github.com/ncannasse/castle
    haxelib git hx3compat https://github.com/HaxeFoundation/hx3compat
    haxelib git domkit https://github.com/HeapsIO/domkit
    
    cd c:/HaxeToolkit/
    git clone https://github.com/HeapsIO/hide
    
    1. Open c:/HaxeToolkit/hide as workspace in VSCode
    2. Install "Debugger for NWjs" extension
    3. Install "Haxe Extension Pack" extension
    4. Run Debug of task "Launch HIDE"

Demos/examples/jam games

Note: See Libraries/IDEs section for more Heaps-related stuff.

Code snippets

  • ddmills - script to convert CP347 bitmap to .fnt file | Source

  • ZwodahS: How to fix sound bug | Source*

    See issues Heaps#1068 and Haxe#10682
    A simple fix is to put this line in your App.init:
    @:privateAccess haxe.MainLoop.add(() -> {});

  • ZwodahS: 2D Interactives break after resize | Source*
    See Heaps#1147 and reproduction

  • amusei: Taking a screenshot | Source*

    // Usage: takeScreenshot("path/to/my_screenshot.png");
    function takeScreenshot(path: String) {
        var tex = new h3d.mat.Texture(640, 480, [Target, IsNPOT, Serialize]);
        s2d.drawTo(tex);
        var pixels = tex.capturePixels();
        sys.io.File.saveBytes(path, pixels.toPNG());
    }
  • l_asticot: Saving .png screenshot on JS as href-url | Source

    var download = document.createAnchorElement();
    download.href = 'data:image/png;base16,' + data.toHex();
    download.download = "pock.png";
    download.click();
    download.remove();
  • Nevergarden: Getting 3D outline shader to work | Source

    Although not ideal but found a little bit of solution might be useful to some and maybe change it to a better one in future?

    I did this:

    var outlineShader = new h3d.shader.Outline();
    outlineShader.size = 0.05;
    outlineShader.color.setColor(0x000000);
    var base = new BaseMesh();
    base.color.setColor(0xE7A35A);
    var basePass = new h3d.mat.Pass("Outline");
    basePass.load(obj1.material.mainPass);
    basePass.addShader(base);
    obj1.material.mainPass.culling = Front;
    obj1.material.mainPass.addShader(outlineShader);
    obj1.material.addPass(basePass);
    Sample image

    preview

  • Spitko: Opening links | Source

If by link you mean to a website in the user's own browser, you'll probably need to do an os-specific shell call for that. Something like Sys.command( "start", [ "http://mysite.com/about" ] );. the command is going to be different by platform so you'll probably need some ifdefs :pensive_loaf:

HL/C; Mobile

In short: if you want mobile, you're in for a lot of pain.

  • Generic tooling by Rainy: Zyheaps | Source
    Note: read instructions, it may require using custom Heaps fork.

Android

iOS

  • qkdreyer's ios project files - You guessed it! Old (3+ years), no guarantees.
  • FylmTM supposedly have an updated fork of qkdreyer's project, but it's not public. (See discord link to their Android fork above)

HL/C

Libraries/IDEs

Dead

Those posts contain dead links, and remain here until I get confirmation that they are truly dead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment