Development Alternatives to tiles when outside room [SOLVED]

jamyers

Member
I've created an "infinite" world with chunk loading. I've been testing and searching around for an answer for the past few hours and I can't seem to find anything.

I wanted to use tiles originally, but they only fill in in the actual room which in the case of this game is not very big. The main problem is that because the game allows you to go past the room border, and even into the negatives, from what I've gathered, I won't be able to tile because game maker doesn't allow it? .

I've tried adding sprites to an asset layer, but as you can imagine, after a certain threshold, my frame rate tanks, as to be expected. I didn't see a way of clearing an asset layer though.

I've also tried drawing sprites just inside of the view along my "chunk grids", but for whatever reason that was really choppy even when my fps was in the 400s... I'm assuming I coded it poorly, and I'll try again tomorrow. But in the mean time, are there any other work around to placing tiles outside of the room? Or maybe some other ideas my sleep deprived brain is struggling to come up with?
 
Last edited by a moderator:

Yal

🍋 *lemon noises*
GMC Elder
If you have infinite chunk loading, you should also have chunk unloading... basically, when stuff goes out of the view far enough, remove them from the room. Then the asset layer approach should work just fine.

Another approach: instead of creating and destroying tiles all the time, compute your terrain using an infinite noise function, and just draw the terrain corresponding to the view's current position. Now you only need to keep track of the current world position (through the draw loop might be a bit slow)

A primer on what noise randomness is (watch the entire thing if you can't tell the difference between noise randomness and a traditional pseudo-random generator off the top of your head):
 

Japster

Member
Hi @jamyers...

You've probably already checked out @Yal 's advice and that great link, and tbh, I think that there are many approaches to this (most of which I'm guessing yal, with their experience, has tried and used, or dismissed for various good reasons! - Your query is marked as solved, but I'm intrigued on how you sorted it in the end!

i.e. I was thinking....

Couldn't you have a larger room, smaller camera, and simply adjust the layer's X and Y or as @Yal suggests, draw the surrounding tiles - if you're storing your map data anyway (ie. to a persistent grid, etc), you can use that to render the tiles on-screen, and just outside of the view? ..ie The player does not move, but the tile layer contents are updated to give the impression that they are?

Also, I've had very, VERY, large rooms in terms of 10's or thousands of tiles across / high, and didn't notice any performance issues with a view that does not show ludicrous amounts of them at once - you could create a huge room with a smaller viewport into it, only updating and rendering the tiles around the player, and when nearing the edge of it, fill in a more central viewport area's worth with the new 'area's tiles, and 'snap' the player to that location? - The player would be oblivious to this relocation (Note - this would only work if you're storing the source world data in a data structure, as opposed to ONLY in the tile layer, thereby over-writing it.)

...or you could do it via this method:- If you're smooth scrolling, you could go old-skool, ie:- smoothly scroll the tile layer (or camera) around, offsetting the X/Y position, until you hit an exact X/Y tile 'grid' position, then hard 'shift' all on-screen tiles across by one tile grid cell, and reset the layer or camera's X/Y position. Conversely, If you're NOT smooth scrolling, you need simply do the latter? - just shift by one grid position each step!... (Both of which we used to do on the ol' C64 / 8-Bits... :D )

If the player is 'moving' around a virtual space, and you're displaying that local environment around them, couldn't you just use their 'virtual' location to offset the chunker's rendering source grid, to always display the 'tiles' in that area on the actual tile or asset map, therefore not hitting the tile layer boundary?

Sorry if I'm not great at explaining this sort of stuff!
 

Yal

🍋 *lemon noises*
GMC Elder
~









On a serious note, deleting post contents is considered rude since it retroactively diminishes the value of the entire discussion, not just your own contributions. Please use the "delete" button instead.
 

Japster

Member
~


On a serious note, deleting post contents is considered rude since it retroactively diminishes the value of the entire discussion, not just your own contributions. Please use the "delete" button instead.
...not to mention that my curiosity is now driving me crazy.... :(
 

jamyers

Member
I deleted my replies because they just turned into me bitching about my failures as a game developer and then slowly turned into me bitching about never being able to get help on this forum.. which made no sense because you guys had responded (prior to this topic though, I could never get help, and ended up getting a handful of dead topics deleted by the mods because there were like 2 years old with no response). It was just me ranting about months of frustration developing a bunch of failed projects... So i deleted the replies because in that time I've pretty much decided to completely give up. (about 4 years of failed projects, projects that received little to no players as well as my frustration with how game maker operates on Mac, and how I think the newest update sucks).

Going back to what @Yal was saying, yes I was using a crude version of noise to generate the terrain and I was already activate/deactivate chunks, but that didn't solve the problem of trying to save memory by drawing tiles instead of drawing sprites.( I read somewhere that tiles were much more efficient than drawing sprites) I couldn't find a way to just drawing actual tiles because they can only be drawn in the "room". Because I was unlocking the camera allowing for chunk generation to go into "negative values", the tiles just wouldn't work or at least not what I could find. So I was stuck drawing sprites instead of tiles for my terrain. I like building games for mobile, so part of the problem that I continue to run into is that my frame rate is choppy when I activate/deactivate objects. Just for an example, I'd use a parent object for all my level objects(trees, rocks, grass, ect) . Then I would have variables to stores my players location. Once the player got a certain distance away from the stored valued, I would activate/deactivate the parent objects and chunk objects and the frame rate would stutter. The stutter increases as you add more objects, as you'd expect. But there's even a stutter when activate/deactivate just chunk objects as well. So It just wasn't working how I wanted, and It was becoming more of a headache than what it was actually worth. I was also running to other problems with how the game ran if I got too far away from the original spawn location (0,0). It felt like the game was struggling to properly sync up my variables if my player objects location was (10 million, 10 million)... and the problem would get worse if I continued further, or lessen if I got closer to spawn. very strange...

So because I originally added nothing to further the conversation, and because I scrapped the project, I decided to just delete my garbage and allow people to still stumble across the information you guys added, just in case someone else was following a similar way of developing their game.
 
Top