Page 1 of 1

Understanding SFSTris example

Posted: 09 Nov 2010, 01:13
by haplo
Hey, im trying to understand the logic of the example provided.
It seems i have a basic problem understanding how you guys separate the game logic between each room.

you declare few variables under the main class SFSTrisGame
one of them is a single instance of the gameboard

Code: Select all

private TrisGameBoard gameBoard;

under the init function you instantiate the board which mean we only have 1 instance of that board

Code: Select all

	public void init()
	{

		gameBoard = new TrisGameBoard();
        }


now i guess what im trying to understand is this : When users create different room games, they use the same gameBoard instance in the server? or this variable is initiated for each room?

Posted: 09 Nov 2010, 08:14
by sHTiF
SFSTrisGame is a room extension so a new instance of the extension class is created each time a room is created therefore a new instance of the board as well.

thank you

Posted: 10 Nov 2010, 02:06
by haplo
Thank you for your answer now i start to understand the logic behind the server.

I have one more problem regarding that. Is it correct to assume that as soon as the user join a room he will use the extension attached to that room. if a user is not joined to any room he will use the extension attached to the zone? Is that correct?

We would like to implement a shop system which is independent from room logic. Is there any way a user can send() to the zone extension while connected to a room ?

Posted: 10 Nov 2010, 07:59
by sHTiF
User is using the zone extension the whole time he is in the zone, he can be in any number of rooms with various extensions and still use zone extension. Its like global vs local extensions ;)

So yes you can still send to zone extension.