0 Favourites

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

  • 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.

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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?

  • no, you can do it just using system expressions

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
81 11,906
LaurenceBedford's avatar
LaurenceBedford
Unread hot topic
0 Favourites
[PLUGIN] Google Map
118 34,687
eryson27's avatar
eryson27
Unread hot topic
99 10,152
karshinkoff's avatar
karshinkoff