Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / randomly placing trees but not in water?

Author
Message
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 26th May 2006 21:13
im trying to come up with a way to randomly place trees only on ground & not in my river.if i use a for next command how could i do this???

heres a pic for example:

Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 26th May 2006 21:16
you could somehow detect if the tree is in that area and if it is just delete it.

Pirates of Port Royale
Live the life of a pirate.
Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 26th May 2006 22:17
if object hit(water, tree) then exclude object tree


Or just set the rnd value less

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th May 2006 22:18
Depends on how your land is. Is this placing sprites on a 2d image like you show? or is it actually in 3d using tree models and a matrix.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 27th May 2006 01:32 Edited at: 27th May 2006 01:33
its placing trees in 3d.

i thought of a way to keep the trees out of the river,check if the y position is greater than certain # but,

1 other question related to this,how would i make sure the trees arent inside each other??
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 27th May 2006 01:56
make a for loop
in this loop

randomly place a tree within the given size of your map.
if the tree is lower then a certain height re randomly place it
if the tree collides with another tree re randomly place it.
if these conditions are all met you will end up with trees
placed on your map while not touching and not lower then a given height.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 27th May 2006 03:10
well,how would i code the check for the specific tree its placing colliding with other trees that has already been placed?
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 27th May 2006 03:13 Edited at: 27th May 2006 03:14
check the current tree your placing with all trees currently placed

some variables would manage this/


current_tree eg: 6
current_placed_trees eg: 5
total_trees eg: 10

the current tree is always going to be one more then the currently placed tress on the map.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 27th May 2006 03:20
oh,ok.im starting to get an idea.
something like:



thanks!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 27th May 2006 03:32
good luck kimosabi

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 27th May 2006 23:10
Quote: "if the tree is lower then a certain height re randomly place it"


Is that your solution to the river problem? What if the rivers weren't the lowest part of the map (like a waterfall)?

Another idear;

Have two seperate objects, one for the grass, and one for the river. If the river is an object check for intersection below each tree after placing it to see if its above the river, if so reposition it. If the river is a matrix, check if the object is within a matrix tile of the river, if so once again re place it.

David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 28th May 2006 03:40
well,ive decided to use a poly check to see if the n tree is touching another tree or river.i dont think this will kill framerate,since its not going to be checking for this throughout the whole game,just when its placing it.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 28th May 2006 10:14
that was a simple solution I gave to a new coder yes.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 28th May 2006 16:41
I wasnt critisizing the solution its fine if he has his water as the lowest part of the matrix. Though David has been around for about a year now, so I was assumming he might've looked into using Intersect Object by now.

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 28th May 2006 17:18
Or just turn the landscape into a grid, put a number 1 in the grid sections containing water, and only place 1 tree in each grid section. When placing a tree put a 1 in that grid section. So basically it all just an array.

Login to post a reply

Server time is: 2024-11-27 18:55:25
Your offset time is: 2024-11-27 18:55:25