mil minimerdes arreglades

This commit is contained in:
2024-07-11 20:52:04 +02:00
parent 4c44fc0e1a
commit 80bbe711a2
10 changed files with 34 additions and 28 deletions

View File

@@ -1,6 +1,7 @@
#GAME
gameWidth 320
gameHeight 240
itemSize 20
#FADE
numSquaresWidth 160

Binary file not shown.

Before

Width:  |  Height:  |  Size: 623 B

After

Width:  |  Height:  |  Size: 623 B

View File

@@ -1,5 +1,5 @@
frameWidth=30
frameHeight=39
frameWidth=28
frameHeight=37
[animation]
name=default

Binary file not shown.

Before

Width:  |  Height:  |  Size: 972 B

After

Width:  |  Height:  |  Size: 835 B

View File

@@ -171,6 +171,7 @@ struct param_t
{
int gameWidth; // Ancho de la resolucion nativa del juego
int gameHeight; // Alto de la resolucion nativa del juego
int itemSize; // Tamañoi de los items del juego
SDL_Rect scoreboard; // Posición y tamaño del marcador

View File

@@ -2376,8 +2376,8 @@ void Game::throwCoffee(int x, int y)
ss->setPosX(x - 8);
ss->setPosY(y - 8);
ss->setWidth(16);
ss->setHeight(16);
ss->setWidth(param->itemSize);
ss->setHeight(param->itemSize);
ss->setVelX(-1.0f + ((rand() % 5) * 0.5f));
ss->setVelY(-4.0f);
ss->setAccelX(0.0f);
@@ -2386,7 +2386,7 @@ void Game::throwCoffee(int x, int y)
ss->setDestY(param->gameHeight + 1);
ss->setEnabled(true);
ss->setEnabledCounter(1);
ss->setSpriteClip(0, 0, 16, 16);
ss->setSpriteClip(0, param->itemSize, param->itemSize, param->itemSize);
ss->setRotate(true);
ss->setRotateSpeed(10);
ss->setRotateAmount(90.0);

View File

@@ -35,7 +35,7 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset,
counterEnd = 700;
view = {0, 0, param->gameWidth, param->gameHeight};
spritePos = {0, 0};
itemSize = 20;
itemSpace = 2;
// Inicializa objetos
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
@@ -96,12 +96,10 @@ void Instructions::iniSprites()
itemTextures.push_back(item5);
// Inicializa los sprites
const int desp = spritePos.y - 4;
for (int i = 0; i < (int)itemTextures.size(); ++i)
{
Sprite *sprite = new Sprite(0, 0, itemSize, itemSize, itemTextures[i], renderer);
sprite->setPos({spritePos.x, desp + ((itemSize + 2) * i), itemSize, itemSize});
Sprite *sprite = new Sprite(0, 0, param->itemSize, param->itemSize, itemTextures[i], renderer);
sprite->setPos({spritePos.x, spritePos.y + ((param->itemSize + itemSpace) * i), param->itemSize, param->itemSize});
sprites.push_back(sprite);
}
}
@@ -109,34 +107,33 @@ void Instructions::iniSprites()
// Actualiza los sprites
void Instructions::updateSprites()
{
SDL_Rect srcRect = {0, 0, itemSize, itemSize};
SDL_Rect srcRect = {0, 0, param->itemSize, param->itemSize};
// Disquito
srcRect.y = itemSize * (((counter + 12) / 36) % 2);
srcRect.y = param->itemSize * (((counter + 12) / 36) % 2);
sprites[0]->setSpriteClip(srcRect);
// Gavineixon
srcRect.y = itemSize * (((counter + 9) / 36) % 2);
srcRect.y = param->itemSize * (((counter + 9) / 36) % 2);
sprites[1]->setSpriteClip(srcRect);
// Pacmar
srcRect.y = itemSize * (((counter + 6) / 36) % 2);
srcRect.y = param->itemSize * (((counter + 6) / 36) % 2);
sprites[2]->setSpriteClip(srcRect);
// Time Stopper
srcRect.y = itemSize * (((counter + 3) / 36) % 2);
srcRect.y = param->itemSize * (((counter + 3) / 36) % 2);
sprites[3]->setSpriteClip(srcRect);
// Coffee
srcRect.y = itemSize * (((counter + 0) / 36) % 2);
srcRect.y = param->itemSize * (((counter + 0) / 36) % 2);
sprites[4]->setSpriteClip(srcRect);
}
// Rellena la textura de texto
void Instructions::fillTexture()
{
const int despX = itemSize + 8;
const int despY = (itemSize - text->getCharacterSize() / 2);
const int despX = param->itemSize + 8;
// Modifica el renderizador para pintar en la textura
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
@@ -155,7 +152,7 @@ void Instructions::fillTexture()
const int spacePostHeader = 20;
const int spacePreHeader = 28;
const int spaceBetweenLines = text->getCharacterSize() * 1.5f;
const int spaceBetweenItemLines = itemSize + 2;
const int spaceBetweenItemLines = param->itemSize + itemSpace;
const int spaceNewParagraph = spaceBetweenLines * 0.5f;
const int size = (numLines * spaceBetweenLines) + (numItemLines * spaceBetweenItemLines) + (numPostHeaders * spacePostHeader) + (numPreHeaders * spacePreHeader) + (spaceNewParagraph);
@@ -184,18 +181,19 @@ void Instructions::fillTexture()
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, anchor2, lang->getText(16), 1, orangeColor, 1, shdwTxtColor);
const int anchor3 = anchor2 + spacePostHeader;
text->writeShadowed(anchorItem + despX, despY + anchor3 + spaceBetweenItemLines * 0, lang->getText(17), shdwTxtColor);
text->writeShadowed(anchorItem + despX, despY + anchor3 + spaceBetweenItemLines * 1, lang->getText(18), shdwTxtColor);
text->writeShadowed(anchorItem + despX, despY + anchor3 + spaceBetweenItemLines * 2, lang->getText(19), shdwTxtColor);
text->writeShadowed(anchorItem + despX, despY + anchor3 + spaceBetweenItemLines * 3, lang->getText(20), shdwTxtColor);
text->writeShadowed(anchorItem + despX, despY + anchor3 + spaceBetweenItemLines * 4, lang->getText(21), shdwTxtColor);
//const int anchor4 = anchor3 + ((param->itemSize + text->getCharacterSize()) / 2);
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 0, lang->getText(17), shdwTxtColor);
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 1, lang->getText(18), shdwTxtColor);
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 2, lang->getText(19), shdwTxtColor);
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 3, lang->getText(20), shdwTxtColor);
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 4, lang->getText(21), shdwTxtColor);
// Deja el renderizador como estaba
SDL_SetRenderTarget(renderer, temp);
// Da valor a la variable
spritePos.x = anchorItem;
spritePos.y = anchor3;
spritePos.y = anchor3 - ((param->itemSize - text->getCharacterSize()) / 2);
}
// Rellena el backbuffer

View File

@@ -44,7 +44,7 @@ private:
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
SDL_Rect view; // Vista del backbuffer que se va amostrar por pantalla
SDL_Point spritePos; // Posición del primer sprite
int itemSize; // Tamaño de los items
int itemSpace; // Espacio entre los items
// Actualiza las variables
void update();

View File

@@ -14,8 +14,8 @@ Item::Item(Uint8 kind, float x, float y, Texture *texture, std::vector<std::stri
if (kind == ITEM_COFFEE_MACHINE)
{
width = 30;
height = 39;
width = 28;
height = 37;
posX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - width - 5)) + 2;
posY = PLAY_AREA_TOP - height;
velX = 0.0f;

View File

@@ -11,6 +11,7 @@ void initParam(param_t *param)
// Tamaño original del juego
param->gameWidth = 320;
param->gameHeight = 240;
param->itemSize = 20;
// Tamaño para el marcador
param->scoreboard = {0, 208, 320, 32};
@@ -131,6 +132,11 @@ bool setOptions(param_t *param, std::string var, std::string value)
param->gameHeight = std::stoi(value);
}
else if (var == "itemSize")
{
param->itemSize = std::stoi(value);
}
else if (var == "numSquaresWidth")
{
param->numSquaresWidth = std::stoi(value);