You are here: Home

XNA Community Thailand

XNA Webboard
ยินดีต้อนรับ, ผู้เยี่ยมชม
กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน.    ลืมรหัสผ่าน?
ใครมีอัลกอในการแจกไพ่บ้างครับ (1 viewing) (1) ผู้เยี่ยมชม
Go to bottom รายการถูกบันทึก: 0
หัวข้อ: ใครมีอัลกอในการแจกไพ่บ้างครับ
#1527
csnaijim (สมาชิก)
Senior Boarder
กระทู้: 44
graphgraph
สมาชิกที่ไม่ได้ออนไลน์ Click here to see the profile of this user
ใครมีอัลกอในการแจกไพ่บ้างครับ 6 เดือน ที่ผ่านมา กรรม: 0  
ตามหัวข้อเลยครับ
โค้ดผมประมาณนี้

for (int p = 0; p < amountPlayer; p++)
{
_player[p] = new Player();
for (int cNo = 0; cNo < 52 / amountPlayer; cNo++)
{
RandomCard randomCard = new RandomCard();
int rCardPoint = randomCard.randomCard();
String rCardType = randomCard.randomCardType();
int inDesk = 0;
while (inDesk < 52)
{
if (_card[inDesk].cardScore == rCardPoint && _card[inDesk].cType == rCardType)
{
_player[p].dealingCard(_card[inDesk], cNo);
break;
}
inDesk++;
}
}
}


แต่ผมไม่เข้าใจว่า ทำไมตอนวาด มันวนลูป แล้วได้ไพ่ 13 ใบ เป็นแบบเดียวกันหมดเลย ใครพอมีแนวทางแก้ไขบ้างครับ

_player[0].DrawCardInHand(spriteBatch); //วาดไพ่ของคนที่ 1

อันนี้เป็นส่วน Class Player ครับ
class Player
{
public String PlayerName { get; set; }
public enum Status { King,Queen,People,Slave,normal }
public Status status { get; set; }
public Card[] cardInHand = new Card[13];//{get;set;}
private int I = 0;
private int pos = 0;

public void dealingCard(Card rCard, int cardNo)
{
cardInHand[cardNo] = rCard;
I = cardNo;
}
public void DrawCardInHand(SpriteBatch spr)
{
for (int i = 0; i < I; i++)
{
spr.Draw(cardInHand[i].CardPic, new Vector2(1024 / 3 + pos, 400), Color.White);
pos += 20;
}
}
}


ปล. get กับ set ที่ตรง attribute ของ class เอาไว้ทำไรหรอครับ โง่จริงๆน่ะนี่ เห็นบางคนเขาใช้กัน เลยใช้บ้าง เหอๆ
 
การบันทึก การบันทึก  
 
Last Edit: 2010/03/08 12:59 By csnaijim.
  The administrator has disabled public write access.
#1543
csnaijim (สมาชิก)
Senior Boarder
กระทู้: 44
graphgraph
สมาชิกที่ไม่ได้ออนไลน์ Click here to see the profile of this user
Re:ใครมีอัลกอในการแจกไพ่บ้างครับ 6 เดือน ที่ผ่านมา กรรม: 0  
มีใครพอมี แนวคิดใหม่ๆบ้างครับ
ถามเพิ่มเลยแล้วกันครับ

ใครพอมีแนวเกมไพ่สลาฟ ขอทราบแนวคิดหน่อยครับ
ขอบคุณครับ
 
การบันทึก การบันทึก  
  The administrator has disabled public write access.
Go to top