? Placing a bunch of trees (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Contest results!

Placing a bunch of trees

  • #1 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself I'm trying to put trees in random places and I can't do it. I'm trying with VAR and Dim like this : DIM Tree%(5,1) Tree%(0,1) = 0 -Age of tree I want 5 trees using the BG and I dunno how to put them with this code.... Posted
  • #2 ✎ 60 seggiepants VAR MAXX = 400 / 16 VAR MAXY = 240 / 16 VAR TREE = 107 'Dont know the right index, replace with desired tile id BGSCREEN 0, MAXX, MAXY FOR I = 0 TO 4 REPEAT X = RND(MAXX) Y = RND(MAXY) UNTIL BGGET(0, X, Y) != TREE BGPUT 0, X, Y, TREE NEXT I I typed that without testing in SmileBasic, but is that what you are looking for? The repeat until loop is to make sure each tree goes on a new tile. Posted
  • #3 ✎ 54 dfrost2 Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Minecraft Is Awesome! I love Minecraft! Express Yourself you use [] for arrays, not () Posted
  • #4 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Thanks for the help guys. It's partially working. I have to tweak it. Posted
  • #5 ✎ 60 seggiepants I would change tree to 100 in the example for a better tree picture but otherwise the code above just puts some tiles on the BG graphics layer. I wasn't using arrays, RND is a function call to the random number generator. BGGET is also a function call that gets a tile id from the BG graphics layer. If you need it in an array I would just create tree_x and tree_y empty arrays then push the values in. Instead of bgget you would have to loop through the array so far looking for a duplicate x and y location. Hope that makes sense. Let me know if you have questions. Posted
  • #6 ✎ 54 dfrost2 Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Minecraft Is Awesome! I love Minecraft! Express Yourself
    I'm trying to put trees in random places and I can't do it. I'm trying with VAR and Dim like this : DIM Tree%(5,1) Tree%(0,1) = 0 -Age of tree I want 5 trees using the BG and I dunno how to put them with this code....
    notice the DIM Tree%(5,1)? That is what I'm talking about.
    Posted