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.


Messages - servvs

Pages: [1]
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.

2
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...

3
General / Help with bouncing ship
« on: April 12, 2010, 03:13:58 am »
Okie dokie then, got it working with a little but of umm... work. http://pastebin.com/gmcShYyB for the updated code that works how it should. Now to create missles and collision and then to separate everything into classes :D

4
General / Help with bouncing ship
« on: April 12, 2010, 01:40:22 am »
I tested it out but still can't get it to work correctly. Here is the entire source at pastebin (not very big source)

http://pastebin.com/HfvAhSfn

5
General / Help with bouncing ship
« on: April 12, 2010, 01:00:30 am »
Ok so we have all heard of the game alien invaders, where the enemy ships bounce  back and forth and you shoot them with your space ship right? Well right now I am having trouble getting them to bounce back and forth. I have updated the code and tried it at a different view, but I still get the same thing. Basically instead of bouncing off of the screen and to the other side it bounces between the edge and the first pixel of the edge causing it to vibrate and be stuck.... I can't get it it to just bounce and go the other direction... Here is my updated code

Code: [Select]

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

6
General / Help with bouncing ship
« on: April 12, 2010, 12:48:49 am »
Really no help? :(

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

8
Graphics / sprite.GetPosition and Vector2f
« on: April 11, 2010, 08:34:52 am »
Quote from: "Ashenwraith"
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


Im still getting used to c++ could you show me an example for that? and this helps a lot :D

9
Graphics / sprite.GetPosition and Vector2f
« on: April 11, 2010, 08:22:59 am »
Ok another new problem im having is that when the enemy reaches the edge of the screen, it should change its direction by -1...

Code: [Select]

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


I know this code is defunct, and that it creates an endless loop and gets stuck between the edge of the window and one pixel from the edge of the window causing it to bounce by 1 pixel over and over again. I have tried numerous things but cant get this to work, any ideas?

10
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]