I am having trouble making my frogger game work and needed some help:
I can get the frog to appear but the cars won't and i keep getting errors any help would be appreciated.Code:
private void timer1_Tick(object sender, EventArgs e)
{
for (int i = 1; i <= 6; i++)
{
// move falling obejct [i]
LeftCarX[i] = LeftCarX[i] + LeftCarSpeed[i];
// check if falling object [i] has been hit
if ((LeftCarY[i] + LeftCarSize) > (ClientSize.Width - FroggerFrog.Width))
{
if (LeftCarX[i] - 20 < x) //-20/+20 added to make sure falling
{ //ojbect bigger than dribbler
if ((LeftCarX[i] + LeftCarSize + 20) > (x + FroggerFrog.Width))
{
// object [i] has been hit
// Increase score - move back to top
Console.Beep();
//txtScore.Text = Convert.ToString(Convert.ToInt32(txtScore.Text) + 1);
LeftCarY[i] = -LeftCarSize;
LeftCarSpeed[i] = myrandom.Next(4) + 3;
}
}
}
// check for moving off bottom
if ((LeftCarY[i] + LeftCarSize) > ClientSize.Height)
{
// object [i] reaches bottom without being hit
// Move back to top with new speed
LeftCarY[i] = -LeftCarSize;
LeftCarSpeed[i] = myrandom.Next(4) + 3;
}
// redraw falling object [i] and dribbler at new location
myGraphics.DrawImage(FroggerFrog, x, ClientSize.Height - FroggerFrog.Width, FroggerFrog.Width, FroggerFrog.Height);
myGraphics.DrawImage(LeftCars[i], LeftCarX[i], LeftCarY[i], LeftCarSize, LeftCarSize);
}
}
private void BtnStart_Click_1(object sender, EventArgs e)
{
NewGame();
timer1.Enabled = true;
timer2.Enabled = true;
timer3.Enabled = true;
timer4.Enabled = true;
timer5.Enabled = true;
timer6.Enabled = true;
// set each ball off side of panel and give new speed
for (int i = 0; i < 6; i++)
{
LeftCarX[i] = -LeftCarSize;
LeftCarSpeed[i] = myrandom.Next(4) + 3;
}
// Set man near center
x = (int)(ClientSize.Width / 2);
// Give form focus so it can accept KeyDown events
this.Focus();
}
}
}

