bug hunting coffee machine on windows

This commit is contained in:
2021-08-27 12:32:34 +02:00
parent 5d6047b642
commit 70324570c8
4 changed files with 48 additions and 34 deletions

View File

@@ -43,6 +43,8 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer *
mSprite->setAnimationSpeed(0, 10);
mSprite->setAnimationLoop(0, true);
mSprite->setSpriteClip(mSprite->getAnimationClip(0, 0));
mSprite->setPosX(mPosX);
mSprite->setPosY(mPosY);
switch (value)
{
@@ -86,15 +88,19 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer *
mWidth = 32;
mHeight = 32;
//mPosX = (rand() % (PLAY_AREA_WIDTH - mWidth - 3)) + 3;
mPosX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - mWidth));
mPosX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - mWidth - 5)) + 2;
mPosY = PLAY_AREA_TOP - mHeight;
mVelX = 0.0f;
mVelY = -2.0f;
mVelY = -0.1f;
mAccelY = 0.15f;
mSprite->setAnimationNumFrames(0, 4);
mSprite->setAnimationFrames(0, 0, 32 * 0, 16 * 2, mWidth, mHeight);
mSprite->setAnimationFrames(0, 1, 32 * 1, 16 * 2, mWidth, mHeight);
mSprite->setAnimationFrames(0, 2, 32 * 2, 16 * 2, mWidth, mHeight);
mSprite->setAnimationFrames(0, 3, 32 * 3, 16 * 2, mWidth, mHeight);
//mSprite->setSpriteClip(mSprite->getAnimationClip(0, 0));
mSprite->setPosX(mPosX);
mSprite->setPosY(mPosY);
mCollider.r = mWidth / 2;
shiftColliders();
break;
@@ -105,12 +111,12 @@ void Item::init(Uint8 value, float x, float y, LTexture *texture, SDL_Renderer *
if (mClass == ITEM_COFFEE_MACHINE)
{
printf("---\n");
printf("-creation-\n");
printf("x\t%f\n", mPosX);
printf("y\t%f\n", mPosY);
printf("ax\t%f\n", mAccelX);
printf("ay\t%f\n", mAccelY);
printf("r\t%f\n", mCollider.r);
printf("r\t%i\n", mCollider.r);
printf("---\n");
}
}
@@ -156,15 +162,15 @@ void Item::render()
// Actualiza la posición y estados del objeto
void Item::move()
{
if (mClass == ITEM_COFFEE_MACHINE)
{
printf("---\n");
printf("x\t%f\n", mPosX);
printf("y\t%f\n", mPosY);
printf("ax\t%f\n", mAccelX);
printf("ay\t%f\n", mAccelY);
printf("---\n");
}
//if (mClass == ITEM_COFFEE_MACHINE)
//{
// printf("-move-\n");
// printf("x\t%f\n", mPosX);
// printf("y\t%f\n", mPosY);
// printf("ax\t%f\n", mAccelX);
// printf("ay\t%f\n", mAccelY);
// printf("---\n");
//}
mStatus = 0;
@@ -187,14 +193,14 @@ void Item::move()
}
// Si se sale por arriba
if (mPosY < PLAY_AREA_TOP)
{
// Corrige
mPosY = PLAY_AREA_TOP;
// Invierte el sentido
mVelY = -mVelY;
}
//if (mPosY < PLAY_AREA_TOP)
//{
// // Corrige
// mPosY = PLAY_AREA_TOP;
//
// // Invierte el sentido
// mVelY = -mVelY;
//}
// Si el objeto se sale por la parte inferior
if (mPosY + mHeight > PLAY_AREA_BOTTOM)
@@ -305,6 +311,6 @@ circle_t &Item::getCollider()
// Alinea el circulo de colisión con la posición del objeto
void Item::shiftColliders()
{
mCollider.x = Uint16(mPosX + mCollider.r);
mCollider.y = Uint16(mPosY + mCollider.r);
mCollider.x = int(mPosX + mCollider.r);
mCollider.y = int(mPosY + mCollider.r);
}