Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Topics - servvs

Pages: [1]
1
General / Problems with Drawable.Rotate
« on: April 14, 2010, 12:07:25 am »
Is there any way to rotate an image from an offset axis? Basically I want a wheel to spin in circles but it rotates around a large axis...

2
General / Help with bouncing ship
« on: April 11, 2010, 09:24:40 pm »
Ok so I have a ship sprite that I want to bounce back and forth from each edge of the screen. I am having trouble with it and here is the code:

Code: [Select]

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);

3
Graphics / sprite.GetPosition and Vector2f
« on: April 11, 2010, 07:10:35 am »
So basically I am trying to make a ball that bounces around, but im unsure how to use the geposition and vector2 functions to do that. I don't understand how to use getposition to assign a float to said variable and then have my if statement read said variable and change directions when said variable reaches a point of the screen that it should not go out of.... A little enlightenment please?

while im here. I also want to learn more about classes. I understand them to a point and I know it makes it easier to create multiple enemies with their health and weather they are alive stored in the class, but i can't figure out how to implement that either... Basically I want a class for enemies with those things in them that way I can create my for loop and have multiple instances of the enemies but I can't get it to work with the sprites and what not... An example would be great though, or just some more enlightenment

[edit]
I typed originally getscale :p same concept though

[edit]
My latest attempt is
Code: [Select]

        sf::Vector2f::x EnemyWidthCheck;
        float enemyWidthCheck = EnemyWidthCheck.GetPosition;
        if (enemyWidthCheck >= wWidth)
        {
            enemyMove = enemyMove * -1;
        }


[edit]
Ugh I feel dumb... its just sprite.GetPosition().x;

Still, any resources on classes would be great :p

Pages: [1]
anything