Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About gsoutz

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

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

  1. I want to make an 2D endless runner, that also allows player to go backwards. So I have to create random world as the map goes, also keep the old map in case player goes back. I ask about how to update and render this program. I am thinking having a generate function that takes an x value and generates world from x to (x + chunk size) and when camera reaches x + chunk size, call this function again to generate more map: function source(x) { // generate world for x value }; And maybe use this function like: let worldThings = []; // push the world from 0 to chunk size worldThings.push(...source(0)); // called every frame to update world function update() { if (camera.x > chunkSize) { // generate more world worldThings.push(...source(chunkSize)); } } To render these something like: // object pooling for rendering things in view let renderPool = new Pool(); function render() { // release all objects renderPool.releaseAll(); // take things that are visible let renderThings = worldThings.filter(thingsInCameraView); // for everything allocate a resource in the render pool renderThings.each(renderPool.allocate); // render the pool renderPool.each(renderThing); }
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!