本文整理汇总了C++中Input::addPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ Input::addPlayer方法的具体用法?C++ Input::addPlayer怎么用?C++ Input::addPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::addPlayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) == 1 )
return -1;
const SDL_VideoInfo *video_info = SDL_GetVideoInfo();
if(video_info == NULL)
return -1;
atexit(SDL_Quit);
int video_flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_RESIZABLE;
if(video_info->hw_available)
video_flags |= SDL_HWSURFACE;
else
video_flags |= SDL_SWSURFACE;
if(video_info->blit_hw)
video_flags |= SDL_HWACCEL;
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_SetVideoMode(screen_width, screen_height, screen_bpp, video_flags);
graphics->initialize(screen_width, screen_height);
Configuration configuration("data/config.xml");
configuration.read();
Input input;
input.addPlayer(configuration.getConfigKeys(true), configuration.getConfigDevice(true));
input.addPlayer(configuration.getConfigKeys(false), configuration.getConfigDevice(false));
PlayerAgent player;
player.initialize("data/ryu/ryu.xml", "data/ryu/moves.xml", true);
PlayerAgent player2;
player2.initialize("data/ryu/ryu.xml","data/ryu/moves.xml", false);
player.getPlayer()->setOpponent(player2.getPlayer());
player2.getPlayer()->setOpponent(player.getPlayer());
Sprite background;
GLuint texture = texture_manager->addTexture("data/background.png", false);
background.setTexture(texture,200,100);
PlayerBridge bridge;
bridge.initialize(player.getPlayer(), player2.getPlayer());
object_manager->add("0", player.getPlayer());
object_manager->add("1", player2.getPlayer());
while(!input.quitGame())
{
float game_time;
if(updateGame(game_time))
{
SDL_Event event = input.poll();
if(event.type == SDL_VIDEORESIZE)
{
SDL_SetVideoMode(event.resize.w, event.resize.h, screen_bpp, video_flags);
graphics->resizeWindow(event.resize.w, event.resize.h);
}
bool *keys = input.getKeys(0);
player.update(keys);
bool *keys2 = input.getKeys(1);
player2.update(keys2);
string key = object_manager->first();
while(key != "")
{
bool done = false;
if(key != "0" && key != "1")
done = object_manager->get(key)->update();
if(done)
object_manager->remove(key);
key = object_manager->next();
}
//draw
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); // Clear color and depth buffer
glLoadIdentity(); // Reset orientation
glTranslatef(-50.0f, -50.0f, -120.0f);
bridge.update();
background.draw(50,50,1, false);
list<Player*> objects = object_manager->getSortedList();
for(list<Player*>::iterator i = objects.begin(); i != objects.end(); i++)
//.........这里部分代码省略.........