1
General / Problems with Drawable.Rotate
« on: April 14, 2010, 12:35:26 am »
thank you very much laurent. Ive got to read more on all the functions before I ask questions.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
int x = wWidth/2;
int x_velocity = 200 * ElapsedTime;
if (x <= 0)
x_velocity = -x_velocity;
if (x >= wWidth)
x_velocity = -x_velocity;
x += x_velocity;
Sprite2.SetPosition(x, y);
float enemyVelocity = 150.0f * ElapsedTime;
float enemyXMax = wWidth - Sprite2.GetScale().x;
float enemyXMin = 0 + Sprite2.GetScale().x;
float spriteWidth = Sprite2.GetScale().x;
float spriteX;
spriteX = Sprite2.GetPosition().x;
cout << spriteX << endl;
if (spriteX >= enemyXMax)
{
enemyVelocity = enemyVelocity * -1;
spriteX = enemyXMax;
}
else if (spriteX <= enemyXMin);
{
enemyVelocity = enemyVelocity * -1;
spriteX = enemyXMin;
}
Sprite2.Move(enemyVelocity, 0);
I'm just starting on this myself.
It should go like this:
-load resources into memory
-instantiate classes that use these sources (make sure they have an id string)
-place in an array
-modify/update through array
float enemyMove = 150;
float enemyX = Sprite2.GetPosition().x;
bool bEnemy = true;
if (enemyX >= wWidth)
bEnemy = false;
if (bEnemy)
{
Sprite2.Move(enemyMove * ElapsedTime, 0);
}
else if(!bEnemy)
{
Sprite2.Move(enemyMove * ElapsedTime * -1, 0);
}
sf::Vector2f::x EnemyWidthCheck;
float enemyWidthCheck = EnemyWidthCheck.GetPosition;
if (enemyWidthCheck >= wWidth)
{
enemyMove = enemyMove * -1;
}