Place And Destroy Blocks

I’m trying to make game where I can place and destroy blocks, kind of like minecraft. Help? Assets: My Project7-21-2021_9-54-23.wick (12.7 KB)

First you need the world to be represented by a 2D grid. Each item in the 2D grid would be indexed by a 2D position – an x and a y value. You could have each item a number. And each number would represent a different block – 0 would be air, 1 would be stone, 2 would be dirt, 3 would be grass, e.t.c. Or you could have it a different data type, like strings.

For terrain generation, you can use perlin or simplex noise to generate a heightmap for the terrain.

Then, to draw the terrain on screen, you could have a singular clip for the blocks and each frame in the block clip would be for different blocks. Then you would make a clone for each block on screen (determined by the world 2D array) and move the block to the correct position.

Here’s a project I made that demonstrates this: (I used a JavaScript noise library from online)
Use WASD to move the camera, left click to place/destroy blocks
(An optimization I made is that it only renders blocks inside the camera’s view)
mc.wick (17.9 KB)

If you want more help with your project, I think instead of asking for help first, you should try looking for information online. If you don’t understand the information or can’t find any, then you should ask for help.


So good. I really like the camera system (Where you disappear the blocks that are outside of the screen).