Popular Content

Showing most liked content on 12/28/2016 in all areas

  1. 2 points
    I'd suggest try make your own, reasons below: AABB collision is pretty simple with just a few lines. Regarding the physics simulation you just need to create a class with only the properties your entities need, which is just another few lines of code. For box-vs-box collision detection: // a vs b aIsOverlapB = !( a.bottom <= b.top || a.top >= b.bottom || a.left >= b.right || a.right <= b.left ); For circle-vs-circle collision detection: // AABB overlap first aIsOverlapWithB = false; if (!( a.bottom <= b.top || a.top >= b.bottom || a.left >= b.right || a.right <= b.left) ) { // Now let's check the distance between center of the circles with radius sum // Squared distance is enough, so you can skip the expensive `sqrt` calculation aIsOverlapWithB = Vec2.squaredDistance(a.position, b.position) < (a.radius + b.radius) * (a.radius + b.radius); } For complete AABB based physics implementation, you can take a look at the physics module of LesserPanda, and use it as a reference for your own physics engine.
  2. 2 points

    Pixi.js for Typescript?

    This is up to date. https://github.com/pixijs/pixi-typescript In the future will look at possibly including types with the official package.json so that they are automatically available when acquiring pixi from npm.
  3. 1 point
    Server-side everything important. Assume that everything client-side will be manipulated (because it can).
  4. 1 point


    Gentlemen, I did some work and with the help of Pryme8, here is the jump feature : http://yobrowser.hol.es/babcity/alpha02-jump.html https://github.com/getzelus/babcity/blob/master/alpha02-jump.html He proposed to use a physic engine (CannonJS). But for the moment, I prefer to keep moveWithCollision if its enough, because of performance and easy coding. Other ways to deal with collisions : intersectsMesh or raycast and move in the opposite direction of walk (dirty ?) I'm ok with this new jump feature but maybe you know a better way. (need to create the jumping animation but this is only graphic stuff). ------------------- In fact I have some questions relative to moveWithCollision (native collision system) : - Can we implement an isGrounded parameter ? To check if our character can jump (like in Unity) I coded a working trick : compare the y position of the man in time (dirty ? and not accurate with heightfield) The comparison has a little delta of 0.2 because when the man is a little upside when he walks. To check if the character collides something and get the obstacle, the onCollide function seems to work fine. - Is it possible to implement a debug function to draw the ellipsoid ? I configured the ellipsoid of the man at line 180 and 181. The man doesn't go through the floating platform. But he can't walk below if the platform is high. ------------- Thank you guys !
  5. 1 point
    Yes, database for sure. I would also keep a local client-side copy of the purchased state for convenience. Most importantly I would regularly check that the effects of the purchase client-side correlate with the expected outcome on the server-side. Server would be Judge, Jury and Executioner with the Terms & Conditions clearly stating that upfront prior to any purchases.
  6. 1 point

    using texture atlas

    Ok, I'll try to clarify some things up: 1) To answer back a previous comment of another user: for me a Scale9 Sprite doesn't have to rely on an Atlas Texture, for me (but I totally understand other people may have other point of view) the Scale9Sprite is just a sprite with 4 more values: the 2 horiz splits and the 2 vert splits to define the 9 parts. 2) What I understood about TexturePacker (but I can be wrong because I just went to the product home page) is that it generates a picture file containing the atlas but also a json file that contains the whole information needed to find the right location/size of a given sprite's bitmap you put in the Atlas. You could and will be able to specify these information manually, but I think that if you store many sprites into one picture file: it's better to rely on a product that ease the production chain of your development. That was what I was trying to say with: The way Sprite2D is implemented internally so far would make things pretty easy to extend it to a Texture Altas, because internally the Sprite2D's bitmap (which can change because of the Frame support) is defined by a nomalized UV for the bottom/left corner and normalize size. Instead of storing just once this tuple I could make a list of them and there you have a Texture Atlas... But I don't want it to be this way, for me it should be a brand new primitive with a clearly defined semantic, well, I have to think it through, and I still haven't. One last thing concerning Scale9Sprite, do you people know if there are tool which generate a json file that store the 4 splits values so you won't have to specify them by code (or creating your own file format) ? Thanks
  7. 1 point
  8. 1 point

    Scaling imported scene

    @Adem Yes, mesh.scaling = new BABYLON.Vector3( 1, 1, 1); //1 = no scaling, 2 = twice the size, etc. but if your scene contains several, seperate meshes, it may mess with the positioning, scaling changes the size of a mesh, but not the position relative to other meshes, See this example; 3 meshes, 2 spheres, one at each end of the plane, http://www.babylonjs-playground.com/#1XGCEA#0 Now see the same scene scaled by 2. http://www.babylonjs-playground.com/#1XGCEA#1
  9. 1 point

    Scaling imported scene

    Hi @Adem It's probably best to do before you export it, depending on it's contents and setup.
  10. 1 point
    Hey Guys... So howz it going with your projects??? Did you ever get up and running ???
  11. 1 point

    Installing an HTML5 game

    I agree with End3r. Or just tell them right up front so they never ask at all: "Hey guys, try my new game, "Tomb Plunder". Play it online (no install needed) at tombplunder.com."
  12. 1 point
    Okay, I figured it out. new Phaser.Game(((window.innerWidth * window.devicePixelRatio) / (window.innerHeight * window.devicePixelRatio)) * 240, 240, Phaser.AUTO) this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; backgroundLayer.fixedToCamera = false; backgroundLayer.scrollFactorX = 0; backgroundLayer.scrollFactorY = 0; this.collisionLayer.fixedToCamera = false; this.collisionLayer.scrollFactorX = 0; this.collisionLayer.scrollFactorY = 0; this.mapOffsetX = (this.camera.width - this.map.widthInPixels) / 2; backgroundLayer.position.set(this.mapOffsetX, 0); this.collisionLayer.position.set(this.mapOffsetX, 0); I'm using Typescript so I'm just including the important snippets from various files. Create the height of the game to be the size of your tilemap. In my case I'm using 240 currently and then calculate the width based on the height as you can see above. Scale the game using SHOW_ALL so it will take full vertical space and not stretch. Then for each layer you create you must set the fixedToCamera and scrollFactor to be 0. Without these it won't work. I don't know why and would love an explanation as to why. Then finally calculate the X offset needed to center everything horizontally and apply it to the tilemap layers. Everything else you place in your game will need to be offset as well.
  13. 1 point

    [BABYLON.JS] Prosecution

    20 points is my best result. : ) Beautiful game. Firstly i tried to play with ASDW control, but looks like only 'D' works in that case. With arrows all fine.
  14. 1 point

    [BABYLON.JS] Prosecution

    Very cool! Got 39 points. How is the score calculated?
  15. 1 point

    [BABYLON.JS] Prosecution

    This is really fun! Can't break past 20 because I'm not that good but love the game!!
  16. 1 point
    Hi @viohlet, states are tricky at first. Here's a skeleton. Within the state callbacks (preload, create, update), this represents the current state, but you don't have to use it — you can keep using the game reference. let game = new Phaser.Game(800, 600, Phaser.CANVAS, 'showgame'); let menuState = { preload: function () {}, create: function () { // … onInputDown.add -> // game.state.start('game'); } }; let gameState = { preload: function () {}, create: function () {}, update: function () {} }; let gameOverState = { preload: function () {}, create: function () { // … onInputDown.add -> // game.state.start('game'); } }; game.state.add('menu', menuState); game.state.add('game', gameState); game.state.add('gameOver', gameOverState); game.state.start('menu');
  17. 1 point

    Move the Crates

    In level with flying something (11 i guess) they block if direction in which they want to go is blocked. Also i refined character moving. Addictionly in some case character get damage when leaving tile on which it has an opponent. Visually they don't touch me. But still is very good game!
  18. 1 point

    Move the Crates

    Love the styling. Feels really nice and polished!
  19. 1 point

    Move the Crates

    it's fun and polished, although I found the enemies kind of annoying
  20. 1 point

    this. usage

  21. 1 point
    @valueerror Thanks for posting. I think I saw your old post. However I didn't get that zip file. I'll try that shortly. I think I have everything setup and (mostly) working as expected. All but the tile collisions. Here is my code that I believe exactly matches your example... create: function () { this.game.stage.backgroundColor = '#EAEAEA'; var map = this.game.add.tilemap('WallsTileMap'); // Preloaded tilemap map.addTilesetImage('OfficeWalls', 'WallsTilesetImg'); // Preloaded tileset this.game.physics.startSystem(Phaser.Physics.P2JS); // If you use 'collide' function with the layer, then the tiles from the first (ID 0) tile till // the 100th element will collide with the other sprite //this.map.setCollisionBetween(0, 100); ball = this.game.add.sprite((SCREEN_WIDTH / 2) + 250, (SCREEN_HEIGHT / 2), 'blueBall'); ball.frameName = "00-ball-blue-up.png"; this.game.physics.p2.enable(ball); // This is the default name of the first layer in Tiled var layer = map.createLayer('WallTiles'); var mapObs = this.game.physics.p2.convertCollisionObjects(map, "WallObjects"); console.log('mapObs = ', mapObs); // Sets the world size to match the size of this layer. layer.resizeWorld(); // The camera will follow the player in the world this.game.camera.follow(ball, Phaser.Camera.FOLLOW_TOPDOWN); cursors = this.input.keyboard.createCursorKeys();},I used the polyline tool in Tiled to trace around my wall tiles and saved/exported as JSON. The JSON file loads and the walls display and the player moves around but the tile collisions don't happen. At the console.log line above, mapObs = []. So I guess this means p2.convertCollisionObjects is failing and Tiled collision objects aren't loading. The Tiled objects layer is definitely called "WallObjects". I do see all the data exported in the JSON file so I'm pretty stumped here. I think in one of your other posts you or another poster mentions completing/connecting the end of the polyline "exactly" or "precisely". I tried as best I could to exactly connect the ends of the polylines but this is pretty tiny on the screen even way magnified. Could this be my issue? Thank you very much for any advice :-) Mark