Program
Program
cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Breakout
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Breakout
{
public partial class Form1 : Form
{
bool duteStanga;
bool duteDreapta;
bool isGameOver;
int scor;
int mingeX;
int mingeY;
int vitezaPlayer;
PictureBox[] sirBlockuri;
public Form1()
{
InitializeComponent();
scoateBlockui();
}
ball.Left = 376;
ball.Top = 328;
player.Left = 347;
gameTImer.Start();
{
sirBlockuri = new PictureBox[15];
int a = 0;
if (a < 5)
{
a++;
sirBlockuri[i].Left = left;
sirBlockuri[i].Top = top;
this.Controls.Add(sirBlockuri[i]);
left = left + 130;
}
}
setupGame();
}
ball.Left += mingeX;
ball.Top += mingeY;
ball.Top = 463;
if (mingeX < 0)
{
mingeX = rnd.Next(5, 12) * -1;
}
else
{
mingeX = rnd.Next(5, 12);
}
}
mingeY = -mingeY;
this.Controls.Remove(x);
}
}
if (scor == 15)
{
gameOver("Ai castigat!! Apasa Enter ca sa joci din nou !");
}
if (e.KeyCode == Keys.Left)
{
duteStanga = true;
}
if (e.KeyCode == Keys.Right)
{
duteDreapta = true;
}
Form1.Designer.cs
namespace Breakout
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise,
false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.txtScore = new System.Windows.Forms.Label();
this.player = new System.Windows.Forms.PictureBox();
this.ball = new System.Windows.Forms.PictureBox();
this.gameTImer = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.player)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ball)).BeginInit();
this.SuspendLayout();
//
// txtScore
//
this.txtScore.AutoSize = true;
this.txtScore.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtScore.ForeColor = System.Drawing.Color.White;
this.txtScore.Location = new System.Drawing.Point(17, 16);
this.txtScore.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.txtScore.Name = "txtScore";
this.txtScore.Size = new System.Drawing.Size(95, 29);
this.txtScore.TabIndex = 0;
this.txtScore.Text = "Scor: 0";
//
// player
//
this.player.BackColor = System.Drawing.Color.MistyRose;
this.player.Location = new System.Drawing.Point(463, 606);
this.player.Margin = new System.Windows.Forms.Padding(4);
this.player.Name = "player";
this.player.Size = new System.Drawing.Size(133, 39);
this.player.TabIndex = 1;
this.player.TabStop = false;
//
// ball
//
this.ball.BackColor = System.Drawing.Color.Red;
this.ball.Location = new System.Drawing.Point(503, 366);
this.ball.Margin = new System.Windows.Forms.Padding(4);
this.ball.Name = "ball";
this.ball.Size = new System.Drawing.Size(33, 28);
this.ball.TabIndex = 1;
this.ball.TabStop = false;
//
// gameTImer
//
this.gameTImer.Interval = 20;
this.gameTImer.Tick += new System.EventHandler(this.mainGameTimerEvent);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(0)))),
((int)(((byte)(64)))));
this.ClientSize = new System.Drawing.Size(1067, 660);
this.Controls.Add(this.ball);
this.Controls.Add(this.player);
this.Controls.Add(this.txtScore);
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "Form1";
this.Text = "BreakOut";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.keyisdown);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.keyisup);
((System.ComponentModel.ISupportInitialize)(this.player)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ball)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
#endregion