Jump to content

Search the Community

Showing results for tags 'object layer'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 3 results

  1. Hi everyone, Anyone knows how i could convert a object layer from tiled(with rectangle, circle...) into a P2 object/sprite or whatever ? I would like that my player can check if there's an overlap with theses objects :/
  2. Hi there. So currently I have a single player open world game which I am in the process of developing multiplayer for. The current system of map gen is local, and done through a bunch of arrays lol. I chose this route LONG ago, and I know it wasn't the best option, but it was easier for me to throw this together than to learn how to used tiled and object layers etc. Using arrays seemed easier to me because I understood how I can respawn/kill dead objects from the array instead of having to learn tiled's object layer stuff. Anyway, my current system is as follows: At the top of my game basically I have something like this run PS: (The map is 2k x 2k TILES long, each tile is 32x32 so map is 64k x 64k pixels) var mapSize = 2000; var grid = new Array(mapSize).fill(0); for(var i = 0; i<mapSize+1; i++){ grid[i] = new Array(mapSize).fill(0); }; for(var i = 0; i<18000; i++){ var tempX = Math.round(Math.random()*(mapSize-1)); var tempY = Math.round(Math.random()*(mapSize-1)); if(grid[tempX][tempY] == 0){ grid[tempX][tempY] = 2; } } for(var i = 0; i<12000; i++){ var tempX = Math.round(Math.random()*(mapSize-1)); var tempY = Math.round(Math.random()*(mapSize-1)); if(grid[tempX][tempY] == 0){ grid[tempX][tempY] = 3; } } This is an example of how i am generating the map. Basically it creates a 2 dimensional array with values 0, 2, or 3 in this example. My rendering system is shown bellow, basically spawn any non 0 entry within 3k pixels of the person (or 91 tiles) by reading the map array from points based on the players current position: function mapGen(x1, y1, x2, y2){ if(x1<0){ x1 = 0; } else if(x2>(mapSize-1)){ x2 = mapSize-1; } if(y1<0){ y1 = 0; } else if(y2>(mapSize-1)){ y2 = mapSize-1; } for(var row = x1; row<x2; row++){ for(var col = y1; col<y2; col++){ if(grid[row][col]!=0){ temp = position(row, col); if(grid[row][col]==2){ createSprite = itemGroup.create(temp[0], temp[1], 'tree'); createSprite.scale.set(1.1, 1.1); } else if(grid[row][col]==3){ createSprite = itemGroup.create(temp[0], temp[1], 'boulder'); } createSprite.body.immovable = true; } }; }; } This is the render system that is called whenever a player ventures 3k pixels away from a position (The function variables are the corners of the 3k x 3k box around the player in tiles), when called, the position it's using as reference is changed to the current position of the player, so basically it just renders 3k pixels around the player until a player moves to far from that squares center and renders a new one, I do this bc the game cant handle more than a couple thousand sprites on the screen, and doing this lets me have like 200 rendered and have flawless performance. This system works fine for what I need, if there is a 0, leave it blank and the tilesprite background will show, if there is something there then spawn a tree or a rock or whatever said item is (This is just dummy code). For destroying sprites once a player destroys a sprite I get the pixel location of the now dead sprite and change it into tile position and set that tile position to 0. Which is why i chose this system over tiled, it seemed easier to me. Now finally, here is my problem: I have created a lot of the multiplayer aspect, and all the connections and player positions etc. However, the map is still different on every players screen due to the random gen that happens every time game loads. I can create the giant array on the server, however there is no way I can transfer it to the players. Creating the giant array only takes 300ms which is kinda a lot in terms of performance for my game, but if i render it once on the server and send it to every client my server crashes, i assume its because its wayyy too much data or takes too long. I tried writing it out to a file to read then from my clients but that's 11mb lol and I dont know where to smoothly read something like that. So basically, what are my options here. I would be open to switching to tiled, however i dont know how to randomly generate terrain there, and cant do it manually, as well as i like the system I have now bc how easily i can manipulate it. Another solution I have yet to try but I might, is instead of sending the entire map file, just write a file or a variable i could send through sockets with where all the non 0 items are around the array to cut down on space and increase performance. This was kinda poorly written, however I appreciate anyone who took the time to read this, I always chose bad times to write forum posts and right now Im in a rush so I didnt get a chance to re-read this and make myself not sound like I have the English skills of an 8 year old. So if anything needs clarifying let me know! Thanks again for the help.
  3. I am testing a racing car game. For that I make my road in tiled map editor and using its json file in phaser. It is 50 tiles in height. Now I want to extend my map. I have two options , extend it through phaser or make whole extended map in tiled map editor. Which one is better and how can I extend it through phaser ? I have no idea about this. I also want to add an object layer on my background layer, so that my car collides with other objects which will be on my background layer. I have already searched object layer problem in this forum, but not satisfied. I am also attaching files , may be I am not clearing my question... plz help me out..test game.zip
×
×
  • Create New...