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 - jamku

Pages: [1]
1
General / how to display alternate images at each timestep
« on: July 22, 2011, 11:00:47 pm »
:shock:  :shock:  :shock: OMG how could i miss that lol it now moves :D thank you

2
General / how to display alternate images at each timestep
« on: July 22, 2011, 08:53:14 pm »
even when i put a constant value no movement and my x n y co-ordinates are
Code: [Select]
s.setPosX(width/2);s.setPosY(height/10);

but why would that be the problem, does the if statement call for the elapsed time consecutively until it matches the expression? or does it only call once?

3
General / how to display alternate images at each timestep
« on: July 21, 2011, 07:57:06 pm »
it still aint moving my guess is the clock aint increasing so it aint reaching higher or equal 2 the timestep is there away i can keep track of the clock? so when it hits a certain time value it will excute the if statement

4
General / how to display alternate images at each timestep
« on: July 21, 2011, 06:31:25 pm »
Code: [Select]
void SpaceInvadersDemo::init()
{
shipImage.LoadFromFile("myC++/images/asprite1.png");
shipImage2.LoadFromFile("myC++/images/asprite2.png");
shipSprite=sf::Sprite(shipImage), (shipImage2);
shipSprite.SetCenter(shipSprite.GetSize().x/2,shipSprite.GetSize().y/2);
s.setRadius(shipSprite.GetSize().x/2);
s.setPosX(width/2);s.setPosY(height/10);



}
void SpaceInvadersDemo::draw()
{
win.Clear(sf::Color(0,0,0));
shipSprite.SetPosition(s.getPosX(),s.getPosY());
win.Draw(shipSprite);
}
void SpaceInvadersDemo::getInput()
{
sf::Event Event;
        while (win.GetEvent(Event))
        {

            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                win.Close();
           //Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                win.Close();


        }
}
void SpaceInvadersDemo::update()
{
sf::Clock Clock;


if (Clock.GetElapsedTime()>=Timestep)
{

shipSprite.SetImage(shipImage2);
s.setPosX(s.getPosX()+moveIncrement);
Clock.Reset();


}

void SpaceInvadersDemo::play()
{
//the game loop
draw();//the offscreen buffer
getInput();//from the user
update();//integrate user input and any game movement which is automatic
}


5
General / how to display alternate images at each timestep
« on: July 21, 2011, 05:28:15 pm »
thanks well i changed the code to
Code: [Select]
if (Clock.GetElapsedTime()>=Timestep)
{

shipSprite.SetImage(shipImage2);
s.setPosX(s.getPosX()+moveIncrement);
Clock.Reset();


}

and it still doesn't move does anybody know what the problem could be?

6
General / how to display alternate images at each timestep
« on: July 19, 2011, 07:13:46 pm »
it still doesn't work :( and whats the diffence between calling it with set image, would i use get image to display it?

7
General / how to display alternate images at each timestep
« on: July 19, 2011, 06:33:29 pm »
hey im tryin to make a program where the sprite has two images which are displayed alternatively at each timestep to give the impression of movement like space invaders


i did this  
Code: [Select]

    if (Clock.GetElapsedTime()==Timestep)
{

shipSprite=sf::Sprite(shipImage2);
s.setPosX(s.getPosX()+moveIncrement);

}


the timestep can be modified so a gamedesigner could change the speed of movement but it doesnt move at all :(

Pages: [1]
anything