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
bobo cent
NA
1
0
Space Invaders Project
Nov 19 2009 3:24 PM
Hi iam doing a project for my games class which is to produce a space invaders game (a very basic one) for C# in a windows form. My one problem is that i cant quite get how to make the alien move to the end of the row and then move down,then move to the left, then move down,etc. My code so far for this part is this, which makes the alien go along then down, left but then goes back up and starts again. How can i change my code to make it move as it is supposed to? bear in mind it has to be very basic coding or else my lecturer may start to wonder how i know these advance codes.
int speed = 1, playerx = 253, playery = 460, bulletx = 253, bullety = 460, alienx = 0, alieny = 0;
double score = 0;
bool fire = false;
private void tmrgo_Tick(object sender, EventArgs e)
{
if (alienx <= 500 && alieny <= 0)
{
alienx += 5;
alieny = 0;
hit();
}
if (alienx >= 500 && alieny <= 50)
{
alieny += 5;
alienx = 500;
hit();
}
if (alienx >= 0 && alieny >= 50)
alienx -= 5;
hit();
if (alienx <= 0 && alieny <= 50)
alieny -= 5;
hit();
if (alienx <= 0 && alieny <= 0)
{
speed += 5;
hit();
}
if (speed >= 500)
speed = 9;
hit();
picalien.Location = new Point(alienx, alieny);
}
Reply
Answers (
1
)
Show info on datagridview when row is selected
Windows App Published with Visual Studio 2005 comes up blank