Game Development Community

Active/Inactive seats in a poker game

by Joel Reymont · in Torque Game Builder · 05/10/2005 (7:49 am) · 6 replies

Folks,

My poker room consists of a "carpet" /background/, table, chairs, etc. I'm using static sprites to display the table and chairs (table should be drawn over chairs for them to appear under it) and I'm using different layers for z-order. I'm new to T2D and Torque and I'm not sure if static 2D sprites are the way to go. They do seem to work, though. My code looks like this:

$table = new fxStaticSprite2D() {
scenegraph = t2dSceneGraph;
};

$emptySeat.setLayer(1);
$emptySeat.setPosition("-200 -100");
$emptySeat.setSize("50 50");

A "seat" can be in different states such as empty, reserved or taken. I'm wondering how I should go about displaying a seat. Should I show and hide the appropriate sprite objects /all states exist in the scene/ or should I delete objects when seat state changes and insert new ones into the scene?

Things are complicated a bit by the fact that the position of buttons, chairs, etc. changes depending on the number of seats at the table so I would need to store seat parameters if I'm to insert and delete objects.

Thanks, Joel

#1
05/10/2005 (12:08 pm)
You could just change your image map to be celled instead of full, and put all the seat images in that file.
Then you would just have a $seat.setFrame(seatStatus).
#2
05/10/2005 (7:14 pm)
......
#3
05/10/2005 (7:15 pm)
Joseph gave good advice :) Using setFrame(0) to pass it a number of the frame is pretty efficient, I have a little code snippet to post here later (its on my laptop, on my work pc right now) I couldn't post it earlier because of board problems.
#4
05/12/2005 (8:17 am)
You could do it either way... I haven't had much time to think about this, but heres one way
you could organize it... not sure if this is what your looking for, or if it helps... in this case
I'm using four sprites a nd just changing out there images.


function loadData()
{
    $gameData = new ScriptObject();

    $gameData.seat[0] = createNewSeat(1, "-200 -100", "50 50");
    $gameData.seat[1] = createNewSeat(1, "-200 100", "50 50");
    $gameData.seat[2] = createNewSeat(1, "200 -100", "50 50");
    $gameData.seat[3] = createNewSeat(1, "200 100", "50 50");

    $gameData.player["Bob"] = bobImageMap;
    $gameData.player["Jane"] = janeImageMap;
    $gameData.player["Joe"] = joeImageMap;
    $gameData.player["Susan"] = susanImageMap;

    loadPlayerIntoSeat(0, "Bob");
    loadPlayerIntoSeat(1, "Jane");
    loadPlayerIntoSeat(2, "Joe");
    loadPlayerIntoSeat(3, "Susan");
}

function loadPlayerIntoSeat(%seat, %player)
{
    $gameData.seat[%seat].setImageMap($gameData.player[%player]);
}

function createNewSeat(%layer, %pos, %size)
{     
    %seat = new fxStaticSprite();
    %seat.setImageMap(emptyImageMap);
    %seat.setSize(%size);
    %seat.setPosition(%position);
    %seat.setLayer(%layer);
    
    return %seat;
}
#5
05/13/2005 (2:55 am)
Thank you folks!
#6
05/13/2005 (3:20 am)
Thank you folks!