How do I place clusters of trees and stone on my map?

Get help using Construct 2

» Fri Jul 10, 2015 11:58 pm

The image above shows my game and the process that I made for creating my own randomly generated maps. I created an object that digs through the map and places tiles while randomly turning at certain points.

The problem I am having is I would like to make a game like the picture below

where the world is surrounded by water and has stone clusters and trees spawned in at random points on the land. When I try to use sprites I end up getting poor performance so I modified my "digging generation" code to work with tiles. I am left with no clear idea on how I am supposed to:

1. Surround the play area with water
2. Create clusters of stone and trees on the land that the player can interact with (this is REALLY confusing when using tiles instead of sprites)

I understand that I will end up having to use a bitwise tile method to make each tile connect but I am confused with the map generation process that would be involved with this.

My method was quick and dirty and I am sure there is an easier way to accomplish this.
B
18
S
4
G
4
Posts: 61
Reputation: 3,150

» Sat Jul 11, 2015 6:57 pm

for the map generation I would use a seeded perlin noise generator, in much the way you would use to create an island in 3D but just set it so if the height is greater than x the tile is land, and if it is less then x it is sea. See here. It is important to seed the generation else it wont give you an island, but instead areas of water and land in a cloud-like pattern.

As for the trees and rocks you could use a loop while x is less than the number of tree areas you want, pick a random position. If that position is empty land, then continue, else break. Then from that position, place x trees by moving random values (within reason) in x and y and placing trees there until you have x trees in the area. The same can be applied to the rocks. As for the interaction, when the player wants to move check that its not into a rock before allowing the move, if it is, prevent the move. If the player is looking at the coordinate of the tile given +- arctan(width-of-tile/distance-from-tile) degrees and is a suitable distance from the tile then a use key should do the required function.
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

» Sat Jul 11, 2015 11:40 pm

briggybros wrote:for the map generation I would use a seeded perlin noise generator, in much the way you would use to create an island in 3D but just set it so if the height is greater than x the tile is land, and if it is less then x it is sea. See here. It is important to seed the generation else it wont give you an island, but instead areas of water and land in a cloud-like pattern.

As for the trees and rocks you could use a loop while x is less than the number of tree areas you want, pick a random position. If that position is empty land, then continue, else break. Then from that position, place x trees by moving random values (within reason) in x and y and placing trees there until you have x trees in the area. The same can be applied to the rocks. As for the interaction, when the player wants to move check that its not into a rock before allowing the move, if it is, prevent the move. If the player is looking at the coordinate of the tile given +- arctan(width-of-tile/distance-from-tile) degrees and is a suitable distance from the tile then a use key should do the required function.

I see, would I need a plugin to use this method?
B
18
S
4
G
4
Posts: 61
Reputation: 3,150

» Sun Jul 12, 2015 7:55 pm

no, you can do it just using system expressions
B
24
S
5
G
1
Posts: 434
Reputation: 3,446