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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form2 gift;
public Form1()
{
InitializeComponent();
gift = new Form2();
gift.Hide();
}
private static int up=1, down=0, left=1, right=0;
private static Point q = new Point(200, 200);
private void timer1_Tick(object sender, EventArgs e)
{
Point p = new Point(this.DesktopLocation.X, this.DesktopLocation.Y);
if (up == 1)
{
q.Y = p.Y - 1;
if (q.Y == 0) { up = 0; down = 1; }
this.DesktopLocation = q;
}
else if (down == 1)
{
q.Y = p.Y + 1;
if (q.Y == 300) { up = 1; down = 0; }
this.DesktopLocation = q;
}
if (right == 1)
{
q.X = p.X - 1;
if (q.X == 0) { left = 1; right = 0; }
this.DesktopLocation = q;
}
else if (left == 1)
{
q.X = p.X + 1;
if (q.X == 300) { right = 1; left = 0; }
this.DesktopLocation = q;
}
}
private void Form1_Load(object sender, EventArgs e)
{
Point p = new Point(200, 200);
this.DesktopLocation = p;
}
private void label1_Click(object sender, EventArgs e)
{
this.Hide();
gift.Show();
}
}
}
No comments:
Post a Comment