soulVampire

Members
  • Content Count

    11
  • Joined

  • Last visited

About soulVampire

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. soulVampire

    SoulVampire

    how do you use the melonjs response.b.body.collisionType.bInA to check if player is in ladder tried but not working, doing something wrong with the assignment of the object
  2. I have a healthBar entity given by the code below which is in a separate file called health_bar_entity.js(melonjs code base) game.HealthBar = me.Renderable.extend( { init: function(hitPoints, maxHitPoints) { this._super(me.Renderable, "init", [0, -24, 48, 6]); this.z = 100; this.hitPoints = hitPoints; this.maxHitPoints = maxHitPoints; this.health = 1; this.currentHealth = 1; this.setHealth(hitPoints); this.borderColor = '#000'; this.alwaysUpdate = false; }, draw : function(renderer) { if(this.health>=0) { renderer.setColor(this.borderColor); renderer.fillRect(this.pos.x, this.pos.y, this.width, this.height); renderer.setColor('#F00'); renderer.fillRect(this.pos.x+1, this.pos.y+1, this.width-2, this.height-2); renderer.setColor('#0F0'); if(this.health>1) renderer.fillRect(this.pos.x+1, this.pos.y+1, this.width-2, this.height-2); else renderer.fillRect(this.pos.x+1, this.pos.y+1, (this.width-2)*this.health, this.height-2); } }, update : function() { if(this.updateOnce) { this.updateOnce = false; return true; } if(this.health==this.currentHealth) return false; this.health = this.currentHealth; return true; }, setHealth: function(hitPoints) { this.currentHealth = hitPoints/this.maxHitPoints; }, setCurrentAnimation: function() { //do nothing }, setAnimationFrame: function(blarg) { //do nothing } }); and I want to add this to the player entity, but when I try to add to the player by using the code below, this is in the file game_player_entity.js(melonjs code base) this.player_health = 50; this.player_max_health = 100; this.healthBar = me.pool.pull("playerHealthbar", this.player_health, this.player_max_health); console.log('health bar' + this.healthBar); this.addChild(this.healthbar, 9); it give me an error don't know whats going wrong have looked at the api and it seems that it should work
  3. soulVampire

    Mr TwinkleToes

    have a WIP at www.silverhawk.co.uk it has moving platforms and pass through platform at certain location within the game, the ladders are currently not working, but as I am testing it on my domain to see how it runs in a browser will be adding destructible platforms that break when you stand on them, but at this time have the level designed and finished, the additions will be added later , this will be world 1, area 1(castle level) the next area will be world 1, area 2(forest)..... there will be a total of 4 worlds each with 4 area's so in total 16 large maps each area being equal to about 70 (screens) by 30(screens) each screen at 640x480. anyone having any ideas if they want can become involved in my project. my email is gamerequest@silverhawk.co.uk
  4. having a problem with the collisionbox for the moving platform it moves but does not change the size to be the size of the image, its the size of the area then the platform has to move through(left to right) here is the image with the hitbox bounds on now here is the code don't know why its not doing what it should do /*---------------- floating Plataform ----------------- */ game.movingPlatforms = me.Entity.extend({ init: function(x, y, settings) { // define this here instead of tiled settings.image = "platform_2"; //values from tiled on the size of the area to move within var area_width = settings.width; var area_height = settings.height;; //sprite area settings.width = settings.framewidth = 64; settings.height = settings.frameheight = 32; this._super(me.Entity, 'init', [x, y , settings]); this.body.collisionType = me.collision.types.WORLD_SHAPE; this.body.setCollisionMask(me.collision.types.WORLD_SHAPE | me.collision.types.PLAYER_OBJECT); // set start/end position based on the initial area size initial_start_pos_x = this.pos.x; this.startX = initial_start_pos_x; this.endX = this.startX + area_width - settings.framewidth;; this.pos.x = this.startX + area_width; // manually update the entity bounds as we manually change the position this.updateBounds(); // to remember which side we were walking this.walkLeft = false; this.alwaysUpdate = true; // velocity this.body.setVelocity(2, 5); }, update : function (dt) { this.body.gravity = 0; if (this.walkLeft && this.pos.x <= this.startX) { this.walkLeft = false; } else if (!this.walkLeft && this.pos.x >= this.endX) { this.walkLeft = true; } // make it walk //this.renderable.flipX(this.walkLeft); this.body.vel.x += (this.walkLeft) ? -this.body.accel.x * me.timer.tick : this.body.accel.x * me.timer.tick; // update the body movement this.body.update(dt); // handle collisions against other shapes me.collision.check(this); // return true if we moved or if the renderable was updated return (this._super(me.Entity, 'update', [dt]) || this.body.vel.x !== 0 || this.body.vel.y !== 0); } }); have not a clue as to why the collision box is not the right size
  5. soulVampire

    Mr TwinkleToes

    have a moving platform created in the lvl, but need to create a collision area so the my player can stand on it, when i use the this.body.kinematic = false;, the platform can be moved out of the way, not what i wanted need to be able to jump on it removed the this .body.kinematic = false; from the code now can not interact with the platform in any way, so need to have a way to have a collision body so that can stand on object, but when add the kinematic the platform behaves in a way that is not what i want, the code for what i currently have is given below /** * moving platforms Entity */ game.MovingPlatformEntity = me.Sprite.extend( { init: function (x, y, settings) { // save the area size as defined in Tiled width = settings.width; // define this here instead of tiled settings.image = "platform_2"; // adjust the size setting information to match the sprite size // so that the entity object is created with the right size settings.framewidth = settings.width = 64; settings.frameheight = settings.height = 32; // call the parent constructor this._super(me.Sprite, 'init', [x, y , settings]); // add a physic body this.body = new me.Body(this); // turn off gravity this.body.gravity = 0; // add a default collision shape this.body.addShape(new me.Rect(0, 0, this.width, this.height)); // configure max speed and friction this.body.setMaxVelocity(settings.platform_movment_speed, 6); // set start/end position based on the initial area size x = this.pos.x; this.startX = x; this.pos.x = this.endX = x + width - this.width; //this.pos.x = x + width - this.width; // manually update the entity bounds as we manually change the position this.updateBounds(); // to remember which side we were walking this.platform_move_left = false; // make it "alive" this.alive = true; this.alwaysUpdate = true; }, // manage the enemy movement update : function (dt) { if (this.alive) { if (this.platform_move_left && this.pos.x <= this.startX) { this.platform_move_left = false; this.body.force.x = this.body.maxVel.x; } else if (!this.platform_move_left && this.pos.x >= this.endX) { this.platform_move_left = true; this.body.force.x = -this.body.maxVel.x; } } else { this.body.force.x = 0; } //this.renderable.flipX(this.walkLeft); // turn off gravity this.body.gravity = 0; // check & update movement this.body.update(dt); // handle collisions against other shapes me.collision.check(this); // return true if we moved or if the renderable was updated return (this._super(me.Sprite, 'update', [dt]) || this.body.vel.x !== 0 || this.body.vel.y !== 0); }, /** * colision handler * (called when colliding with other objects) */ onCollision : function (response, other) { }, });
  6. been trying to change the this.body.shape to the new this.body.addshape(0,0,[0,0,50,0,50,31,0,31]), but does nothing to change the size which is the size of the crouch animation, have the animations in a texture, but when loading the graphics the crouch animation displays to high on the screen and I don't know why the graphics come from a texture file created by texturepacker so and have looked at the json file contains all the correct sizes for each of the animation frames, but the walk frames display fine but the crouch frames don't as you can see from the displayed running image
  7. at the moment have just made the resolution high so as to encompass a large view of the lvl, but when playing the resolution will only so a small part of the lvl, have been making changes to the game on my PC, so have not uploaded the new version to my site, just working on the mechanics of the character movement before I start to add enemies, also going to try to add spawn triggers to the lvl to activate enemies when your character move over point in the lvl, also having trouble trying to load different sprites to the character as the jump sprites are 57x56 and the walk sprites are 57x22 s o need to change the framewidth to the new value, but not finding any solution the problem at the moment
  8. Have started to design a platformer game have world 1 designed, now starting to create enemies spawn point triggers at the moment it’s a WIP if you want to see the first world then go to www.silverhawk.co.uk for the moment only works on desktop PC if you have any suggestions or graphics that you think would improve the game then contact me at email: graphicsideas@silverhawk.co.uk, have default character just to test mechanics of the platforms, but am going to use maptiled to create different enemies spawn areas
  9. trying to create two types of players sprites one for walking which is width 22px, height 57px the other images are for crawling and are width 50px height 32px, been trying to use add the new sprite to the code but having no success this code is for walking, init : function (x, y, settings) { // call the constructor this._super(me.Entity, 'init', [x, y, settings]); // max walking & jumping speed this.body.setMaxVelocity(1.5, 11); this.body.setFriction(0.4, 0); // set the display to follow our position on both axis me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH, 0.4); // ensure the player is updated even when outside of the viewport this.alwaysUpdate = true; this.mutipleJump = 1; // define a basic walking animation (using all frames) this.renderable.addAnimation("walk", [0, 1, 2, 3, 4, 5]); // define a standing animation (using the first frame) this.renderable.addAnimation("stand", [0]); this.renderable.setCurrentAnimation("stand"); }, now I want to add the this,renderable.addAnimation("crawl", [0,1,2,3,4,5]) but not using tiled to pass the values want to do it from the program, so define a base state in tiled(walking) and define the more complex actions in game.PlayerEntity() section so that I can add crawl, running, climping and other player actions within the program, if any one has any ideas would love to hear
  10. soulVampire

    Mr

    how do you create jump through platforms in meleonjs using maptiled program....looked at the platformer example on github, but does not explain how to create a flag or a bitmask to specifiy which parts of the platform the player can jump through.....was thinking of a 4 bitmask 0000 = solid platform for 1000=leftside pass through, 0100 top pass through, 0010=rightside pass through, 0001=bottompass through....but can't find a concrete example of how to do this