samlancashire

Members
  • Content Count

    9
  • Joined

  • Last visited

About samlancashire

  • Rank
    Newbie

Contact Methods

  • Website URL
    samlancashire.com

Recent Profile Visitors

512 profile views
  1. samlancashire

    Text width issues

    You need to set the width of the string to the rectangles width after you scale it.
  2. Firefox 45 and Chrome 49 (both to be released in March) will have support for ECMAScript 6's class declaration, as well as constructor method, and super and extends keywords. This means we can now create classes in Javascript like this: class Sprite { constructor(health) { this.health = health; this.maxHealth = health; } get totalDamageTaken() { return this.maxHealth - this.health; } } class Enemy extends Sprite { constructor(health, damage) { super(health); this.damage = damage; } attack(sprite) { sprite.health -= this.damage; } } var player = new Sprite(10); var badguy = new Enemy(10, 2); badguy.attack(player); badguy.attack(player); console.log(player.health, player.totalDamageTaken); // 6, 4 If you want to try for yourself you can download Firefox Developer Edition, as it currently supports these features. For more information read MDN's documentation.
  3. samlancashire

    Fire on canvas (sailing boat) irregularly

    I think this is being over complicated. Unless the particles NEED to be generated exactly within the bounds of the sail and NEED to be randomly distributed within the sail, why not just: 1. Pick several points (x, y) for each sail and store them with the ship data 2. When it is time for the sail to ignite, generate particles randomly around each of those points, ie: // particles stored here var particles = []; var pointsArray = [ // array of a few coordinates that are within the bounds of the sail ]; for (var point in pointsArray) { // generate random coordinates near point var x = pointsArray[point].x + randomBetween(-50, 50); var y = pointsArray[point].y + randomBetween(-50, 50); // make a particle particles.push(new Particle('fire', x, y)); }
  4. samlancashire

    Builtin way for drawing on a canvas "loopingly"

    Not familiar with a built in way of doing this. I think you're on the money with the premature optimization. Are there a ton of images being drawn in this way every frame? 4 drawImage calls is nothing. My tile based game (768x640, with 64x64 tiles) runs 60fps no problem on my potato of a laptop, and thats 120 drawImage calls before I draw any sprites or worry about any game logic.
  5. samlancashire

    Embed gfycat in forum post?

    The other day I was updating the forum topic for my game with a new gfycat video. Somehow I managed to embed the actual gfycat video into the post and it can be paused by clicking on it, which is nice. I want to add another one now but cannot for the life of me figure out how I did it before. I can of course add a regular .gif but it is not as nice because it can't be paused. Help!?
  6. samlancashire

    [WIP] Goblins & Grottos

    This looks great! Thanks for sharing nodewebkit. Never heard of it but had always wondered about packaging my HTML5 games for desktop.
  7. samlancashire

    Twisted Bark - A Pixely Forest Critter RPG

    I made this rock golem sprite... It is the first hostile enemy to be encountered in the game.
  8. About a month into development now and having a blast making this. What's black and white and might have rabies? Don't let the mask fool you, this raccoon is a hero. Set in a fantasy woodland where trouble's brewing, our ring-tailed hero must explore, quest, and fight to survive. Nocturnal critters armed with high explosives and not a workplace safety poster in sight: that's right folks, things are going to get crazy. Twisted Bark is a pixely open-world style RPG. Gain experience completing quests and fighting enemies. Explore as far as your ability and level will allow you. Implemented features: Dynamic lighting Particle effects Quest platform (currently 1 quest fully implemented and working on #2) Slash Attack Dynamite item/attack Health Bar Experience points / level system Some enemy AI For more info/screenshots or to subscribe to updates by email, see the website: http://samlancashire.com/twisted-bark Open to any CC/feedback/ideas! Thanks for reading. Sam
  9. samlancashire

    Put game logic into same or separate loop than renderer?

    Yes, separate is the usual approach. I usually do something like: function update(mod) { //do logic!} function render() { requestAnimationFrame(render); if (eng.loadedImages == eng.imageCount) { //if all images have are loaded... //draw stuff! }} function tick() { update((Date.now() - lastTick) / 1000); lastTick = Date.now();} var lastTick = Date.now();setInterval(tick, 16.67); //60fpsrender();Also some quick reading: http://stackoverflow.com/questions/729921/settimeout-or-setinterval