本文整理汇总了C++中Graphics::AddSprite方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::AddSprite方法的具体用法?C++ Graphics::AddSprite怎么用?C++ Graphics::AddSprite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics::AddSprite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
// Some parameters for testing
int test_w = 800;
int test_h = 600;
int test_phys_w = 400;
int test_phys_h = 300;
Graphics *gr = Graphics::Create(test_w, test_h);
assert(gr);
// Initialization of interface between graphics and physics (GPInterface)
gr->InitGPInterface(test_w, test_h, test_phys_w, test_phys_h);
gr->AddSprite(32, 17, "./gfx/car1.png");
gr->AddSprite(32, 17, "./gfx/car2.png");
// Variable coordinates of car
float cX = 20, cY = 15;
float ang = 0;
gr->SetSpriteCoordinates(0, cX, cY, ang);
gr->SetSpriteCoordinates(1, cX+50, cY, ang);
//
Event new_event;
// printf("%d %d\n", gpi.gr_coordinate_x(cX), gpi.gr_coordinate_y(cY));
while(new_event.running()) {
new_event.CheckEvents();
if(new_event.fullscreen()) {
gr->FullscreenOn();
} else {
gr->FullscreenOff();
}
gr->Render();
cX += 0.1;
cY += 0.1;
ang += 0.01;
gr->SetSpriteCoordinates(0, cX, cY, ang);
gr->SetSpriteCoordinates(1, cX+50, cY, ang);
SDL_Delay(5);
}
gr->CleanUp();
delete gr;
return 0;
}