本文整理汇总了C++中mazewarinstance::Ptr::score方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::score方法的具体用法?C++ Ptr::score怎么用?C++ Ptr::score使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mazewarinstance::Ptr
的用法示例。
在下文中一共展示了Ptr::score方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shoot
void shoot()
{
if (proj.present) return;
proj.present = true;
proj.x = M->xloc().value();
proj.y = M->yloc().value();
proj.prev_x = proj.prev_y = 0;
proj.direction = M->dir().value();
gettimeofday(&proj.shootTime, NULL);
M->scoreIs( M->score().value()-1 );
UpdateScoreCard(0);
}
示例2: GetRatScore
/* This is just for the sample version, rewrite your own */
Score GetRatScore(RatIndexType ratId)
{
if (ratId.value() == 0 )
{ return(M->score()); }
else
{
if(rat_array[(ratId.value())]==NULL)
return 0;
else
return rat_array[ratId.value()]->score;
}
}
示例3: makePacket
void makePacket(MW244BPacket *p, char status, int killed, bool UpdateSeqNo)
{
strncpy(p->Name,M->myName_,NAMESIZE );
p-> ID = M->myRatId().value();
cout << "ID from packet: " << M->myRatId().value() << endl;
if (UpdateSeqNo) ++my_seq_no;
p-> sequence_number = my_seq_no;
p -> tagged_rat = killed;
p->score = M->score().value();
p->x_pos = MY_X_LOC;
p->y_pos = MY_Y_LOC;
p-> dir = MY_DIR;
p-> status = status;
p-> globalID = GLOBAL_ID;
p -> time = start_time;
}
示例4: GetRatScore
/* This is just for the sample version, rewrite your own */
Score GetRatScore(RatIndexType ratId)
{
if (ratId.value() == M->myRatId().value())
{ return(M->score()); }
else { return (0); }
}
示例5: processPacket
void processPacket (MWEvent *eventPacket)
{
MW244BPacket *p = new MW244BPacket ;
p = eventPacket->eventDetail;
/*cout << p->ID<< endl;
cout << p->sequence_number<< endl;
cout << p->score<< endl;
cout << p->x_pos<< endl;
cout << p->y_pos<< endl;
cout << p->dir<< endl;
cout << p->tagged_rat<< endl;
cout << p->globalID<< endl;
ConvertIncoming(p);
cout << p->ID<< endl;
cout << p->sequence_number<< endl;
cout << p->score<< endl;
cout << p->x_pos<< endl;
cout << p->y_pos<< endl;
cout << p->dir<< endl;
cout << p->tagged_rat<< endl;
cout << p->globalID<< endl;
exit(0);*/
cout << "PP " << p->ID << endl;
if (myPacket(p, &eventPacket->eventSource) && join)// BECAUSE WHILE YOU ARE STILL 0, you will get packets with ID 0
{
return;
}
else {
if (!join && expected_seqno[p->ID] <= p->sequence_number){
if (p->globalID == 7) // What if there is only player with global ID 7? :/
{
cout << "You are one player too many :(" << endl;
cout << "Please try again later." << endl;
exit(0);
}
else
{ for (int i = 0; i < 100; i++)
cout << "Incrementing for no reason" << endl;
join = true;
GLOBAL_ID = p->globalID+1;
M->myRatIdIs(GLOBAL_ID);
setMapping();
UpdateScoreCard(0);
MW244BPacket q;
makePacket(&q,'h',-1, updateSeqNo);
sendPacketToPlayers(q);
participants[p->ID]++;
Rat r;
r.playing = 1;
cout << "NEW " << p->ID << endl;
r.x=p->x_pos;
r.y=p->y_pos;
r.dir=(p->dir);
M->mazeRats_[Mapping_idToIndex.find(p->ID)->second] = r;
rat_array[p-> ID]=new MW244BPacket;
rat_array[Mapping_idToIndex.find(p->ID)->second]=p;
Loc x(p->x_pos);
Loc y(p->y_pos);
Direction dir(p-> dir);
RatIndexType ratId(Mapping_idToIndex.find(p->ID)->second);
SetRatPosition(ratId, x, y, dir);
UpdateScoreCard(Mapping_idToIndex.find(p-> ID)->second);
expected_seqno[p->ID] = p->sequence_number + 1;
return;
}
}
if (GLOBAL_ID < p->globalID && expected_seqno[p->ID] <= p->sequence_number )
GLOBAL_ID = p->globalID;
if (p->status == 'a' && p->tagged_rat == M->myRatId().value())
{ // cannot discard expected_seqno[p->ID] <= p->sequence_number
// because we're getting this packet because the other side didn't get b :(
// MUST send b
MW244BPacket q;
makePacket(&q,'b',-1, updateSeqNo);
sendPacketToPlayers(q);
cout<<p->sequence_number<<"Seq number"<<endl;
cout<<prevseq_a[p->ID]<<"Previous Seq number"<<endl;
if (p->sequence_number > prevseq_a[p->ID])
{ // dealing with duplicates
DrawString("You have been tagged!",21,200,250);
M->scoreIs( M->score().value()-5 );
UpdateScoreCard(0);
NewPosition(M);
}
prevseq_a[p->ID] = p->sequence_number;
}
else if (p->status == 'a' && expected_seqno[p->ID] <= p->sequence_number){
//RatIndexType ratId(p-> ID);
//ClearRatPosition(ratId);
RatIndexType ratId( Mapping_idToIndex.find(p->ID)->second);
ClearRatPosition(ratId);
//.........这里部分代码省略.........
示例6: manageMissiles
void manageMissiles()
{
if (!proj.present)
return;
struct timeval now;
gettimeofday(&now, NULL);
int x = proj.x, y = proj.y;
int elapsed_time = time_diff(now, proj.shootTime);
int distance_travelled = elapsed_time * projectile_speed;
if (proj.direction == 0)
x += distance_travelled;
else if (proj.direction == 1)
x -= distance_travelled;
else if (proj.direction == 2)
y += distance_travelled;
else if (proj.direction == 3)
y -= distance_travelled;
if (MY_X_LOC == x && MY_Y_LOC == y)
return;
if (M->maze_[x][y]) {
// hit wall
clearProjectile();
return;
}
for (int i = 0; i < 8; i++)
{
if (M->mazeRats_[i].playing && M->mazeRats_[i].x.value() == x && y == M->mazeRats_[i].y.value())
{
MW244BPacket p;
makePacket(&p,'a',Mapping_indexToId.find(i)->second, updateSeqNo);
proj.prev_x = x;
proj.prev_y = y;
sendPacketToPlayers(p);
updateSeqNo = false;
checkingzero = 0;
RatIndexType ratId(i);
kills = Mapping_indexToId.find(i)->second;
clearProjectile();
M->scoreIs( M->score().value() + 11 );
UpdateScoreCard(0);
DrawString("You have tagged a player!",25,200,250);
ClearRatPosition(ratId);
}
}
if (proj.prev_x == 0 && proj.prev_y == 0) proj.prev_x = proj.prev_y = 1;
showMissile(x, y, proj.direction,
proj.prev_x, proj.prev_y,
true);
proj.prev_x = x;
proj.prev_y = y;
if (updateSeqNo && join)
{
MW244BPacket p;
makePacket(&p,'t',-1, updateSeqNo);
sendPacketToPlayers(p);
}
}