- Home /
Question by
Whelandrew · May 08, 2015 at 06:19 PM ·
layoutcardsdistribution
Creating Card Game Layouts
I'm writing a card game that will require distribution of cards in different layouts.
Currently, I use this function to distribute 10 card in 2 rows. So, rows = 2, columns = 5.
for ( int i=0;i<this.numOfRows;i++)
{
for ( int j=0;j<this.numofCols;j++ )
{
tempCache[k].transform.Translate(new Vector2(
(k%this.numofCols+(k%this.numofCols*space))-(this.numofCols)+space,
(k/this.numofCols+(k/this.numofCols*space*2f))
memoryCards.Add(tempCache[k]);
k++;
}
}
I'm hoping for some directions on how I could create card layouts that are a bit more unique. I'm thinking to create cards in a semi-circular patter, cross shapes, etc. I know I could create a series of gameobject points to draw with but I would rather do this in code. Any suggestions?
Comment
Best Answer
Answer by Whelandrew · May 11, 2015 at 10:47 PM
Turns out I can lerp my deck of cards to create a nice even spread
currentPos.y += deck.curve * Mathf.Sin(Mathf.Clamp01(cTime) * Mathf.PI);
Hello there :) Thanks for your post. I was wondering about the deck.curve variable. $$anonymous$$ay you elaborate more? thank you!