Skip to content

Commit

Permalink
feat: add a bounce of the sprite from the edges of the window
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKonstantinSh committed Sep 16, 2020
1 parent 4f93988 commit 71bf683
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lab_1/Lab_1/Lab_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,21 @@ COORD CreateNewSpritePosition(COORD spritePosition, COORD spriteSteps, HWND hWnd
newSpritePosition.X = spritePosition.X + spriteSteps.X;
if (newSpritePosition.X < 0)
{
newSpritePosition.X = 0;
newSpritePosition.X = 0 + SPRITE_STEP + 90;
}
else if (newSpritePosition.X + spriteSize.cx > windowSize.cx)
{
newSpritePosition.X = (SHORT)(windowSize.cx - spriteSize.cx);
newSpritePosition.X = (SHORT)(windowSize.cx - spriteSize.cx - SPRITE_STEP);
}

newSpritePosition.Y = spritePosition.Y + spriteSteps.Y;
if (newSpritePosition.Y < 0)
{
newSpritePosition.Y = 0;
newSpritePosition.Y = 0 + SPRITE_STEP;
}
else if (newSpritePosition.Y + spriteSize.cy > windowSize.cy)
{
newSpritePosition.Y = (SHORT)(windowSize.cy - spriteSize.cy);
newSpritePosition.Y = (SHORT)(windowSize.cy - spriteSize.cy - SPRITE_STEP);
}

return newSpritePosition;
Expand Down

0 comments on commit 71bf683

Please sign in to comment.