Highwire4 Posted July 16, 2013 Report Share Posted July 16, 2013 Hey all. So I'm making an infinite runner game and its going along pretty well. But I've hit an issue with the terrain generation that has just driven me into a brick wall. I've been trying to get it to work the way I want for the past week now with no luck. The way how it currently works is by randomly creating platforms from one green square. It does this REALLY well but the problem is that its nearly impossible to apply any kind of graphics to it or make it more diverse with different platform types. So I've been trying to re-write it to work more like how Canabalt makes its stuff (which I have no idea on a technical level). So what I want is instead of generating from one object and making only one kind of platform, I want to make it generate a bunch of different platforms, like buildings, cranes, etc. here's a pic of the generation code so far: I've been trying to look up similar programs to look at their code to maybe get an idea for how to go about this (since one of the best ways to learn code is look at a LOT of code) but I've had no luck. If anyone knows something like this that I can take a look at or has an idea for how to go about this I would be srsly grateful. Link to comment Share on other sites More sharing options...
Based LiBi (JoeyD) Posted July 16, 2013 Report Share Posted July 16, 2013 Here's how I would go about this in Java. For each different platform you want to make, you need a different object for it, and then you'd code out a chooser for the world generation. So say you got Platform and SpecialPlatform. SpecialPlatform is a group of action platforms that you would create. FallingPlatform, RisingPlatform, etc. "Platform" would be the platform you have now, stable and regular. "Falling Platform" would start to crumble and fall after the player stands on it for X amount of time. "RisingPlatform" would do the opposite of the FallingPlatform. Now the main chooser would choose between generating a Platform and a SpecialPlatform. Now, to pick which Special Platform that would generate, you need another chooser that picks between the RisingPlatform and FallingPlatfrom. You don't want all the Platforms under one chooser because then you would have a possibility of all the Platforms being one type. If you have 2 choosers, you can limit how many SpecialPlatforms generate. Link to comment Share on other sites More sharing options...
Highwire4 Posted July 16, 2013 Author Report Share Posted July 16, 2013 So let me see if I understand you. So I'd have two groups of platforms with their own group associated events that can only be activated by a randomizer that chooses between the two groups everytime it needs to spawn a new platform and once its chosen the platform, it spawns that platform in accordance with the rules specified for platform spawining randomization? Link to comment Share on other sites More sharing options...
Based LiBi (JoeyD) Posted July 16, 2013 Report Share Posted July 16, 2013 In short, Yes Having multiple groups of platforms will also help you define a graphics for that particular platform. Link to comment Share on other sites More sharing options...
Highwire4 Posted July 17, 2013 Author Report Share Posted July 17, 2013 Alright, I'll try it out and keep y'all posted to see if I can put together something that'll work. Thanks a lot man! Link to comment Share on other sites More sharing options...
Recommended Posts