Sponsored By

Cool_Dragon

Members
  • Content Count

    6
  • Joined

  • Last visited

Everything posted by Cool_Dragon

  1. Well before that code you told me. What it does now is bounces off the walls all four sides and paddeles as well. I am looking for a scorecborad idk how to do and to make it like when the ball hits the wall the other player gets a point and then you add one to the score.
  2. I have microsoft visual studios . net 2003 edition for c# and I am wondering really i will post the code here like how to like make a scoreboard out of this really. I got the paddles to work make it bounce off of them but now I need them to like make it like a game. I mean is for it to score if one paddles go over the ither here is the code hopefully someone will help. using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace Keyboard { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.ComponentModel.IContainer components; // Global Variables int dx=0, dy=0, newX=0, newY=0,dx2=0,dy2=0,newX2=0,newY2=0, newX3=0, newY3=0, bdx=0, bdy=0; private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Timer timer2; private System.Windows.Forms.Label lblBall; private System.Windows.Forms.Label Score1; private System.Windows.Forms.Label Score3; private System.Windows.Forms.Label Score2; private System.Windows.Forms.Label Score4; private System.Windows.Forms.Label label1; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <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.label1 = new System.Windows.Forms.Label(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.label2 = new System.Windows.Forms.Label(); this.timer2 = new System.Windows.Forms.Timer(this.components); this.lblBall = new System.Windows.Forms.Label(); this.Score1 = new System.Windows.Forms.Label(); this.Score3 = new System.Windows.Forms.Label(); this.Score2 = new System.Windows.Forms.Label(); this.Score4 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.BackColor = System.Drawing.Color.Blue; this.label1.Location = new System.Drawing.Point(104, 32); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(88, 8); this.label1.TabIndex = 0; // // timer1 // this.timer1.Enabled = true; this.timer1.Interval = 1; this.timer1.Tick += new System.EventHandler(this.timer1_Tick_1); // // label2 // this.label2.BackColor = System.Drawing.Color.Blue; this.label2.Location = new System.Drawing.Point(104, 224); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(88, 8); this.label2.TabIndex = 1; // // timer2 // this.timer2.Enabled = true; this.timer2.Interval = 20; this.timer2.Tick += new System.EventHandler(this.timer2_Tick); // // lblBall // this.lblBall.BackColor = System.Drawing.Color.White; this.lblBall.Location = new System.Drawing.Point(152, 128); this.lblBall.Name = "lblBall"; this.lblBall.Size = new System.Drawing.Size(8, 8); this.lblBall.TabIndex = 2; // // Score1 // this.Score1.BackColor = System.Drawing.Color.White; this.Score1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Score1.Location = new System.Drawing.Point(0, 0); this.Score1.Name = "Score1"; this.Score1.Size = new System.Drawing.Size(32, 24); this.Score1.TabIndex = 3; this.Score1.Text = " 0"; // // Score3 // this.Score3.BackColor = System.Drawing.Color.White; this.Score3.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Score3.Location = new System.Drawing.Point(0, 248); this.Score3.Name = "Score3"; this.Score3.Size = new System.Drawing.Size(24, 24); this.Score3.TabIndex = 4; this.Score3.Text = "0"; // // Score2 // this.Score2.BackColor = System.Drawing.Color.White; this.Score2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Score2.Location = new System.Drawing.Point(264, 0); this.Score2.Name = "Score2"; this.Score2.Size = new System.Drawing.Size(48, 24); this.Score2.TabIndex = 5; this.Score2.Text = "0"; // // Score4 // this.Score4.BackColor = System.Drawing.Color.White; this.Score4.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Score4.Location = new System.Drawing.Point(264, 248); this.Score4.Name = "Score4"; this.Score4.Size = new System.Drawing.Size(32, 32); this.Score4.TabIndex = 6; this.Score4.Text = "0"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.Score4); this.Controls.Add(this.Score2); this.Controls.Add(this.Score3); this.Controls.Add(this.Score1); this.Controls.Add(this.lblBall); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Name = "Form1"; this.Text = "Pong"; this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown); this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress); this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyUp); this.ResumeLayout(false); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [sTAThread] static void Main() { Application.Run(new Form1()); } private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { //label.Text += Convert.ToString(e.KeyChar); } private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { //label.Text = "Down: " + Convert.ToString(e.KeyCode); switch(e.KeyCode) { case Keys.Right: dx = 2; dy = 0; break; case Keys.Left: dx = -2; dy = 0; break; } switch(e.KeyCode) { case Keys.D: dx2 = 2; dy2 = 0; break; case Keys.A: dx2 = -2; dy2 = 0; break; } switch(e.KeyCode) { case Keys.B: bdx = 2; bdy = 5; break; } } private void Form1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { //label1.Text = "Up: " + Convert.ToString(e.KeyCode); } private void timer1_Tick_1(object sender, System.EventArgs e) { newX=label1.Location.X + dx; if (newX >this.Width-label1.Width) dx=-dx; if (newX <0) dx=-dx; newY =label1.Location.Y + dy; Point newLoc = new Point(newX,newY); label1.Location = newLoc; newX2=label2.Location.X + dx2; newY2=label2.Location.Y + dy2; if (newX2 >this.Width-label1.Width) dx2=-dx2; if (newX2 <0) dx2=-dx2; Point newLoc2 = new Point(newX2,newY2); label2.Location = newLoc2; } private void timer2_Tick(object sender, System.EventArgs e) { newX3=lblBall.Location.X + bdx; newY3=lblBall.Location.Y + bdy; if (newX3 >this.Height-lblBall.Width) bdx=-bdx; if (newX3 <0) bdx=-bdx; if (newY3 >this.Height-lblBall.Width) bdy=-bdy; if (newY3 <0) bdy=-bdy; Point newLoc3 = new Point(newX3,newY3); lblBall.Location = newLoc3; if(lblBall.Bounds.IntersectsWith(label1.Bounds)) { bdx=-bdx; bdy=-bdy; } if(lblBall.Bounds.IntersectsWith(label2.Bounds)) { bdx=-bdx; bdy=-bdy; } } } } copyright me or whatver. Edit/Delete Message
  3. I am still bad at this can you please try to do it for me and stuff please it is due tommorrow i really need to finish this thank you.
  4. Yeah I have the star picture but I really dont know how to do the rest really can please someone like do it fast or something please. Thanks.
  5. I have microsoft visual studio .net 2003 C# version. I need big help with like a program if anyone can do this for me that would be wonder but you dont if you could I would appreciate it. I have to like make a program that can add averages up like 90 85 95 and press add to the rich text box and then press the calculate button and then it will make a average and a star will come up next to it. I have a picture of what it should look like http://img160.imageshack.us/my.php?image=untitled4go1.jpg. This is a picture of what it show look like. I want it too like put in a number and it goes to the rich text box and then you calculate it and a star should appear. You also need to use arrays and loops if that helps. Thanks any help would be helpful doing it fast for me and telling me how you got it and or telling me what to do. I am very new at this stuff thanks again and I need a reply kinda fast if possible. Thanks for any help please this project is due tomorrow thanks.