本文整理汇总了C++中Road::Move方法的典型用法代码示例。如果您正苦于以下问题:C++ Road::Move方法的具体用法?C++ Road::Move怎么用?C++ Road::Move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Road
的用法示例。
在下文中一共展示了Road::Move方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
object.SetAngle(0);
object.Draw(renderer);
Actions actions;
SDL_Event event;
int rl=0,rp=0;
while (1)
{
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_KEYDOWN:
{
if (SDL_GetScancodeFromKey(event.key.keysym.sym)==SDL_SCANCODE_LEFT)
{
if (((object.GetX()>=MainWindowWidth/2-10)&&(object.GetDirection()==true))||
((object.GetX()<=MainWindowWidth/2+10)&&(object.GetDirection()==false)))
{
bool AChecked=false;
if ((object.GetX()<MainWindowWidth/2+10)&&(object.GetX()>MainWindowWidth/2-10))
{
actions.ScanA(object,road);
AChecked=true;
}
if (rp==1)
{
rl=0;
rp=0;
}
if (rl==0)
{
object.RotateLeft();
rl++;
}
object.Rotate90(renderer);
road.Draw(renderer);
if (!AChecked)
actions.ScanA(object,road);
actions.ScanBC(object,road);
actions.ActionOutput();
}
}
if (SDL_GetScancodeFromKey(event.key.keysym.sym)==SDL_SCANCODE_RIGHT)
{
if (((object.GetX()>=MainWindowWidth/2-10)&&(object.GetDirection()==false))||
((object.GetX()<=MainWindowWidth/2+10)&&(object.GetDirection()==true)))
{
bool AChecked=false;
if ((object.GetX()<MainWindowWidth/2+10)&&(object.GetX()>MainWindowWidth/2-10))
{
actions.ScanA(object,road);
AChecked=true;
}
actions.ScanA(object,road);
if (rl==1)
{
rl=0;
rp=0;
}
if (rp==0)
{
object.RotateRight();
rp++;
}
object.Rotate90(renderer);
road.Draw(renderer);
if (!AChecked)
actions.ScanA(object,road);
actions.ScanBC(object,road);
actions.ActionOutput();
}
}
if (SDL_GetScancodeFromKey(event.key.keysym.sym)==SDL_SCANCODE_UP)
{
if ((object.GetX()<MainWindowWidth/2-10)||(object.GetX()>MainWindowWidth/2+10))
{
road.Draw(renderer);
road.Move(object.GetDirection());
Sleep(50);
}
}
if (SDL_GetScancodeFromKey(event.key.keysym.sym)==SDL_SCANCODE_ESCAPE)
return 0;
}
break;
case SDL_QUIT:
exit(0);
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}