Can I simplify this 3D code?



Hey guys. I'm attempting to create a game similar to Shooty Skies (recommended by @Hoppertoscotch). I really like the style of it so I am trying 3D-type trees, characters, NPCs, etc.

You can find my little tiny 3D trees project I created here

Is there a way to shorten or simplify this code? There will be many characters and trees spawned probably so I am just wondering. Thanks!


It does look complex. I would have guessed that you could get "trees" like that with much less code. Of course, just about anybody else's code looks complex to me.

I would have to understand the rationales for each of the steps - in other words, what is is that you are thinking that convinces you that each step is necessary - in order to offer more feedback.

As far as I understand, you just want something that can spawn little trees in random places. What other requirements are there? I mean, on the trees? Is there some universal quality that you are trying to reserve hooks for in your code? That could be just as important to the question of whether the code is bushier than it needs to be.


Well, I was going for a look like this but a bit simpler:

The basics of the code is it creates a clone and it increases the value How Many? by 1. If that value is in between certain parameters it turns into the trunk/branch 1/branch 2. It creates another clone and stacks them.

Currently though I have to create a new value for each little tree's spot. I'm wondering about that...


Is a great idea! Although... I'm sorry to say, but I don't think that it can be 100% hopscotchified at the moment. A possibility could be to shorten the game. I have tried to make complex games before, and oh boy, they were laggy. Shooty Skies is an awesome idea, but I'm worried that it might be too laggy, and will crash. (Happened to me) here are possible ways to reduce it:
Reduce trees in your game
Simplify code if possible
Don't use "repeat forever as much"

I hope this helps!


You could use abilities, but change up the code a little bit.
But, a more faster way to do this is to randomly place your 3D objects with set position and random, but it can cause a disaster. (What I mean about disaster is that the trees could stack up or get very close to eachother.)
As @Follow4LikesOfficial is right about what he said, it IS impossible to do it in Hopscotch standards, but it can be possible.
I'm not a "expert" at coding, so I can't really explain.
Sorry! :frowning:


Good idea, but unfortunately I tried that. None of the blocks align (their position is truly random)


@CreativeCoder I never thought it would be brought to a 3D level......good luck!


That's what I meant by "disaster", @CreativeCoder.
Their position is truly random.