Acomodats els estats del jugador

El compte enrrere per a continuar ara ix al acabar la animació de morir
Afegit el estat "entering_name"
This commit is contained in:
2024-09-29 10:40:35 +02:00
parent 945eaa68e7
commit 8ce09d1355
9 changed files with 193 additions and 68 deletions

View File

@@ -1,13 +1,17 @@
#include "enter_name.h"
#include <algorithm> // for max, min
#include <algorithm> // for max, min
// Constructor
EnterName::EnterName(std::string *name)
{
characterList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
// Obtiene el puntero al nombre
this->name = name;
// Inicia la lista de caracteres permitidos
characterList = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
pos = 0;
numCharacters = (int)characterList.size();
for (int i = 0; i < NAME_LENGHT; ++i)
{
characterIndex[i] = 0;
@@ -33,13 +37,32 @@ void EnterName::decPos()
pos = std::max(pos, 0);
}
// Incrementa el índice
void EnterName::incIndex()
{
++characterIndex[pos];
if (characterIndex[pos] >= numCharacters)
{
characterIndex[pos] = 0;
}
}
// Decrementa el índice
void EnterName::decIndex()
{
--characterIndex[pos];
if (characterIndex[pos] < 0)
{
characterIndex[pos] = numCharacters - 1;
}
}
// Actualiza la variable
void EnterName::updateName()
{
name->clear();
for (int i = 0; i < NAME_LENGHT; ++i)
{
name->append("a");
//name->append(characterIndex[i] = 0;
name->push_back(characterList[characterIndex[i]]);
}
}
}