Osc blog header photo
Osc's c-blog
Posts 1495Blogs 38Following 0Followers 13



Game In Progress: December 2020


Intro header

Short and sweet. Again...

Still having issues with getting the shape to turn. This was really cutting into my time doing other things in the past, so I figured I'd at least finish a different process of the game. This bit of code was for randomizing the shapes to load  during the start of the game. Luckily, this was probably the easiest thing I've done so far.

There's only 7 shapes right now because of the small scope of the game. It was simply a matter of referencing those different names when picking the asset from the location.

Code to store shape names

What's happening above is that I put the shapes into a list called a string array. As we will see, the index variable will come in handy to pick which file name to choose in the list with the help of a different bit of code.

Code to load radnom asset

The shapeIndex variable is set by picking a random number between zero and the length of the list - in this case it's 7. After that, I pick a shape in the list based on the number we got from the shapeIndex variable. This name is stored in the variable called initialShape.

Whatever name in the array that was chosen is then used in the next bit of code which actually calls the asset from the location. So it could be "3-D Shapes/Shapes/" + "Cone" (or some other shape name) which obviously creates the filepath 3-D Shapes/Shapes/Cone.

The shape is then saved onto a variable, which lastly, gets loaded as the variable 'shape'.

And presto, we get a somewhat random shape each time. Beautiful!

Now to work on that shape rotation issue 😒😒.

Login to vote this up!


CelicaCrazed   15



Please login (or) make a quick account (free)
to view and post comments.

 Login with Twitter

 Login with Dtoid

Three day old threads are only visible to verified humans - this helps our small community management team stay on top of spam

Sorry for the extra step!


About Oscone of us since 9:37 AM on 11.12.2011

Talk, play games and make the funnies.

Twitter: https://twitter.com/oscmolo