本文整理汇总了C++中Road::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Road::Draw方法的具体用法?C++ Road::Draw怎么用?C++ Road::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Road
的用法示例。
在下文中一共展示了Road::Draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window *window;
window = SDL_CreateWindow("SDLwindow", 600, 300, MainWindowWidth, MainWindowHigh, SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = NULL;
renderer = SDL_CreateRenderer( window, 0, SDL_RENDER_TARGETS_RESET);
SDL_SetRenderDrawColor(renderer,255,255,255,255);
SDL_RenderClear( renderer );
SDL_SetRenderDrawColor(renderer,0,0,0,0);
SDL_RenderDrawLine(renderer,MainWindowWidth/12,MainWindowHigh-30,MainWindowWidth/12,MainWindowHigh-70);
SDL_RenderDrawLine(renderer,MainWindowWidth/12,MainWindowHigh-30,MainWindowWidth/12-10,MainWindowHigh-50);
SDL_RenderDrawLine(renderer,MainWindowWidth/12,MainWindowHigh-30,MainWindowWidth/12+10,MainWindowHigh-50);
SDL_RenderDrawLine(renderer,MainWindowWidth/12*11,MainWindowHigh-30,MainWindowWidth/12*11,MainWindowHigh-70);
SDL_RenderDrawLine(renderer,MainWindowWidth/12*11,MainWindowHigh-70,MainWindowWidth/12*11-10,MainWindowHigh-50);
SDL_RenderDrawLine(renderer,MainWindowWidth/12*11,MainWindowHigh-70,MainWindowWidth/12*11+10,MainWindowHigh-50);
Road road;
road.Draw(renderer);
Car object;
object.SetX(MainWindowWidth/5*3);
object.SetY(MainWindowHigh/5*3);
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);
//.........这里部分代码省略.........