- Home /
TETRIS STYLE - create a preview of the next block
Hello I am trying to add some code or a function that would show a preview of the next block that is about to drop in a game of tetris (foundation for the game taken from Noobtuts). I have created a GameObject that would be considered the space where the preview would be shown, but whenever I try different methods it literally crashes Unity everytime. A snippet of code that I was trying to do was have the block that is about to spawn and the block that is next pulling from the same array, as I'm not sure how I could go about setting bools to pull from one and then convert it to the block dropped.
From Group.cs:
//Fall
else if (Input.GetKey (KeyCode.DownArrow) && !Pause.paused || Time.time * LevelUpdater.fallTimer - lastFall >= 1)
{
//Modify position
transform.position += new Vector3(0, -1, 0);
//See if valid
if (isValidGridPos())
{
//It's valid. Update grid.
updateGrid();
}
else
{
//It's not valid. Revert.
transform.position += new Vector3(0, 1, 0);
//Clear filled horizontal lines
Grid.deleteFullRows();
//Spawn next Group
FindObjectOfType<Spawner>().spawnNext();
previewDropped = true;
//Disable script
enabled = false;
}
lastFall = Time.time;
}
Then this is the Spawner.cs:
public void spawnNext()
{
//Random Index
int i = Random.Range (0, groups.Length);
if (!Group.previewDropped)
{
//Spawn Group at Preview Spawn Window Position
Instantiate (groups [i], previewSpawnWindow.transform.position, Quaternion.identity);
}
if (Group.previewDropped)
{
Instantiate (groups [i], transform.position, Quaternion.identity);
Group.previewDropped = false;
}
}
Hmm... Hi xylofiso! Although it's not the answer you're looking for, just read this: http://gamedev.stackexchange.com/questions/16455/is-tetris-public-domain http://www.businesswire.com/news/home/20090910006464/en/Resolution-Litigation-%E2%80%9CBlockles%E2%80%9D-Announced-Tetris-Holding-LLC Long story short: There's a reason we don't see many Tetris clones. Guys that are holding rights to that title aren't particularly understanding nor forgiving.
Oh! And here's one more: http://arstechnica.com/ga$$anonymous$$g/2012/06/defining-tetris-how-courts-judge-ga$$anonymous$$g-clones/ (author even add some power ups etc. so it wasn't exact clone). Probably it's safier to create clone of some birds or bird game.
When the game crashes, do you get an error message? Have you looked in the player error log? I can't see why this would happen based on the code snippets you've provided.
DyrdaOrg, thanks for your negative feedback! Go shove it up your you know what, I don't care about your advertisements, I am trying to figure out how to make this, not read about why others can't.
tanoshimi, I am getting no error messages other than Unity has stopped working. Which is one of the reasons I brought it up here, due to not being able to get any error messages. I know it's probably just going to be a kick it in the head until it works solution, but hey, I figured if someone else was experiencing this, or if a Unity employee saw this, then maybe they could find out what kind of bug it is then remedy it. It's not the game crashing, it is actually Unity itself.
There are plenty of people here that can help you, but in order to let them do so it helps if you can be as descriptive as possible: "it literally crashes Unity" doesn't give us much to go on. So now we know that you're getting an error message, that's something (if you were "crashing" Unity with an infinite loop, say, then you'd not typically get one) - and have you looked at the editor log? http://docs.unity3d.com/$$anonymous$$anual/LogFiles.html
Thanks tanoshimi, I was unaware of a log file, and I still couldn't find the log under the filepath that was displayed on the link, but alas, I have found a bug reporter built into Unity, so I am going to go ahead and shoot them the folder with all assets in it, and maybe they can investigate further into this issue.
Hi xylofiso. First of all - you've got me all wrong. I'm not trying to be negative. I lost one of weeks to made "zombieskinned-tetro$$anonymous$$o-interpretation" a s an entry for a jam. It gave me nothing but the knowledge that I can't do nothing with my game. Because of links I gave you. Ins$$anonymous$$d of being aggressive and immature read what I wrote, next read "your reply", what's wrong with it? IT'S REPLY. Both tanoshimi and me wrote you CO$$anonymous$$$$anonymous$$ENTS. Because if we can't serve you solution we won't be na$$anonymous$$g it a REPLY. As for negativity - others did it before you - I promise. I just thought you might be interested in taking other course for making your first blockbuster since this is clearly leading you (as stated in my "advertisement" (stackexchange? seriously? maybe add unity answers and stackoverflow to your banned sites?)) into some legal problems. As for help... try my reply it's in C#.
Yes DyrdaOrg, I did take a sense a little hostility in your comment and countered with what I saw was fit. I am on this board to LEARN, I am no where near in the position to want to make any games for commercial use right now, so you going on about litigation of public domain and holding rights was understood by me as "Don't even bother learning how to make the game because you can't sell it". I never have had an intention of selling a Tetris style game unless there was a very unique twist to it, which I can not even imagine yet. See you claim to be able to make the game though, I can't. That is the difference, I don't care that you couldn't do anything after the jam. I want to make something to be able to put in the jam. Your looking at dollars and I'm looking at information. The more respectable response though I see is the preview of the game you made, not antagonizing me for wanting to learn. patoo
Answer by DyrdaOrg · Nov 22, 2015 at 08:33 PM
Try this for C# http://samentries.com/index.php/2015/05/28/building-tetris-with-unity/ I can also send you my old scripts if that would any kind of help. Long long time ago I managed to get that:
I apologize to the people who have to go through the Unity Answers for my incorrect placing of the comment in the reply section, I am new to this forum and mistakenly replied to my own question. If you have the scripts and are willing to explain how to get the preview of the next piece to drop, I would love to see them, but let's keep this in the scope of this forum, maybe a reply with the script that handles the next block dropping and an explanation? I would consider that a satisfactory answer. I am in no way trying to make a "blockbuster" game and I have already done the "bird" tutorial, and don't see how a "bird" game relates to "tetris" style in anyway and find that just as you "flipping me the internet bird" for suggesting such. I had attempted to look at that site beforehand but couldn't relate it to the way the tutorial I followed was written, so even then it might not be understandable for me le sigh