demo: optimizada la inicialización de input
This commit is contained in:
18
main.cpp
18
main.cpp
@@ -93,21 +93,7 @@ int main(int argc, char *argv[])
|
|||||||
Input *input = new Input(asset->get("gamecontrollerdb.txt"));
|
Input *input = new Input(asset->get("gamecontrollerdb.txt"));
|
||||||
input->setVerbose(options->console);
|
input->setVerbose(options->console);
|
||||||
input->discoverGameController();
|
input->discoverGameController();
|
||||||
//input->bindKey(INPUT_UP, SDL_SCANCODE_UP);
|
string controllerName = input->getNumControllers() > 0 ? input->getControllerName(0) : "";
|
||||||
//input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
|
|
||||||
//input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT);
|
|
||||||
//input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT);
|
|
||||||
//input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
|
||||||
//input->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
|
||||||
//input->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
|
||||||
//input->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
|
||||||
string controllerName = "";
|
|
||||||
int numControllers = input->getNumControllers();
|
|
||||||
if (numControllers > 0)
|
|
||||||
{
|
|
||||||
// Obtiene el nombre del primer mando conectado
|
|
||||||
controllerName = input->getControllerName(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializa el texto
|
// Inicializa el texto
|
||||||
Text *text = new Text(asset->get("smb2.txt"), asset->get("smb2.png"), renderer);
|
Text *text = new Text(asset->get("smb2.txt"), asset->get("smb2.png"), renderer);
|
||||||
@@ -282,7 +268,7 @@ int main(int argc, char *argv[])
|
|||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE, options->screen.nativeWidth / 2, text->getCharacterSize() * 7, "Pulsa 'N' para mostrar", 1, {240, 240, 240}, 1, {0, 0, 192});
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE, options->screen.nativeWidth / 2, text->getCharacterSize() * 7, "Pulsa 'N' para mostrar", 1, {240, 240, 240}, 1, {0, 0, 192});
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE, options->screen.nativeWidth / 2, text->getCharacterSize() * 8, "una notificacion", 1, {240, 240, 240}, 1, {0, 0, 192});
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE, options->screen.nativeWidth / 2, text->getCharacterSize() * 8, "una notificacion", 1, {240, 240, 240}, 1, {0, 0, 192});
|
||||||
debugText->writeCentered(options->screen.nativeWidth / 2, options->screen.nativeHeight / 2, controllerName);
|
debugText->writeCentered(options->screen.nativeWidth / 2, options->screen.nativeHeight / 2, controllerName);
|
||||||
debugText->writeCentered(options->screen.nativeWidth / 2, (options->screen.nativeHeight / 2) + (debugText->getCharacterSize()*2), inputPressed);
|
debugText->writeCentered(options->screen.nativeWidth / 2, (options->screen.nativeHeight / 2) + (debugText->getCharacterSize() * 2), inputPressed);
|
||||||
|
|
||||||
// Vuelca el buffer en pantalla
|
// Vuelca el buffer en pantalla
|
||||||
screen->blit();
|
screen->blit();
|
||||||
|
|||||||
Reference in New Issue
Block a user