Jump to content


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    pdiddles03 reacted to mattstyles in Game list of phaser games   
    I heard a great story about a guy who ran regularly and always wore neoprene gloves, one day he sees a dog way up ahead drop a log on the pavement and watched the owner have a sly look around and just carry on walking, so, he scooped it up, tapped the owner on the shoulder "excuse me, you dropped this" and dropped the poo straight in her hands.
    Not sure if it helped her learn the error of her ways but amusing anyway!
    Nice work on the game, reminds me of BC's Quest for Tires! I played that a LOT back in the day!
  2. Sad
    pdiddles03 reacted to Maras in How to properly work with audio   
    So it looks like the problem is audiosprite + .mp3. 
    If I use this: 
    this.load.audio("sounds", ["_game/assets/sounds/sounds.mp3", "_game/assets/sounds/sounds.ogg"], true); or
    this.load.audio("sounds", "_game/assets/sounds/sounds.mp3", true); It's broken. If I use this:
    this.load.audio("sounds", "_game/assets/sounds/sounds.ogg", true); Everything works fine. Separate mp3 audiofiles works fine too.
    Tested on Samsung GT-i8190n (No sound while using mp3 audiosprite) and Lenovo IdeaTabA1000-F (sounds go crazy while using mp3 audiosprite).
    I also just found quite simple fix - putting ogg file first and mp3 file second. But does it fix everything? It seems that every device is behaving a bit differently (starting with preloader and ending with sounds)
    Like this:
    this.load.audio("sounds", ["_game/assets/sounds/sounds.mp3", "_game/assets/sounds/sounds.ogg"], true);  
    I use TypeScript, so I just simply store the sounds in global variable. (not global in final JS)
  3. Like
    pdiddles03 reacted to nkholski in Transition between states   
    Just coordinates. Define minX,minY, maxX and maxY (or x,y,width,height) for each "room" and check the player position against those rectangles. When you move between rooms you tween such a rectangle from original bounds to the desired ones and constantly set the real world bounds to match that rectangle in the update-loop. Sorry for being cryptic, you'll have to translate it to code yourself. This how it works in my partial metroid remake at http://metroid.niklasberg.se
  4. Like
    pdiddles03 reacted to samme in Give Sprite a Sword   
    sprite.addChild(game.make.sprite(offsetFromSpriteX, offsetFromSpriteY, 'sword');  
  5. Like
    pdiddles03 reacted to Quinten in Need some Tilemap and camera performance tips.   
    Maybe this will help someone who is looking for tips:
    I have a game with a tilemap made in Tiled. The tilemap is 128 x 128 in size with tiles of 16 x 16 resulting in a small sandbox world of 2048 x 2048 pixels.
    Now the game was running okay, but on an older laptop of mine it had some lag dropping in fps from 60 to 40/30 when moving the camera. (i'm not even talking about mobile, that i still have to tackle).
    First thing i did was putting the visible property of the 2 layers of the map to false. Which stopped rendering the tilemap, but kept all the game objects still colliding the map.
    Then i got rid of the tilesetimage, which i did not need anymore.
    Then i went back to Tiled and exported the whole map as an image and added that image as background to the level.
    in the preload:
    game.load.image('levelflat', 'assets/sprites/level.png'); and in the create function:
    var levelbg = game.add.image(0, 0, 'levelflat'); That made a very noticeable boost i must say. Resulting in no more lag on the old laptop. Even on mobile it was almost there, but there still was another element causing lag on mobile.
    Now i must note that this probably won't work with very large levels. It all depends on how large you can make the images of the backgrounds.
  6. Like
    pdiddles03 reacted to mrxj88 in Sprite not adding using spritesheet animation   
    You say you want to add your spritesheet by using the example above that you gave me from the link. But 'Im telling you that's the wrong example your trying to use. Because you are using a json file which means you are trying to use a texture atlas. As spritesheet don't need a json file to describe where the sprite begins and ends because they dont vary in size. Here i found 2 links that may be able to help clear up what i'm saying. the first link is for a texture atlas: https://www.joshmorony.com/how-to-create-animations-in-phaser-with-a-texture-atlas/ And this link is for spritesheet: https://www.joshmorony.com/how-to-create-an-animated-character-using-sprites-in-phaser/
  7. Like
    pdiddles03 reacted to mattstyles in JavaScript Collision with Tile Map   
    What does the tile array represent? if 0's are spaces and 1's are blocked then surely it's a simple case of:
    function updatePosition () { // Calculate next position for player // e.g. var desiredX = player.x + 1 var desiredY = player.y // Query table for cell data var cell = map[desiredY, desiredX) // Run collision detection code if (cell === 1) { return } // If we get here then no collision so move away player.x = desiredX player.y = desiredY } If your tile structure gets more complex then that is still fine, just use table lookup again to get the cell you're want and you'd need to check against something in that structure that denotes it blocks movement, e.g.
    // This returns a cell object, used when creating your map function createCell (isBlocker) { return { textureID: 10, isBlocker: isBlocker } } // A representative map var map = [ createCell(false), createCell(true) ] // Some time later, lets assume player is moving from map[0] to map[1] function isCollision (index) { return map[index].isBlocker } // Invoke it isCollision(1) // This will return true, so the cell is blocked so do not update player movement Note here that even though we've changed your cell definition from a number to an object the logic is the same.
    Spot on, this might be a problem and 2d arrays as you've specified in your post are usually worse for lookups than a 1d array with a helper function to convert [x, y] into [index].
    However, there is a case that changing your map structure from the 2d one you're currently using is premature optimisation, try it out for your use-case, for example the following array structure with 1e12 total entries (that's a pretty bloody big map) takes less than a ms and half in node (which is v8, so, Chrome perf should be comparable) on my machine (which is beefy, granted, but its a ruddy big map!), 60 fps gives you ~16ms, 1.35ms of that just for a lookup is a lot, but, its a big map and if you can afford it then its no problem, again, test your use-case and find your optimum map size, create automatic perf tests and optimise the structures when it becomes  a problem.
    console.time('make') var map = new Array(1000000).fill(new Array(1000000).fill(0)) console.timeEnd('make') console.time('lookup') console.log(map[90000][90000]) console.timeEnd('lookup') // make: 33.392ms // 0 // lookup: 1.357ms Note that my highly unrepresentative set of random numbers (90k x 90k here but I tried a few other combos, ~20 each) found no difference in where you do the lookup, its not like it has to search through all the items in your array to find the one you want when you do a lookup (note that depending on how you change your structure it could make a difference but, largely, just indexing an array doesn't really matter where you index). Note also that there could be a crafty v8 optimisation as all the array entries are identical, I doubt it but its not unfeasible.
    Some things you might want to consider if your map gets prohibitively large:
    * use a 1d array and a helper to convert [x, y] into [index]. Creating the helper function is remarkably easy, but I'll leave that to you
    * consider some sort of space partitioning, a tree of some sort (i.e. look for how octrees or binary space trees work) might help. Might be worth also searching for 'chunking' i.e. subdividing maps into chunks (this is exactly what space partitioning is, but with the prevalence of minecraft you might find some info in google under chunk rather than partitioning).
    * if your structures get really complex (they shouldn't) then maybe you'd hold multiple maps, one that just contained 'blocking' or collision data? maybe the lookups will be faster and there shouldn't really be much in the way of memory overhead/waste/redundancy unless you kept the same info in multiple arrays.
    Some other things to consider for collision detection:
    * your map is currently a static entity when you check against it, what if it also moved? who moves first?
    * how to check against a list of entities? again, if they move, who moves first? or maybe they all move simultaneously and you check for collisions against where all these entities want to move to? although in that case who has preference when a collision occurs? what happens when entities collide?
    * if your entities or map is moving how would you stop entities from going through each other? i.e. if player moves 3 spaces in one movement just checking the destination isn't going to work, you're going to have to check all intermediate locations too.
  8. Like
    pdiddles03 got a reaction from guatedude2 in Pixi.js Showcase   
    Don't want to share the actual game yet, but here is a video of what I am workiong on. it will be for phones.

  • Create New...