How to determine the end of list has been reached?
Posted
by
Sweta Dwivedi
on Game Development
See other posts from Game Development
or by Sweta Dwivedi
Published on 2012-10-05T14:51:32Z
Indexed on
2012/10/05
15:55 UTC
Read the original article
Hit count: 278
I'm trying to animate my object according to a set of recorded values from kinect skeleton stream by saving the (x,y,z) stream from the skeletal data into a list and then set my objects x and y position from the x,y of the list. However, once the list end has been reached it starts to animate again from the start. I don't want that - I just want the model position to keep going in the positive X direction. Is there any way I can check if end of the list has been reached and to just update the model position in x direction?
Or is there any other way to continue moving my sprite once the points in the list are over... i dont want it to start animating all the way again..
protected override void Update(GameTime gameTime)
{
//position += spriteSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
//// TODO: Add your update logic here
using (StreamReader r = new StreamReader(f))
{
string line;
Viewport view = graphics.GraphicsDevice.Viewport;
int maxWidth = view.Width;
int maxHeight = view.Height;
while((line = r.ReadLine()) != null)
{
string[] temp = line.Split(',');
int x = (int) Math.Floor(((float.Parse(temp[0]) * 0.5f) + 0.5f) * maxWidth);
int y = (int) Math.Floor(((float.Parse(temp[1]) * -0.5f) + 0.5f) * maxHeight);
motion_2.Add(new Point(x, y));
}
}
position.X = motion_2[i].X;
position.Y = motion_2[i].Y;
i++;
a_butterfly_up.Update(gameTime);
a_butterfly_side.Update(gameTime);
G_vidPlayer.Play(mossV);
base.Update(gameTime);
}
© Game Development or respective owner