本文整理汇总了C++中Position::GetXDistance方法的典型用法代码示例。如果您正苦于以下问题:C++ Position::GetXDistance方法的具体用法?C++ Position::GetXDistance怎么用?C++ Position::GetXDistance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position::GetXDistance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: click
// Mouse clicking function to turn the snake
int click(const Position &p){
int w=289;
if (images.IsInside(p) && state==2) {
snake.StopTimer();
state=1;
}
if (forward.IsInside(p) && state==1) {
snake.StartTimer(100);
state=2;
}
else { if( ((p.GetXDistance()>snakepos[0][0]+0.4 && p.GetXDistance()<16.0 && p.GetYDistance()<16.0) || Right.IsInside(p) ) && w==289){
if(q=='u' || q=='d'){
q='r';
w=1;
}
}
if( ((p.GetXDistance()<snakepos[0][0] && p.GetXDistance()<16.0 && p.GetYDistance()<16.0) || Left.IsInside(p) ) && w==289){
if(q=='u' || q=='d'){
q='l';
w=2;
}
}
if( ((p.GetYDistance()<snakepos[0][1] && p.GetXDistance()<16.0 && p.GetYDistance()<16.0) || Up.IsInside(p) ) && w==289){
if(q=='l' || q=='r'){
q='u';
w=3;
}
}
if( ((p.GetYDistance()>snakepos[0][1]+0.4 && p.GetXDistance()<16.0 && p.GetYDistance()<16.0) || Down.IsInside(p) ) && w==289 ){
if(q=='l' || q=='r'){
q='d';
w=4;
}
}
}
return 3;
}
示例2: user
int user(const Position &p1)
{
int x1,y1;
x=p1.GetXDistance();
y=p1.GetYDistance();
int snakecheck=0;
if(x>=6.4&&x<=8.4&&y>=8.0&&y<=10.4)
{
snakecheck=1;
}
if(W1Bmp.IsInside(p1))
{
W1Bmp.Erase();
writefile();
}
if(W4Bmp.IsInside(p1))
{
UserWindow.Close();
/*open another(previous) window here*/
}
if( W5Bmp.IsInside(p1))
{ void playusermaze();
playusermaze();
}
if(x<16.0&&y<16.0&&snakecheck!=1)
{
W1Bmp.Draw();
x=10*x;
y=10*y;
x1=(int)x;
y1=(int)y;
x1=x1-(x1%4);
y1=y1-(y1%4);
x=x1/10.0;
y=y1/10.0;
if(maze_user[x1][y1]==0)
{
maze_user[x1][y1]=1;
renderboundary(x,y);
createmazeuser();
}
else
{
maze_user[x1][y1]=0;
UserWindow.RenderRectangle(Position(x,y), Position(x+0.4,y+0.4),
White, false);
createmazeuser();
}
}
return 0;
}
示例3: VirtualkeyboardMouseClick
int VirtualkeyboardMouseClick(const Position &p) {
float x=p.GetXDistance();
float y=p.GetYDistance();
addX=(0.2 * count1);
//P1=P1 + Position(addX*count1,0.0);
//P2=P2 + Position(addX*count1,0.0);
//cout<<x<<" "<<y<<endl;
//cout<<addX<<endl;
if (A.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"A", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0) +P1;
LowerRight = Position(6.2,10.2)+P2;
name[count1]='A';
count1++;
}
if (B.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"B", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0) +P1;
LowerRight =Position(6.2,10.2)+P2;
name[count1]='B';
count1++;
}
if (C.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"C", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0)+P1;
LowerRight = Position(6.2,10.2)+P2;
name[count1]='C';
count1++;
}
if (D.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"D", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0) +P1;
LowerRight = Position(6.2,10.2)+P2;
name[count1]='D';
count1++;
}
if (E.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"E", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0) +P1;
LowerRight = Position(6.2,10.2)+P2;
name[count1]='E';
count1++;
}
if (F.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"F", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0) +P1;
LowerRight = Position(6.2,10.2)+P2;
name[count1]='F';
count1++;
}
if (G.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"G", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0) +P1;
LowerRight = Position(6.2,10.2)+P2;
name[count1]='G';
count1++;
}
if (H.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"H", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0) +P1;
LowerRight = Position(6.2,10.2)+P2;
name[count1]='H';
count1++;
}
if (I.IsInside(p)) {
Virtualkeyboard.RenderText(UpperLeft,LowerRight,"I", Red);
P1=P1 + Position(0.2,0.0);
P2=P2 + Position(0.2,0.0);
UpperLeft = Position(6.0,10.0) +P1;
LowerRight = Position(6.2,10.2)+P2;
name[count1]='I';
//.........这里部分代码省略.........