Hello everyone, I’ll warn you that I’m new here, so please go easy on me haha
So the other night I downloaded a Tetris clone that I saw on the Forums, for learning purposes.(Link is here http://forum.unity3d.com/viewtopic.php?t=5556) I thought it was great, so I tried to play around with it a bit. I haven’t changed any of the code so far, just visuals.
Anyways, I wanted to add scores to the game, and I looked at the code, and I basically, and I really had no idea where to begin :P. I have some programming experience, and I’ve read through the scripting guide, but like I said, I’m new haha
It somebody would be so kind as to help me figure out how to add scores, so that everytime you complete a line, it adds points, I’d be mighty thankful
I didn’t look at the example, but at its simplest, this will break down to just a few steps:
You’ll need a ‘score’ variable somewhere. The only real requirements regarding its location are that, one way or another, it’s accessible (directly or indirectly) from the part of the code that removes rows from the board, and from the part of the code that displays the score onscreen.
I’m assuming that somewhere in the code is a conditional of some sort that checks to see if a row has been completed, followed by a block of code that does whatever needs to be done when that happens. That’s where the ‘increase the score’ code should go.
Presumably you’ll want to display the score onscreen. An easy way to do this would be to use (e.g.) GUI.Label() or GUILayout.Label(). (You can easily convert the score to string form and submit it as content for the control.)
If you have any questions about the specifics, feel free to ask. (And maybe Eric will see this and offer additional advice that’s specific to the example code.)