Convertit "param" a variable global en lloc de anar marejant amb punterets i passant 8.000.000 de paràmetres

This commit is contained in:
2024-09-27 17:42:25 +02:00
parent c1bf0b8aed
commit 46b41757b2
28 changed files with 279 additions and 293 deletions

View File

@@ -1,9 +1,9 @@
#include "enemy_formations.h"
#include "param.h"
// Constructor
EnemyFormations::EnemyFormations(param_t *param)
EnemyFormations::EnemyFormations()
{
this->param = param;
initEnemyFormations();
initEnemyPools();
initGameStages();
@@ -19,20 +19,20 @@ void EnemyFormations::initEnemyFormations()
{
const int y4 = - BLOCK;
const int x4_0 = PLAY_AREA_LEFT;
const int x4_100 = param->game.playArea.rect.w - BALLOON_WIDTH_4;
const int x4_100 = param.game.playArea.rect.w - BALLOON_WIDTH_4;
const int y3 = - BLOCK;
const int x3_0 = PLAY_AREA_LEFT;
const int x3_100 = param->game.playArea.rect.w - BALLOON_WIDTH_3;
const int x3_100 = param.game.playArea.rect.w - BALLOON_WIDTH_3;
const int y2 = - BLOCK;
const int x2_0 = PLAY_AREA_LEFT;
const int x2_100 = param->game.playArea.rect.w - BALLOON_WIDTH_2;
const int x2_100 = param.game.playArea.rect.w - BALLOON_WIDTH_2;
const int y1 = - BLOCK;
const int x1_0 = PLAY_AREA_LEFT;
const int x1_50 = param->game.playArea.centerX - (BALLOON_WIDTH_1 / 2);
const int x1_100 = param->game.playArea.rect.w - BALLOON_WIDTH_1;
const int x1_50 = param.game.playArea.centerX - (BALLOON_WIDTH_1 / 2);
const int x1_100 = param.game.playArea.rect.w - BALLOON_WIDTH_1;
// Inicializa a cero las variables
for (int i = 0; i < NUMBER_OF_ENEMY_FORMATIONS; i++)
@@ -70,11 +70,11 @@ void EnemyFormations::initEnemyFormations()
// #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro
j = 1;
enemyFormation[j].numberOfEnemies = 2;
incX = param->game.playArea.centerX;
incX = param.game.playArea.centerX;
incTime = 0;
for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++)
{
enemyFormation[j].init[i].x = param->game.playArea.firstQuarterX - (BALLOON_WIDTH_4 / 2) + (i * incX);
enemyFormation[j].init[i].x = param.game.playArea.firstQuarterX - (BALLOON_WIDTH_4 / 2) + (i * incX);
enemyFormation[j].init[i].y = y4;
enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1);
enemyFormation[j].init[i].kind = BALLOON_4;