Professional Documents
Culture Documents
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Contra_Game_By_Rohit_Programming_Zone
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
game_lbl.Visible = false;
class Gun
{
public string direction;
public int speed=20;
PictureBox Bullet = new PictureBox();
Timer Bullet_Movement = new Timer();
public int bullet_Left;
public int bullet_Top;
}
else if (direction =="left")
{
Bullet.Left -= speed;
}
else if (direction == "right")
{
Bullet.Left += speed;
}
else if (direction == "up")
{
Bullet.Top -= speed;
}
}
}
string target;
private void firing(string location)
{
Gun Bullet = new Gun();
Bullet.direction = target;
Bullet.bullet_Left = player.Left + (player.Width / 2);
Bullet.bullet_Top = player.Top + (player.Height / 2);
Bullet.Get_Bullet(this);
}
}
else
{
alien_1.Top += Move;
}
if (alien_2.Top >= 500)
{
y = rnd.Next(0, 800);
alien_2.Location = new Point(y, 0);
}
else
{
alien_2.Top += Move;
}
if (alien_3.Top >= 500)
{
x = rnd.Next(0, 800);
alien_3.Location = new Point(x, 0);
}
else
{
alien_3.Top += Move;
}
if (alien_4.Top >= 500)
{
y = rnd.Next(0, 800);
alien_4.Location = new Point(y, 0);
}
else
{
alien_4.Top += Move;
}
if (alien_5.Top >= 500)
{
y = rnd.Next(0, 800);
alien_5.Location = new Point(y, 0);
}
else
{
alien_5.Top += Move;
}
alians(5);
Game_Over();
foreach(Control a in this.Controls)
{
foreach(Control b in this.Controls)
{
if(a is PictureBox && a.Tag=="alien")
{
if(b is PictureBox && b.Tag=="bullet")
{
if(a.Bounds.IntersectsWith(b.Bounds))
{
this.Controls.Remove(a);
a.Dispose();
this.Controls.Remove(b);
b.Dispose();
score += 20;
Score_lbl.Text = "Score - " + score;
if(score==100)
{
game_lbl.Text = "Level Cleared..";
game_lbl.Visible = true;
timer1.Stop();
}
}
}
}
}
}