zigazak

Members
  • Content Count

    13
  • Joined

  • Last visited

Posts posted by zigazak


  1. Sorry to resurrect an old thread, but would you mind sharing your code for your pathfinding test?

    I've recently started learning babylon and have been experimenting with something similar to this, would be awesome to see how you solved it. 

    Edit* Just realized I can view the source... I'm not a smart man haha


  2. So i've been developing a game where you can gather resources that can be used to build and recruit units.

    I store the players accumulative resources in a global variable on the window object - so it persists on game state changes.

    However it's super easy to open up the console and give yourself resources through accessing that variable.

    Is there an elegant way to hide persistent data from the player? 


  3. Thanks for the reply mattstyles :)

    I've made a basic prototype of the 'tower building', which can be seen here http://codepen.io/JUNKLAB/pen/grOEOV

    ( you can use the up and down arrow keys to move the camera up and down the building )

    My question now is, does Phaser have some sort of trigger functionality? Say my character moves all the way to the left of on of the rooms - I want him to automatically get teleported to the room above. 

    I put together a crude implementation of this using the arcade body physics and collisions, was just wondering if there was something more suitable I could be using? ( the codepen uses x positioning to check wether the 'player' should be teleported to the next level).

     


  4. Hey guys, I've come up with a simple idea for a tower based 'rougelike' where each tower has randomly generated floors.

    I'm having trouble coming up with an elegant way to build the towers and floors within Phaser such that a character can 'climb' the floors.

    The characters will be controlled AI that simply climb the tower from right to left - left to right. 

    An example -

    Do you guys have any tips as to how I might be able to achieve this?

    I've thought of just a standard tile map - with objects on each side of each floor, that when collided with will move the character to the floor above. 

    example.png


  5. So i've recently been building a game in Phaser, trying to keep objects as modular as possible, which lead me to this question. 

     

    I have a main game state that currently handles all input events and moves / mutates objects as necessary, e.g. player, enemies, particles, etc, each being a modular object which is required using browserify. I wanted to keep all input handling / updating within this function to reduce the function calls I'm making each frame (to reduce delta times).

     

    My question is, would this actually yield noticeable efficiency improvements, or should I just pass a reference to the game object to each module to handle their own input / updating. Considering objects pass by reference, this shouldn't be an issue right?

     

    FOR EXAMPLES SAKE, So basically instead of 

    update: function() {    game.physics.arcade.overlap(enemyBullets, tank, bulletHitPlayer, null, this);    enemiesAlive = 0;    for (var i = 0; i < enemies.length; i++)    {        if (enemies[i].alive)        {            enemiesAlive++;            game.physics.arcade.collide(tank, enemies[i].tank);            game.physics.arcade.overlap(bullets, enemies[i].tank, bulletHitEnemy, null, this);            enemies[i].update();        }    }    if (cursors.left.isDown)    {        tank.angle -= 4;    }    else if (cursors.right.isDown)    {        tank.angle += 4;    }    if (cursors.up.isDown)    {        //  The speed we'll travel at        currentSpeed = 300;    }    else    {        if (currentSpeed > 0)        {            currentSpeed -= 4;        }    }    if (currentSpeed > 0)    {        game.physics.arcade.velocityFromRotation(tank.rotation, currentSpeed, tank.body.velocity);    }    land.tilePosition.x = -game.camera.x;    land.tilePosition.y = -game.camera.y;    //  Position all the parts and align rotations    shadow.x = tank.x;    shadow.y = tank.y;    shadow.rotation = tank.rotation;    turret.x = tank.x;    turret.y = tank.y;    turret.rotation = game.physics.arcade.angleToPointer(turret);    if (game.input.activePointer.isDown)    {        //  Boom!        fire();    }}

    I'd have something like 

    update: function() {        this.tank.update(this.game);    this.turret.update(this.game, this.tank);    this.shadow.update(this.game, this.tank);    // etc etc}

  6. Hi guys, I've been struggling recently with overwhelming projects, and instead of actually starting a project, i'll obsess over the finer details. Sort of stuff like, which design patterns I could implement, how I'm going to handle game states, entity management, efficiency, understanding the engine documentation / code-base, etc. 

    I find I become overwhelmed by thinking about all the little things, and never actually start working on any of my game ideas.

    I was wondering if anyone else has had this problem, and what might be some tips to get over them. "Just start", seems like the appropriate answer, but being analytical by nature, it's hard not to think about the bigger picture.


  7. Hi guys, my first post on these forums, how exciting  :P

     

    A little background of myself - I am a web developer by profession, and most of my experience is within the tradition lamp stack / php development, however, I've seen the light! Although I've always know enough javascript to get by, and understand most simple concepts, i've never really truly understood the language. I've fallen head over heels in love with the language and much prefer 'the javascript way' of prototypal inheritance, synchronous programming, dynamic typing, etc. I've recently been trying to broaden my low level javaScript knowledge, and I love games, so most most of my tinkering has been within the game development realm.

     

    ANYWAYS, enough of the life story, basically what i've done is tried to fully grasp the idea of a game loop written in javascript - I was hoping to get as much feedback / suggestion / constructive criticism as I could. So without further adue, I present to you, my understanding of a fixed time-step game loop written in javascript.

    var Game = function() {    // our fixed time-step // 60 FPS // or 16.667 ms per frame    this.timeStep = 1000 / 60;    // used to store the relative 'execution' time of the previous frame    this.lastFrameTime = 0;    // used to store the time taken to process the previous frame    this.deltaTime = 0;    // used to store update calls within our 'time-step' simulation    this.updateCalls = 0;    // the maximum number of update calls we'll allow before we intervene    this.maxUpdateCalls = 240;    // start our loop - bind our local execution context (the game object)    requestAnimationFrame(this.mainLoop.bind(this));}// timestamp: indicates the current time when callbacks queued by// requestAnimationFrame begin to fire. think of it as "startFrameTime"// this is automatically passed by the requestAnimationFrame functionGame.prototype.mainLoop = function(timestamp) {    // this function is called when our update calls exceed the maximum    // update call limit, either our update logic has taken too long to    // process, resulting in a very large deltaTime, or the window has    // lost focus.    function panic() {        console.log('WARNING :: loop panic!');        this.deltaTime = 0; // discard the unsimulated time        // snap the player to the authoritave state (from the server)    }    // the accumulation of the remaining delta time from the last    // update + the time taken to process the previous frame (the delta time)    this.deltaTime += timestamp - this.lastFrameTime;    // set the last frame time to the current timestamp    // this is confusing, we are basically setting our 'last frame time'    // for the next frame    this.lastFrameTime = timestamp;    // reset our update call counter    this.updateCalls = 0;    // simulate the total elapsed time in fixed-size chucks while the time taken to    // render the frame is greater or equal to the desired timestep (the amount of    // time we want to render a frame (16.667ms))    // If the time that has passed since the last frame is less than the    // fixed simulation time, we just won't run an update() until the the next frame    // the remaining time left over is added to the next frame's delta time    while (this.deltaTime >= this.timeStep) {        // !!!!! update  with our fixed time step (1000/60 === 16.667) !!!!! //        // decrease our desired time step time from the accumulated delta        // until it is less than 16.667ms        this.deltaTime -= this.timeStep;        // are we in a spiral of death        if (++this.updateCalls >= this.maxUpdateCalls) {            panic();            break;        }    }    // !!!! draw our game objects !!!! //    requestAnimationFrame(this.mainLoop.bind(this));}

    I've also read about FPS throttling, but I don't really understand the concept. I'm under the impression that if you have a fixed time-step and 'simulate' updates within your game loop, you'll never breach the time-steps resulting FPS, in this case 60 frames per second. Am I not understanding something correctly?