Solitare
by rennie moffat · in Torque Game Builder · 06/15/2009 (10:33 am) · 6 replies
Hi, I am a newbie here and I am trying to figure out things like random image creation. So I am studying Solitaire right now. In it I can understanding the logic of the code. However, I have gone to the TGB interface itself to see how it relates to the graphics. ANd I am baffled.
My problem is, There are 52 cards in a deck, fine, there are 52 cards listed, ALL UNDER ONE STATIC SPRITE. The is the bit that gets me. When you double click, of course all show, but there is no way for me to define them. How does TGB, Script know, what card is which.
Thanks
Ren
My problem is, There are 52 cards in a deck, fine, there are 52 cards listed, ALL UNDER ONE STATIC SPRITE. The is the bit that gets me. When you double click, of course all show, but there is no way for me to define them. How does TGB, Script know, what card is which.
Thanks
Ren
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
06/16/2009 (9:34 am)
yeah. You should try also the mole tutorial so you can split an image in multiple frames and you will refence them later as individual frames or sprites (animated or static).
#3
06/16/2009 (10:18 am)
OK, so setting the frame number, I take it would run from top left, horizontally right, down to the row below and so on.
#4
Thanks,
Ren
06/16/2009 (1:09 pm)
ps. I am sorry I didn't say. but the Solitaire comes as a demo with TGB, if not it will be in Platformer pro as I have that too. If you get any good looks at it, please keep me posted. I seem to be working on 2D scroller stuff today.Thanks,
Ren
#5
You can do this the slow way, literally dragging the image to the scene graph 52 times to create all 52 objects, or create them in script. Off the top of my head:
$card[x] = new t2dStaticSprite
{
SceneGraph = t2dSceneWindow.getSceneGraph();
ImageMap = CardImage;
Frame = x;
Position = x * 10 SPC x * 10;
};
(double-check that code)
Later on, you would reference the card by it's frame number (and deduce the suit and rank based on the frame).
06/16/2009 (3:17 pm)
You would create 52 separate sprites, all with the same image map (the image of all 52 cards), each object would choose a different frame.You can do this the slow way, literally dragging the image to the scene graph 52 times to create all 52 objects, or create them in script. Off the top of my head:
$card[x] = new t2dStaticSprite
{
SceneGraph = t2dSceneWindow.getSceneGraph();
ImageMap = CardImage;
Frame = x;
Position = x * 10 SPC x * 10;
};
(double-check that code)
Later on, you would reference the card by it's frame number (and deduce the suit and rank based on the frame).
#6
new
would reference a new card that has not already been selected, (?)
if right, would I not need a random call in there to insure the same card does not repeat, or simply go up in order?
so in fact would "new" be "random".
SceneGraph
According to wiki, a sceneGraph is a nodal tree structure where any node may have many children but only one parent. Is this true. If so, would it be safe to say a scene graph in this instance would be.. it would simply be a card.
Position = x * 10 SPC x * 10;
Beyond this representing a position, I am unsure of the SPC or why you have multiply signs. Please if you can, explain your logic on these points.
thanks so much,
ps I had written a much more in depth reply but it had been deleted so I apologize for any short comings.
thanks
ren
06/16/2009 (6:10 pm)
So I understand this, I think (from a rookie coders perspective).new
would reference a new card that has not already been selected, (?)
if right, would I not need a random call in there to insure the same card does not repeat, or simply go up in order?
so in fact would "new" be "random".
SceneGraph
According to wiki, a sceneGraph is a nodal tree structure where any node may have many children but only one parent. Is this true. If so, would it be safe to say a scene graph in this instance would be.. it would simply be a card.
Position = x * 10 SPC x * 10;
Beyond this representing a position, I am unsure of the SPC or why you have multiply signs. Please if you can, explain your logic on these points.
thanks so much,
ps I had written a much more in depth reply but it had been deleted so I apologize for any short comings.
thanks
ren
Torque 3D Owner Darius
The first part of this tutorial does a fair job of showing how to manipulate an image in cell mode.
Basically it divides an image into a bunch of smaller images, then you can tell the image map which of those smaller images to display by setting the frame.
So what they probably are doing, is they have one big image with all 52 cards on it, then all of the cards reference that image, and just set the frame to display the correct card.
I hope that makes sense.