Jump to content


Photo

YAMC - 2D Minecraft-Like World Generator


  • Please log in to reply
19 replies to this topic

#1 PrimuS

PrimuS

    GMC Member

  • GMC Member
  • 103 posts
  • Version:GM8.1

Posted 21 February 2012 - 08:31 PM

Yet Another Minecraft Clone v0.2 (in 2D)
GM Version: GM8.1

Description:
Your regular Minecraft-like 2D (Terraria-like, you could say) terrain generator that i've made in my spare time. Without caves. Just plain terrain. And it is pretty lousy, also. So why would you download it? Well, for one single reason.
It has infinite world generation (i hope it is truly infinite, lol). Well, that's not such a huge improvement over the others, but you may want to look at it.
It uses a kind of a chunk system as Minecraft had some time ago. The chunks are areas of the map 320x2048 (20x128 blocks; adjustable) - one view wide - in size. They contain all the blocks (duh) and, possibly, items, mobs, and everything else. Only three chunks of the map are present at the same time. When you leave a chunk beyond your 'render area' (that's three chunks currently: one behind the player, one where the player is currently situated, and one ahead), it gets saved as a simple binary file with its filename containing the chunk id (i.e. 0-320 will be the 0th chunk, -320-0 will be the -1th chunk, etc.) and all the stuff from that chunk gets deleted from memory, so your game would not lag. When a chunk enters your 'render area', it loads into memory, using that file that was saved previously. Or, if the chunk is actually completely new and no chunk file is present, it gets generated randomly. Pretty simple.
Oh, and it also has biomes. Three of them. And trees (if you can actually call these things trees. And flowers. And random seed support through the random_set_seed() function; it works almost as in Minecraft.

I'm not sure if that was done in GM before, lol. Thought someone would find it useful.

Instructions:
WASD - movement
LMB - place block
RMB - remove block
F - show/hide the debug info
R - return to the spawn
Terrain begins at y = 1024, so if you see nothing when you start the game, move down a bit.

Download:
Version 0.2. (.EXE + .GM81; ~1.8MB)

Changelog:
22.02.12 -- v0.2:
Spoiler


Known bugs:
- Seeds work pretty derpy, you can try fixing that by putting 'random_set_seed(global.map_seed)' in the beginning of the chunk_gen() script;
- After you reach distances that are ~15000 units away from your spawnpoint, some barely noticeable graphic artifacts begin to appear, like wobbly sprites and stuff. Tested on my PC only. Should be some GM bug;
- Only chunks (current_chunk - 2) and (current_chunk + 2) are cleared. That is enough when the player is moving smoothly, but when hopping distances wider than the chunk itself, it will leave uncleared chunks behind;
- Chunks do not get cleared when you teleport to the spawn (see the third bug);
Oh, and it does not overwrite previously saved worlds, if you select the same world folder at the start. Instead it loads them, but you can sure change the random seed at the start. So be careful with that.

Screenies:
Spoiler

Edited by PrimuS, 22 February 2012 - 08:40 PM.

  • 7

#2 PrimuS

PrimuS

    GMC Member

  • GMC Member
  • 103 posts
  • Version:GM8.1

Posted 22 February 2012 - 02:40 PM

Oh snap, i pressed 'Quote' instead of 'Edit' ocasionally. This should be deleted.

Edited by PrimuS, 22 February 2012 - 02:43 PM.

  • 0

#3 NicroGames

NicroGames

    GMC Member

  • GMC Member
  • 300 posts
  • Version:GM:Studio

Posted 22 February 2012 - 03:42 PM

Wow!
This is the best terrain generation I have seen in GameMaker. It is a bit slow when generating new chunks, but that's probably GameMaker's fault.
  • -1

#4 PrimuS

PrimuS

    GMC Member

  • GMC Member
  • 103 posts
  • Version:GM8.1

Posted 22 February 2012 - 04:01 PM

Well, thanks.
It saves chunks instantly after generating em, and also when clearing them in case any changes have happened since the generation/loading of these chunks. That's why it hangs a bit. It's not the best way of generating a map, so Minecraft now uses more advanced map formats, like its region system or whatever. And the terrain generating algorithm itself is not the best you can do.

Edited by PrimuS, 22 February 2012 - 04:04 PM.

  • 0

#5 Dylan93

Dylan93

    GMC Member

  • GMC Member
  • 867 posts
  • Version:GM8

Posted 22 February 2012 - 05:49 PM

Wow!
This is the best terrain generation I have seen in GameMaker. It is a bit slow when generating new chunks, but that's probably GameMaker's fault.


I completely agree with this, its a smart way and it works :)
  • 0


Posted Image


#6 AKSuperNewb

AKSuperNewb

    GMC Member

  • GMC Member
  • 140 posts

Posted 22 February 2012 - 07:40 PM

By the way, MineCraft still uses chunks. Just sayin :whistle:

This is pretty awesome. Great job!

Edited by AKSuperNewb, 22 February 2012 - 07:42 PM.

  • 0

Posted Image

------------------------------------------------------------------------------------------------->If I helped you, click this button, please:


#7 PrimuS

PrimuS

    GMC Member

  • GMC Member
  • 103 posts
  • Version:GM8.1

Posted 22 February 2012 - 08:07 PM

It does use chunks, but i think they're saved and managed using some other way, considered to be better by the developers. Thanks.
And anyone knows what's up with these little annoying artifact thingies? Any way to fix em?

Edited by PrimuS, 22 February 2012 - 08:29 PM.

  • 0

#8 BluePotato1994

BluePotato1994

    GMC Member

  • GMC Member
  • 185 posts
  • Version:GM8

Posted 05 March 2012 - 10:25 AM

It does use chunks, but i think they're saved and managed using some other way, considered to be better by the developers. Thanks.
And anyone knows what's up with these little annoying artifact thingies? Any way to fix em?


What are the artifact thingies? From looking at the first screenshot it just looks like normal terrain generation
  • 0
Posted Image
Stick Legends Online - Networking Programmer / GML Programmer Alpha out NOW!

Was this post helpful? if so click (+)


#9 PrimuS

PrimuS

    GMC Member

  • GMC Member
  • 103 posts
  • Version:GM8.1

Posted 06 March 2012 - 12:02 PM

What are the artifact thingies? From looking at the first screenshot it just looks like normal terrain generation

There's nothing wrong with the generation itself, but if you look close enough, you might notice that the text on the screenshot appears a bit distorted, compared to other shots. If you try the thing out for yourself, you'll see that the text and other sprites begin to 'wobble' after reaching ~100th chunk. That 'wobbling' increases with distance.
  • 0

#10 OldSkoolGamer

OldSkoolGamer

    GMC Member

  • GMC Member
  • 128 posts
  • Version:GM:Studio

Posted 06 April 2012 - 02:54 AM

That sounds almost like a floating point error to me. I'll download and test myself to see what's up.
  • 0

#11 gardian20

gardian20

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 21 April 2012 - 12:16 AM

Mind if i use it in my game?
  • 0
Well, i guess this is what we're called now....

Posted Image

#12 gardian20

gardian20

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 23 April 2012 - 01:08 AM

Hey, could i have a list of block type numbers? I could really use it.

Thanks!

-Please answer :D

Edited by gardian20, 22 May 2012 - 06:11 PM.

  • 0
Well, i guess this is what we're called now....

Posted Image

#13 PrimuS

PrimuS

    GMC Member

  • GMC Member
  • 103 posts
  • Version:GM8.1

Posted 07 May 2012 - 03:42 PM

You probably don't need it already, but just in case: they are identical to subimage numbers in spr_block.
And yes, you can use it in your game.

Edited by PrimuS, 07 May 2012 - 03:42 PM.

  • 0

#14 gardian20

gardian20

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 22 May 2012 - 06:11 PM

You probably don't need it already, but just in case: they are identical to subimage numbers in spr_block.
And yes, you can use it in your game.

Thanks! my little game would not be possible without it! :biggrin:
  • 0
Well, i guess this is what we're called now....

Posted Image

#15 ThePC007

ThePC007

    Chickenator

  • GMC Member
  • 1062 posts
  • Version:GM:Studio

Posted 26 November 2012 - 10:03 PM

The way you did the infinite terrain generation is pretty much exactly the way I did it. :)
  • 0

#16 Sirosky

Sirosky

    GMC Member

  • GMC Member
  • 1601 posts
  • Version:GM:Studio

Posted 13 January 2014 - 07:32 PM

Not to necro this topic, but great work. Just came across this and it's fascinating :)


  • 0

gcjRa8D.png


#17 aspire5732zg

aspire5732zg

    GMC Member

  • GMC Member
  • 2 posts
  • Version:GM8

Posted 25 May 2014 - 01:50 AM

Very nice example, i have a one small question. How to set the scripts on the view 800 x 600? I can't this set. I've a set 32x32 blocks but with this I have a problem. Sorry for my weak language english..


  • 0

#18 ThePC007

ThePC007

    Chickenator

  • GMC Member
  • 1062 posts
  • Version:GM:Studio

Posted 27 May 2014 - 04:09 PM

 

 

You might also use the instance_deactivate() function to improve performance.

 

You get the best performance by not using instances at all. :P

I made an engine that stores the entire world in a few buffers. It can store a huge world in memory and the FPS are FAR better than they would be if I'd use instances. Getting it to work properly was kind of hard, though, and I am still struggling with the platform physics. 


  • 0

#19 PrimuS

PrimuS

    GMC Member

  • GMC Member
  • 103 posts
  • Version:GM8.1

Posted 06 August 2014 - 08:48 AM

You're right, but this is just an example of how things can be done.


  • 0

#20 swyrl

swyrl

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 22 September 2014 - 12:18 AM

I've been trying to work out something like this for some time (mostly out of curiousity), but I've been unsuccessful, mostly due to the fact that I have absolutely zero experience w/ gamemaker's file I/O

Definitely going to dissect this. *puts on mad science goggles*

 

Incidentally, is plr_init supposed to be completely empty, or is that a problem?

 

Hmm, do you mind if I take this and mess with it a bit? I've been thinking for a while that the most efficient way to do a block system would be to abstract them, EG instead of actual objects use the necessary variables.

Of course, this makes physics and other fancy stuff like lighting a lot more difficult, and using objects seems to run just fine.


Edited by swyrl, 22 September 2014 - 12:43 AM.

  • 0

uyzd1z6.jpg?1