Users browsing this thread: 4 Guest(s)
Xander's Super Wario Bros! ~ HTML5 Engine Demo!
#15
(05-22-2016, 02:18 PM)iyenal Wrote: Do you have separated Javascript files for enemies AI and powerup transformations ?
If yes, do you can share it ? Thanks.
My code for the powerup transformations wouldn't make much sense without understanding the engine I am using.

Enemy AI code might be useful, but again, it's engine specific and might not help you very much.

Here's the code that handles turning around on platforms, it's pretty rudimentary.

Code:
            if( !ig.game.collisionMap.getTile
                 (
                this.pos.x + (this.flip ? -1 : this.size.x + 1), //the x position when traveling left (add a minus 1 for the next position), the x position plus the width of the entity when going right + 1 for the next tile over
                this.pos.y + this.size.y+1 //y position plus the height gets the ground position, adding 1 lowers the creature into the floor
                )
              )
            { //so if the entity is at the edge, then adding 1 to the x axis and 1 to the y axis would produce no collision since that point would not be touching a collision tile
                this.flip = !this.flip;
            }
            
            if (this.standing) {
                //this.accel.x = this.flip ? -100 : 100;
                this.vel.x = this.flip ? -this.maxVel.x : this.maxVel.x;
            }
            this.currentAnim.flip.x = this.flip;
Reply
Thanked by:


Messages In This Thread
RE: Xander's Super Wario Bros! ~ HTML5 Engine Demo! - by Xander - 05-25-2016, 09:05 AM

Forum Jump: