Amaliy matematika va intellektual texnologiyalar fakulteti
Foydalanilgan internet web manzillari
Download 447.75 Kb.
|
kurs ishi c# new
Foydalanilgan internet web manzillari
https://metanit.com/ www.yandex.ru – axborotlar qidirish tizimi www.ziyonet.uz – ZiyoNet axborot ta’lim portal Ilovalar Ping pong o’yini 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 Game_time2 { public partial class Form1 : Form { public int Speed_left = 4; public int Speed_top = 4; public int point = 0; public Form1() { InitializeComponent(); timer1.Enabled = true; Cursor.Hide();//Hide the cursor this.FormBorderStyle = FormBorderStyle.None;//Remove this border this.TopMost = true; this.Bounds = Screen.PrimaryScreen.Bounds; racket.Top = playground.Bottom - (playground.Bottom / 10);//set position of racket } private void timer1_Tick(object sender, EventArgs e) { racket.Left = Cursor.Position.X - (racket.Width / 2); ball.Left += Speed_left;// move the ball ball.Top += Speed_top; if (ball.Bottom >= racket.Top && ball.Bottom <= racket.Bottom && ball.Left >= racket.Left && ball.Right < racket.Right)//racket collision { Speed_top += 2; Speed_left += 2; Speed_top = -Speed_top;//change direction point += 1; } if (ball.Left <= playground.Left) { Speed_left = -Speed_left; } if (ball.Right >= playground.Right) { Speed_left = -Speed_left;} if (ball.Top <= playground.Top) { Speed_top = -Speed_top;} if (ball.Bottom >= playground.Bottom) { timer1.Enabled = false; Close(); } } private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.Close(); } private void Form1_Load(object sender, EventArgs e) // Draw butterfly curves on both PictureBoxes. private void DrawCurves() { // Clear both images. picCanvas1.Image = null; picCanvas2.Refresh(); picCanvas1.Refresh(); int wid = picCanvas2.ClientSize.Width; int hgt = picCanvas2.ClientSize.Height; // Draw with double-buffering. Bitmap bm = new Bitmap(wid, hgt); using (Graphics gr = Graphics.FromImage(bm)) { DrawButterfly(gr, wid, hgt); } picCanvas1.Image = bm; picCanvas1.Refresh(); // Draw without double-buffering. DrawButterfly(picCanvas2.CreateGraphics(), wid, hgt); } Download 447.75 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling