This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-03-31 12:50:46

kidomat43
Scratcher
Registered: 2009-08-17
Posts: 11

Infinite Fully Destructible Terrain - Minecraft in 2d

Infinite Fully Destructible Terrain

http://oi47.tinypic.com/244yvs2.jpg

The map
Drawing the map
This game works by having a quad core drawing system (ie: 4 sprites are used to stamp draw the terrain) and a dual core update system (2 sprites re-stamp draw blocks that have changed, see the DrawQueue). There is no cloning to be seen here, and because of that it is a lot easier to manage the code.
The map gen on this is pretty basic, but it still fun to play.

Updating content
In this game, trees and grass grow.
Cacti do not as they are added on map generation

Map generation
The map generation is very basic at the moment: it is basically just a short sine wave to a bumps, and a long sine wave to add islands and biomes.

Physics
The player reads from the map and works out which block is where, and so collides with that block. There are no hacky color reading methods.

Data structures
The core of the game is the map list, and consists of a list where each item is a column of the map.

For example, the first column to the left in the example image is
sssssddg
which indicates 5 stone blocks, and 2 dirt blocks, and a dirt block with grass.

The main working frames are the queues.
Queues are lists that allow actions and tasked to be prioritized and ordered.

EditQueue
This list is a queue that a sprite reads from and performs map edits. Items in this queue follow the format:
positionX,positionY,targetID
Where targetID is the one letter identification code for the block that should be placed there. When the map edit is done, the node position is passed to the DrawQueue.

DrawQueue
This list is a queue that the dual core update system reads from, and then re draws that block. The format for this list is:
positionX,positionY
Because there are two sprite parsers, two DrawQueue items can be updated at a time

Specs
Complete render time (quad core): 1 second
Map generation time (per 30 columns): 7 seconds
Time to edit block (Edit+Draw Queue): 0.1 seconds

What now?
I will be improving the map generation quality, and using Scratch 2.0 to add mobs in version 2.0 of this.


KIDOMAT43 / Rubenwardy
My Website: www.multa.bugs3.com

Offline

 

Board footer