My game currently features gargantuan single-room levels but, simply put, they're too damn big and slow down the game.
That said, I'd like to take a Kirby approach and have small/medium sized rooms with doors that bring you to other rooms (not like Metroid, like Kirby!) These rooms combined would create a single level.
The problem is how to go about this..I could
Have all the rooms in a single layout and create camera zones to restrict the camera to one room at a time. When the player enters a door, he's simply teleported to a different room & camera zone.
Problem with this is the levels will now be twice as big as they were in the first place, as every single room is crammed into a single layout, all running at the same time.
Have each room in its own layout..but then we're talking 5-10 layouts for a single level, which could get very messy very fast. I'd like to avoid this at all costs.
Create an array-based level editor and load the levels and rooms externally as you go, keeping the entire "game" in a single layout. Unfortunately, to my knowledge this isn't even remotely possible in C2 - arrays can't even be saved or loaded. My ignorance of web-based game development is really screwing me here.
So yeah..anyone have any ideas? I'd love to hear them!
(Sorry maybe I should've posted this in the "how do I" section)
In my experience many objects doesn't slow down as much as testing collision with many objects. The built-in behaviors that respond to solid collisions will cause a major slowdown when there are many solid objects.
I did an experiment with a very big level with over 6000 collision tiles. Since it's grid based I used an array to store whether or not a particular grid position was solid. I then position 9 "col" sprites with the solid behavior around the player so that the built-in behavior has something to work with. So now instead of collisions being tested against 6000 objects they will only be tested against 9.
That is genius, and so simple! Why is this not built-in?! Anyhow. I might attempt to implement this with my player, enemies, and items (would be easier with containers) but it gave me a few other ideas as well. If I go with option A then I'll be using camera zones, which will allow me to "deactivate" and make invisible all objects outside of the current zone, which should be enough. I could also attempt to destroy all previous rooms since there is no backtracking. That will only improve performance as you progress but hey, it's something.
I'm not sure I understand, are you saying you check the tile position of the player (and the the tiles which surround him), and for any tile that is solid you spawn a temporary invisible solid box?
Another option is to use sprite bank to save all the instances in a layout at the start of layout, then delete all the ones for the other rooms you're not using. Then when you switch rooms, load them all then delete all the ones you're not using again.
Also, you can help the fps by deactivating the solid behavior on objects that are far away.
Creating an array-based level editor is possible, but it's not exactly a smooth, easy process. What I'm doing currently is saving the instances of an room with sprite bank, then storing the JSON string (an array saved as a string) it makes for each room into the CSV plugin (an array with named columns and rows), then saving the JSON string of that to webstorage, then when the level is complete, I copy the JSON string to the clipboard, paste it to a word processor, do a find and replace on the " to "" so C2's expression editor will accept the JSON sting in an expression, and paste it into C2.
Yeah. Not exactly simple. Also keep in mind web browsers limit webstorage to 5 MB, so if your areas go above that, it messes up the whole process, and the only option I can think of is to use different CSV's for each level, and then I have to swap out which one I'm working on using the filesaver/filereader plugins, which can't load stuff automatically, so I have to use a file selection window each time I want to switch levels to edit them.
Yeah, but the temporary collision box is only created for the tiles immediately around the player.
Develop games in your browser. Powerful, performant & highly capable.
Arima Wow sprite bank sounds incredibly useful here. I will look into it! And yes, creating a level editor in C2 seems infinitely more difficult than creating one in CC. I want to say it's not even worth the trouble. I'm glad to see there is a .tmx importer and such, but in the end I highly doubt that will cut it.