News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

Metroid Fusion Engine

Started by liamnajor, April 27, 2017, 06:20:55 PM

Previous topic - Next topic

liamnajor

As most of you who have been keeping up with Metroid Insurrection know, I've been working on a new, revamped engine with cleaner code to replace my old, buggy prototype. New releases of Insurrection will be in the old topic, but the engine itself is going here. This engine will most resemble Metroid Feat Editor(AM2R forums) in terms of features and functionality, except it is in HTML/Javascript and Crafty.js. It comes preloaded with ZM sound effects; upgrades, doors, and Samus sprites(fusion Samus and doors only); all of AM2R's music, a photo editor, an 8-bit music editor, and an incomplete doc/help page. If you use the complete version(won't be out for a month at the very, absolute least) for your own game, I ask(but don't require) that you credit me. Here is a link to the github reposatory:
https://github.com/liamnajor/Metroid-Engine
THIS IS THE DEVELOPMENT VERSION. EXPECT BUGS AND OCCASIONAL BROKENNESS.
screenshots soon.

liamnajor

just so everyone knows, YOU MUST KNOW JAVASCRIPT TO USE MY ENGINE. doing away with coding would defy the laws of physics and quantum mechanics(not really, it's called hyperbole).

Hackmi

This the final engine for Insurrection?

liamnajor

yes; that's the reason I'm making this engine to begin with.

liamnajor

#4
I am writing a custum collision library for my engine. does anyone have suggestions, critisism, thoughts? also note that
this is a WIP.
the function itself:

Crafty.c("Collision", {/
init: function() {
        //auto generate the hitbox
var hitbx = this.x
var hitby = this.y
var hitbw = this.w
var hitbh = this.h
        //sets some values
        var hd = this.h/2
        var wd = this.w/2
        var n = -1
/*adds 'n' to the hitbox as it's ID. hitboxes with the same ID cannot detect collisions
. */
        this.hitbox.n = n
        var u = this.y + hd
        var d = this.y - hd
        var l = this.x - wd
        var r = this.x + wd
        //add the collision booleans
        this.lhit = false
        this.rhit = false
        this.uhit = false
        this.dhit = false
        //defines the corners of the hitbox for accurate collisions
        this.hitbox.LU = {x: l, y: u}
        this.hitbox.RU = {x: r, y: u}
        this.hitbox.LD = {x: l, y: d}
        this.hitbox.RD = {x: r, y: d}

this goes in the game code:
                if ({entity name}.hitbox.x <= {other entity name}.hitbox.x) {
            {entity name}.lhit = true
        } else {
            {entity name}.lhit = false
        }
        if ({entity name}.hitbox.x >= {other entity name}.hitbox.x) {
            {entity name}.rhit = true
        } else {
            {entity name}.rhit = false
        }
        if ({entity name}.hitbox.y <= {other entity name}.hitbox.y) {
            {entity name}.uhit = true
        } else {
            {entity name}.uhit = false
        }
        if ({entity name}.hitbox.y <= {other entity name}.hitbox.y) {
            {entity name}.dhit = true
        } else {
            {entity name}.dhit = false
        }

this allows the game to differentiate between where the entity hit, and more importantly, allows the detection of hits between more than one object per entity. the only flaw I can see is having to call the function for every tile in a room, bloating the code. I have a solotion to that: making a different version of this that detects hits based on COMPONENTS, not entity names. since all the tiles have the "Tile" componant anyway, this is the best solution as far as I can tell. now the only problem is slope collisions.

the 0.8.0 update of Crafty.js has far better collisions, so I'm using that.