TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
albert albert
NA
524
0
move objects from right-left
Mar 12 2011 8:42 AM
Hi everybody,
I have this:
[code]
private bool MoveInvaders()
{
bool directionChanged = false;
//if ((TimerCounter % TheSpeed) == 0)
//{
//foreach (Invader invader in invaders)
// {
// invader.Move(Direction.Right);
//}
if (direction == Direction.Right)
{
//invader.Move( Direction.Right);
var invaderGroups = from invader in invaders
where invader.Location.X > boundaries.Right - 800
orderby invader.Location.Y descending
group invader by invader.Location.X into invaderGroup
//select invaderGroup;
select invader;
//theInvader.Move(Direction.Left);
//where
//select invaderGroup;
if (invaderGroups.Count() > 0) directionChanged = true;
}
//End if
else
// if (direction == Direction.Left)
{
int pixxel = boundaries.Width - GameConstants.InvaderEdgeOfScreen;
var invaderGroups = from invader in invaders
where invader.Location.X < pixxel + invader.image.Width-100 //boundaries.Width - 300
orderby invader.Location.Y descending
//select invaderGroup;
group invader by invader.Location.Y into invaderGroup
select invader;
}
if (directionChanged)
{
if (direction == Direction.Right)
{
direction = Direction.Left;
}
else
direction = Direction.Right - boundaries.Width-100;
}
//}//End timercount
//End foreacht invader
return directionChanged;
}//End method
private void MoveInvaderReal()
{
if ((TimerCounter % TheSpeed) == 0)
{
//TimerCounter = 0;
foreach (Invader invader in invaders)//These method returns a list with the moving invaders.
{
invader.Move(direction);
}
}
TimerCounter++;
}
[/code]
U see there are 2 methods. But the invaders are moving from right - left and back to left. But then the invaders are going off screen and dont come back :(.
THX for helping me!!
Reply
Answers (
4
)
Update command not working
ASP.net