Cambiados muchos DEFINEs por variables de param
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
#include "item.h"
|
||||
|
||||
// Constructor
|
||||
Item::Item(int kind, float x, float y, Texture *texture, std::vector<std::string> *animation)
|
||||
Item::Item(int kind, float x, float y, SDL_Rect *playArea, Texture *texture, std::vector<std::string> *animation)
|
||||
{
|
||||
sprite = new AnimatedSprite(texture, "", animation);
|
||||
|
||||
this->kind = kind;
|
||||
this->playArea = playArea;
|
||||
enabled = true;
|
||||
timeToLive = 600;
|
||||
accelX = 0.0f;
|
||||
@@ -16,8 +17,8 @@ Item::Item(int kind, float x, float y, Texture *texture, std::vector<std::string
|
||||
{
|
||||
width = 28;
|
||||
height = 37;
|
||||
posX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - width - 5)) + 2;
|
||||
posY = PLAY_AREA_TOP - height;
|
||||
posX = (((int)x + (playArea->w / 2)) % (playArea->w - width - 5)) + 2;
|
||||
posY = -height;
|
||||
velX = 0.0f;
|
||||
velY = -0.1f;
|
||||
accelY = 0.1f;
|
||||
@@ -55,9 +56,9 @@ void Item::allignTo(int x)
|
||||
{
|
||||
posX = PLAY_AREA_LEFT + 1;
|
||||
}
|
||||
else if ((posX + width) > PLAY_AREA_RIGHT)
|
||||
else if ((posX + width) > playArea->w)
|
||||
{
|
||||
posX = float(PLAY_AREA_RIGHT - width - 1);
|
||||
posX = float(playArea->w - width - 1);
|
||||
}
|
||||
|
||||
// Posición X,Y del sprite
|
||||
@@ -98,7 +99,7 @@ void Item::move()
|
||||
velY += accelY;
|
||||
|
||||
// Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido
|
||||
if ((posX < PLAY_AREA_LEFT) || (posX + width > PLAY_AREA_RIGHT))
|
||||
if ((posX < PLAY_AREA_LEFT) || (posX + width > playArea->w))
|
||||
{
|
||||
// Corregir posición
|
||||
posX -= velX;
|
||||
@@ -118,7 +119,7 @@ void Item::move()
|
||||
}
|
||||
|
||||
// Si el objeto se sale por la parte inferior
|
||||
if (posY + height > PLAY_AREA_BOTTOM)
|
||||
if (posY + height > playArea->w)
|
||||
{
|
||||
// Corrige
|
||||
posY -= velY;
|
||||
@@ -128,7 +129,7 @@ void Item::move()
|
||||
velX = 0;
|
||||
accelX = 0;
|
||||
accelY = 0;
|
||||
posY = PLAY_AREA_BOTTOM - height;
|
||||
posY = playArea->w - height;
|
||||
if (kind == ITEM_COFFEE_MACHINE)
|
||||
{
|
||||
floorCollision = true;
|
||||
|
||||
Reference in New Issue
Block a user