I'm writing a laser connection game. This is my first game on Windows Phone, and I've never used C# and XNA before.
The part of my code that could be improved is Update()
(where I make my sprites move).
public void Update(GameTime gameTime)
{
TouchPanelCapabilities touchCap = TouchPanel.GetCapabilities();
if (touchCap.IsConnected)
{
TouchCollection touches = TouchPanel.GetState();
if (touches.Count >= 1)
{
Vector2 PositionTouch = touches[0].Position;
for (int i = 0; i < ListDragObj.Count(); i++)
{
if (ListDragObj[i].Shape.Contains((int)PositionTouch.X, (int)PositionTouch.Y))
{
//Permit to avoid several Obj to moove in the same time
if (!OnlyOneSelected(ListDragObj))
{
ListDragObj[i].selected = true;
TamponPosition = ListDragObj[i].Position;
}
}
else
{
ListDragObj[i].selected = false;
}
if (touches[touches.Count - 1].State == TouchLocationState.Released)
{
if (gm.Check_Tile((int)(PositionTouch.X / 10), (int)(PositionTouch.Y / 10)))
{
ListDragObj[i].Update(PositionTouch);
}
else
{
ListDragObj[i].Update(TamponPosition);
}
}
}
}
}
}
I'm looking for the selected Sprite (in the List ListDragobj
), and then I move it.
The last couple if/else
is where I check collisions.
I was wondering how I could improve that position Update()
method.
The last couple if/else is where I check collisions (it actually doesn't work fine, but that's another point)
this could lead down a bunny trail to other issues in your code. get it functioning and then bring it back for review, or limit your review question to the parts of your code that work, if the code you want reviewed links {in any way} to the code that doesn't work, then this question is off-topic. – Malachi Nov 6 '13 at 16:40