PDA

View Full Version : اشکالش چیه؟



zeinab03
یک شنبه 09 خرداد 1389, 10:58 صبح
سلام
من این برنامه رو با ترد(thread) نوشتم لطفا بگین اشکالش کجاست؟
برنامه اجرا نمیشه:عصبانی++::عصبانی++:
فردا باس تحویل بدم
یکی کمکم کنههههههههههههههههههههه:گ یه::گریه::گریه:

برنامه ش شبیه بازیه 2 تا پیکچر باکس داره یکی به دادم برسه:گریه:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
System.Windows.Forms.Control.CheckForIllegalCrossT hreadCalls = false;

namespace Ostad_jafar_nejad
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int speed = 1;
int result;
bool top, left;
Thread th1,th2;

private void Form1_Load(object sender, EventArgs e)
{
Random rand = new Random();
pictureBox1.Location = new Point(0, rand.Next(this.Height));
top = left = true;
th1 = new Thread(func1);
th2 = new Thread(func2);
th1.Priority = ThreadPriority.Normal;
th2.Priority = ThreadPriority.Normal;
th1.Start();
th2.Start();
}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
th1 = new Thread(func1);
th2 = new Thread(func2);
th1.Priority = ThreadPriority.Normal;
th2.Priority = ThreadPriority.Normal;
pictureBox2.Top = e.Y;
th1.Start();
th2.Start();
}
private void func1()
{
if (pictureBox1.Left > pictureBox2.Left)
{
// timer1.Enabled = false;
MessageBox.Show("شما باختید...امتیاز " + result.ToString()); result = 0;
}
if (
pictureBox1.Left + pictureBox1.Width >= pictureBox2.Left &&
pictureBox1.Left + pictureBox1.Width <= pictureBox2.Left + pictureBox2.Width
&& pictureBox1.Top + pictureBox1.Height >= pictureBox2.Top &&
pictureBox1.Top + pictureBox1.Height <= pictureBox2.Top + pictureBox2.Height + pictureBox1.Height
)
{
left = false;
result += 1;
this.Text = result.ToString();
}
}
private void func2()
{
if (left)
pictureBox1.Left += speed;
else
pictureBox1.Left -= speed;
if (top)
pictureBox1.Top += speed;
else
pictureBox1.Top -= speed;
if (pictureBox1.Top >= this.Height - 50)
top = false;
if (pictureBox1.Top <= 0)
top = true;
if (pictureBox1.Left <= 0)
left = true;


}

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyValue)
{
case 38:
{
pictureBox1.Top -= 10;
th1 = new Thread(func1);
th2 = new Thread(func2);
th1.Priority = ThreadPriority.Normal;
th2.Priority = ThreadPriority.Normal;
// pictureBox2.Top = e.Y;
th1.Start();
th2.Start();
break;
}
case 40:
{
pictureBox1.Top += 10;
th1 = new Thread(func1);
th2 = new Thread(func2);
th1.Priority = ThreadPriority.Normal;
th2.Priority = ThreadPriority.Normal;
//pictureBox2.Top = e.Y;
th1.Start();
th2.Start();
break;
}
}

}
}


}

ji ming u
یک شنبه 16 خرداد 1389, 13:20 عصر
يكم توضيح بده تا بدونيم قضيه چيه

mmd2009
یک شنبه 16 خرداد 1389, 13:57 عصر
تو این مواقع : برنامه رو میذارن میگن اشکالاتش رو برطرف کنید و بعدش بذارید واسم