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

Pages: [1]
1
General / Re: Continuous sprites
« on: November 08, 2012, 06:53:37 pm »
Thank you for your quick response  ;) I have the array with the sprites, I know how to move them, but I can't do it separately, one after the other (like a marquee). These are the steps I'm making:

- To generate a random number representing one of the four arrows
- Draw it
- Take the position to separate the next arrow
- Draw the next arrow

Of course this way doesn't work, because when I draw the second arrow I lost the index of the first one and then it disappears from the screen. I think there must be a way to do it automatically but I can see it.

2
General / Re: Continuous sprites
« on: November 08, 2012, 12:50:39 pm »
I start over. I'm trying to make a simple game, where four arrows (up, right, down, left), move from one side to the screen to the other side, one after the other. It would be like guitar hero, but you have to press the key corresponding to the arrow while these pass through a zone.

I have an array of sprites with the four arrows in it. Now my problem is that I can't move the arrows one after the other. I tried drawing a new one in every loop, but it didn't work. I just need to have a constant wave of arrows moving through the screen, but I'm stucked right there.

3
General / Re: Continuous sprites
« on: November 07, 2012, 01:19:07 pm »
I know how to move the sprite, but just one. I have an array of four and I need to move them randomly, but I can't find a way of doing it.

    int index = rand() % 4;
    Window.draw(spritesArray[index]);
    spritesArray[index].move(speed, 0);
 

I use this to move just one, but this generates a different sprite every time it loops, so it doesn't work either.

 I know it sounds silly, but I can't figure it out.

4
General / Continuous sprites
« on: November 07, 2012, 12:26:53 am »
Probably it's a dumb problem but I can't solve it. I have an array of four sprites, each one is an arrow, and want them to go across the screen one after the other randomly. This would be an example but with two arrows: -> -> <- -> -> -> <- -> -> -> <- -> .
while(Window.isOpen())
{
   sf::Event event;

   int index = rand() % 4; //

   while(Window.pollEvent(event))
   {
         if(event.type == sf::Event::Closed)
            Window.close();
   }

   Window.clear();

   while(spritesArray[arrow].getPosition().x < windowWidth)
   {
        Window.draw(spritesArray[arrow]);
        spritesArray[arrow].move(speed, 0);
   }

   Window.display();
}
 

I think the answer might be obvious, but I can't see it.

Pages: [1]
anything