- Home /
Answer given, discussion keeps bumping to top of queue.
Making a Tetris. Help needed on; Making blocks stop at a certain coodinate so they dont go outside the camera view!
Hi people, hello again. I've been making my tetris but these are the two problems i really couldnt handle.
To explain the terrain:
I have a 80x160 board with a cube combinations that have 0.1 dept and 8 with and height per square. So this cube looks 2D from my camera and moves around freely. The rectangle board 80x160(Background) is about %30-35 of the screen and i will put score and stuff on right and left later.
1st Problem; Ok so i want my cubes to stop at the edges of the background. What i mean by that, at tetris when you go with the cube to farthest left, it stops going left. At right it stops going right, but you can still move it to other directions. I want to do that with a command like, "Disable left movement when cube is on bla bla coordinates or something". I can make a distance fucntion to stop movement, but " update() dist " is a very heavy function and i cant use that in every game i make. I want to learn the right way to do it with some kind of a coordinate variable.
2nd Problem;
a)How do i spawn new blocks with RNG.
b)How do i make sure i spawn one block when the other collides.(Probably with onCollisionEnter but still i wanted to ask)
As for the RNG and Spawning combination i have no idea whatsoever so i need help on that. I havent tried collision problem yet but i want to confirm if its true before wasting some large time.
I want to make the blocks rigidBodies that are unable to rotate or move to any axis(I'll move them with codes, i dont want any recoil when they collide). And when they collide with the terrain or any other block or Prefab replacement(There are four of them "L shape, T shape, I shape, CUBE shape blocks), they will be deleted and replaced with a Prefab(via Instantiate) that is also a rigidbody that is unable to move(or a kinematic body) with a diffrent texture and some light effects. And when this collides a new block will spawn. I'll spawn the first block with function Start() and others with onCollisionEnter.
On some tetrises that are things like, "NEXT BLOCK INCOMING SIGN ON THE RIGHT, BONUS COMBOS FOR PONTS, A VISABLE PATH GOING DOWN SHOWING WHERE THE BLOCK WILL LAND"
Like this : http://www.ressim.net/i/4627443
I'd really want to have an idea how to make them. Dont give me entire codelines, i am making a tetris to learn. Give me the ideas and main script names, i'll go on from there.
So are my ideas right, and how can i solve my questions. Any help is appriciated guys. PLEASE ANSWER IN JAVASCRIPT, i have "0" knowledge of C. Love you all...
There must be a half-dozen questions in there. This site is meant to help with specific issues not "how do I make this game"-scale issues.
Break it down, give it a try, keep it to one question per thread and you're going to get better results.
Actually there are only 2 questions here :). I just want 2 answers and some ideas. If you answer one of them, the 1st one which is the most dire at the moment i would be happy.
I was/am making a tetris game and my advice is:
$$anonymous$$ake a script that handles all of the tetris logic/moving around/etc internally (using a 2d array?)
When you are done with that, THEN display it in the world (I'm outputting using GUI.Box at the moment).
Basically: I think you are working backwards. You are trying to output your results before you have created the back-end to create them.
(almost) everything you need is in the scripting reference. Once you know what the functions are called (which will come from reading up/tutorials/looking at other people's code) it's all there, written in plain english. Personally, I keep the scripting reference open at all times when I'm coding. Understanding what that code is doing is paramount. Only then can you translate the logic you have in your $$anonymous$$d back into writable code.
For general discussions/general pointers, the forums are a better venue (every comment we make on this now-solved thread bumps it back to the top of the queue) and I suggest trying them.
For now, I'm closing this thread as I don't see a better answer co$$anonymous$$g for your question than what Eric has supplied. If you have further, specific problems, just open a new question.
@Shealei: it's just practice. If you understand 40% of the code, then you're better off than I was when I started. At the time, pretty much the only thing that existed was the first-person shooter tutorial for Unity 1.x, and I understood maybe 5% of the code. I had to look stuff up in the docs for literally every single line of code that I wrote. Just practice.