• 13
• 18
• 19
• 27
• 10
• ### Similar Content

• Hi everyone! I'm currently working on a series of books about 2D Shader Development.

The idea is to synthesize a bunch of techniques that are specifically useful for 2D, even if they work on 3D as well.

I released the first book last week. It's 4.99 on Amazon or free on the series website, https://www.2dshaders.com

This is an independent initiative, I don't work for any publisher whatsoever. The contents of the books are the result of a 4-year span where I started teaching this in Argentina and USA, always making the workshop better. Now I'm expanding it to make more sense in book form.

I'd love to hear your opinions on the idea and if you get the book let me know what you think.

By the way, the examples are in Unity, but the concepts from the book should be easily transferable to any graphics api/engine.

Hope you like it!

• While looking out for that pesky Terrator, our little alien is doing a bit of relaxed mining down on the new gas planet "Lelantos" this weekend....

• I have a native iOS game (objective c, XCode build) which I am considering to port to other platforms.
Core gameplay is based on solely on geographical maps, and custom drawing over maps. It also has Core Data. This part is complete in development.
What is not done yet is: monetization, gamification (leaderboards, challenges) and multiplayer functionality.
As I think more about it, I am tempted to think if this is the right time to move to a cross platform tool such as Unity. But before dedicating time to port my 5 years side-project effort in Objective C, I really want to know if its worth it.
- Does Unity support such plugins / assets that will fulfill all my above requirements?
- Unity Personal seems to have only 20 concurrent users - is it too costly scaling if I decide for extending to web and android platforms?
- What is the general workflow involved in publishing to iOS, Android, PC, and web platforms while using Unity? I mean to ask about various points of signing stuff, paying fees and getting certified.
- How long will it really take to port my entire Objective C project into Unity? I am somewhat familiar with C# but I am finding it hard fidgeting with Unity IDE as lot of things are focused around FPS and 3D while my game is still 2d - not much action involved. I seem bit overwhelmed by the list of features I see there. All in all, I do not want to lose my momentum while still making sure its portable to everywhere.
- Any assets I could use (for free to try basis in debug) that are relevant for my game?
- Last but not the least, are there any costs that I need to be paying upfront to Unity, for using it (apart from their monthly subscription model)? I don't understand their costing for multiplayer in conjunction with their subscription fees - if someone could kindly elaborate.
• By GytisDev
Hello,
me and few friends are developing simple city building game with unity for a school project, think something like Banished but much simpler. I was tasked to create the path-finding for the game so I mostly followed this tutorial series up to episode 5. Then we created simple working system for cutting trees. The problem is that the path-finding is working like 90% of the time, then it get stuck randomly then there's clearly a way to the objective (tree). I tried looking for some pattern when it happens but can't find anything. So basically I need any tips for how I should approach this problem.
Use this image to visualize the problem.
• By aymen
please any know how can i' calculate the centroid from any number vertices

# Unity The Quest for Tetris... Part 2

This topic is 3918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello all, Continuing from part 1, I have even more problems with my code. (Ok, so only one right now, but I'm pretty sure that it's messing everything else up) PROBLEM 3: My line-removing code doesn't work correctly. It funks out and makes weird patterns. So I'm placing the brick and then it cleared all the lines on top. Then I placed it again and it made weird lines which went away when my brick hit it. Many thanks in advance for the help. adam_o UPDATED CODE EDIT 1: Updated code, updated Problem 3. [Edited by - adam_o on June 9, 2007 9:02:31 PM]

##### Share on other sites
Sounds like an off-by-one error. Remember that C++ arrays start at 0 and go to n-1.

##### Share on other sites
Quote:
 Original post by RavuyaSounds like an off-by-one error. Remember that C++ arrays start at 0 and go to n-1.

I don't think it's off-by-one, because that kicks up the debugger... I had that happen between Problem 2 and Problem 3, but I was able to get the help on that one... nice try...

##### Share on other sites
Quote:
Quote:
 Original post by RavuyaSounds like an off-by-one error. Remember that C++ arrays start at 0 and go to n-1.

I don't think it's off-by-one, because that kicks up the debugger... I had that happen between Problem 2 and Problem 3, but I was able to get the help on that one... nice try...

Not quite. Off-by-one errors are simply miscalculations of location by one, because you forgot to compensate for a starting point or such. First, this is not guaranteed to cause an error, if you overrun an array, so it may or may not crash/invoke debugging. This is not something you can rely on. Second, the off-by-one error may not even be causing you to overrun the array, which would not even generate a potential for an overrun, so a crash/debug wouldn't even happen. It is merely a logic off-by-one.

If you're code is removing a line above the one you want to remove, you probably do, in fact, have an off-by-one error. Check you're code for calculating which row to remove. In a C++ array, the second item is index 1.

##### Share on other sites
I looked at your code and I'm not sure where the problem is, but I wanted to say 3 things:

1) You should create helper functions that operate on a whole row (check if it's full, clear it, ...). This will make functions like check_clear_row() much cleaner (and less error-prone!).

2) In the loop, why is the first index of the array always 0 on the right?

3) Why did you choose to have the the array as -
arr_tetris_screen[Width][Height]? Arrays are row major so switching between the width and the height will make the code more intuitive.

These are just quick suggestions, sorry if I misunderstood your code (regarding 2 and 3).

##### Share on other sites
Quote:
 Original post by DaishimNot quite. Off-by-one errors are simply miscalculations of location by one, because you forgot to compensate for a starting point or such. First, this is not guaranteed to cause an error, if you overrun an array, so it may or may not crash/invoke debugging. This is not something you can rely on. Second, the off-by-one error may not even be causing you to overrun the array, which would not even generate a potential for an overrun, so a crash/debug wouldn't even happen. It is merely a logic off-by-one.If you're code is removing a line above the one you want to remove, you probably do, in fact, have an off-by-one error. Check you're code for calculating which row to remove. In a C++ array, the second item is index 1.

I understand this. It doesn't just remove the line above though, it removes every line.
Quote:
 Original post by Gage64I looked at your code and I'm not sure where the problem is, but I wanted to say 3 things:1) You should create helper functions that operate on a whole row (check if it's full, clear it, ...). This will make functions like check_clear_row() much cleaner (and less error-prone!).

That sounds good. I'll add that to the code.
Quote:
 2) In the loop, why is the first index of the array always 0 on the right?

The first one of the set is always 0, because that's the first one I decided to remove. I didn't really decide to do it in any particular order, just that it's easier if I just do it from low to high to remember. I didn't entirely understand the question, so that's what I hope you're asking.
Quote:
 3) Why did you choose to have the the array as -arr_tetris_screen[Width][Height]? Arrays are row major so switching between the width and the height will make the code more intuitive.

I didn't know! Interesting... I guess width by height is just easier for me, because that way it goes along with the (x,y) coordinate system. It's just the way I tought myself, I guess.

##### Share on other sites
Ok, so I'm really confused about what to do... could somebody show what some pseudocode for clearing lines would look like?

##### Share on other sites
I'm not sure if this will work, but try it anyways.
void check_clear_row(){	int row;	// Scan through all the rows	for(row = 0; row < SCREENH - 1; row++)	{			int i;			BOOL isFull = TRUE;			// Does this row need to be cleared?			for(i = 0; i < 8; i++)			{				if(arr_tetris_screen[row] == NO_TILE) isFull = FALSE;			}			// Clear row			if(isFull)			{				int currow;				// Scan through all rows above this one, starting from this one.				for(currow = row; currow > 0; currow--)				{					// Replace this row by the one right above it					for(i = 0; i < 8; i++)					{						arr_tetris_screen[currow] = arr_tetris_screen[currow - 1];					}				}			}	}		translate();}

##### Share on other sites
Quote:
 Original post by AcePilotI'm not sure if this will work, but try it anyways.*** Source Snippet Removed ***

It didn't work, thanks for trying. I located the spot in the code where the code whas wrong- and it was an off by one code error. WHOOPS! LOL New code attached, looking for new problems.