MeMyMo

Members
  • Content Count

    20
  • Joined

  • Last visited

1 Follower

About MeMyMo

  • Rank
    Member

Recent Profile Visitors

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

  1. MeMyMo

    Moving a custom class that extends a Sprite

    So it was actually working, it was just that I had a black background and the camera followed my character. Doh.
  2. I haven't been able to figure this out. I have a "Player" class that extends Sprite: export default class Player extends Phaser.GameObjects.Sprite{ constructor(scene, x, y, config) { super(scene, x, y, config.key); this.scene = scene; this.lastAnim = null; this.vel = 200; this.scene.physics.world.enable(this); this.scene.add.existing(this); const { LEFT, RIGHT, UP, DOWN } = Phaser.Input.Keyboard.KeyCodes; this.keys = this.scene.input.keyboard.addKeys({ left: LEFT, right: RIGHT, up: UP, down: DOWN, }); } preUpdate (time, delta) { super.preUpdate(time, delta); const keys = this.keys; let animationName = 'player-idle'; if (keys.left.isDown) { this.body.setVelocityX(-this.vel); this.setFlipX(true); } else if (keys.right.isDown) { this.body.setVelocityX(this.vel); this.setFlipX(false); } if (keys.up.isDown) { this.body.setVelocityY(-this.vel); } else if (keys.down.isDown) { this.body.setVelocityY(this.vel); } // TODO: Clean this up if (keys.up.isDown || keys.down.isDown || keys.left.isDown || keys.right.isDown) { animationName = "player-walk"; } else { animationName = 'player-idle'; } if(this.lastAnim !== animationName) { this.lastAnim = animationName; this.anims.play(animationName, true); } } } I instantiate it in the "create" method of the scene: this.player = new Player(this, 300, 300, {key: 'player'}); The Sprite animates and everything, but it just stays in the same place. My game setup: const gameConfig = { width: 1024, height: 768, scene: GameScene, pixelArt: true, zoom: 2, physics: { default: 'arcade', arcade: { gravity: { y: 0 }, debug: false } }, }; I've seen examples that create an update method then call it in the scene update loop, but shouldn't preUpdate be the same? Any help appreciated!
  3. MeMyMo

    ES6 code hinting in Webstorm

    It seems to work for me in VS Code? https://i.imgur.com/8mGagTo.png
  4. I don't know if this helps, but someone ported Box2D to JS recently: https://github.com/shakiba/planck.js Maybe the performance is better?
  5. MeMyMo

    How do you guys build your UI?

    Basically what the title says. I'm having a hard time thinking how you can build a simple UI with some dynamic text/buttons/scrollable fields, etc. A group with sprites? Outside of Phaser with HTML/CSS?
  6. MeMyMo

    Easystar pathfinding path always empty

    I'm an idiot, the walkable tile was 3, not 2.
  7. Hey, I'm messing around with pathfinding. Modified the Easystar Phaser plugin for ES6, but it seems to always return an empty path: https://max-arias.github.io/miner-idle-1click/ (source is 0,0) Calculation is here: https://github.com/max-arias/miner-idle-1click/blob/master/src/entities/Map.js ... let walkableTiles = [2, 150, 152, 166, 35, 68, 18] this.pathfinder = this.game.plugins.add(PathFinderPlugin); this.pathfinder.setGrid(this.layers[1].data, walkableTiles); } update () {} findPathTo(fromX, fromY, toX, toY) { this.pathfinder.setCallbackFunction((path) => { path = path || []; console.log(`path: ${path}`); // for(var i = 0, ilen = path.length; i < ilen; i++) { // map.putTile(46, path[i].x, path[i].y); // } }); console.log(this.layers[1].data); console.log(toX); console.log(toY); this.pathfinder.preparePathCalculation([0, 0], [toX, toY]); this.pathfinder.calculatePath(); } Grid data looks good... ideas?
  8. You would need to use something like this: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
  9. MeMyMo

    Getting a 2D array for Easystar?

    You could do something like: var tile; var map = []; var tileWidth = 38; for (var xx = 0; xx < 10; xx++) { map[xx] = []; for (var yy = 0; yy < 10; yy++) { // Create a tile using the new game.add.isoSprite factory method at the specified position. // The last parameter is the group you want to add it to (just like game.add.sprite) tile = game.add.isoSprite(xx tileWidth, yy * tileWidth, 0, 'tile', 0, tileGroup); tile.anchor.set(0.5, 0); map[xx][yy] = 1; } } console.log(map) But you should probably look into tilemaps and Tiled, it'll help a lot. Also, there's a Phaser plugin to help out with pathfinding: https://github.com/appsbu-de/phaser_plugin_pathfinding
  10. I've been looking at how BrowserQuest does it and I'm getting a better idea. I'll read up on your link Skeptron, too. For the moment I'll go with something a bit more amateur-ish, I don't think it's all that important that it's 'hackable' as much as releasing something is. Appreciate the input guys, thanks.
  11. MeMyMo

    How to move and shoot at same time with multi-touch?

    Maybe something simpler, like: if (direction != 0) { //Move this.player.body.velocity.y = direction * this.PLAYER_SPEED; } if (firePress) { //Fire this.createPlayerBullet(); }
  12. Might have better luck here: http://www.html5gamedevs.com/forum/22-jobs-hiring-and-freelance/
  13. Ah, sorry about that. Googled a bit and it looks like it's not as straightforward. Maybe: http://www.html5gamedevs.com/topic/4760-best-way-to-recreate-old-physicsoverlap-using-p2/ ?
  14. Hey, So I'm messing around with Phaser and Socket.IO, I got a simple "game" working where multiple players can connect and you can see each other/move. The thing is that movement/collisions (for the current player) is client side, relying on arcade physics and x/y velocities. I'm a webdev, so I know it's not smart to rely on the client, but I'm having some difficulty understanding how I would do collisions/movement on the server side. Movement might be easier, I could probably have an update loop on the server and just send over the player's moving direction and then calculate the new coords on the server and send them back, but that would defeat the purpose of using collisions on the client, no? Am I right thinking that I will have to run my own collision logic in the server? Any pointers on what I should do? My "game": http://104.131.68.91:3000/ (Yeah, sometimes it doesn't spawn where it should...) My repo: https://github.com/max-arias/mp-phaser Any help appreciated!
  15. MeMyMo

    Discover Phaser Pdf

    I would start with free resoures, Phaser has some: https://phaser.io/tutorials/making-your-first-phaser-game