Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Microsoft.VisualBasic.PowerPacks;
- namespace C_Sharp_Gravity_Ball_SRC
- {
- public partial class Form1 : Form
- {
- public int UPDOWN = 0;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (UPDOWN == 2)
- {
- ovalShape1.Location = new Point(ovalShape1.Location.X, ovalShape1.Location.Y + 1);
- }
- if (UPDOWN == 1)
- {
- ovalShape1.Location = new Point(ovalShape1.Location.X, ovalShape1.Location.Y - 1);
- }
- if (UPDOWN == 0)
- {
- // ovalShape1.Location = new Point(ovalShape1.Location.X + 1, ovalShape1.Location.Y);
- }
- ovalShape1.Location = new Point(ovalShape1.Location.X + 1, ovalShape1.Location.Y);
- if (ovalShape1.Location == ovalShape2.Location)
- {
- GameOver();
- timer1.Enabled = false;
- MessageBox.Show("You Win!!");
- Application.Exit();
- return;
- }
- if (ovalShape1.Location.Y <= -29 ^ ovalShape1.Location.Y >= 410)
- {
- GameOver1();
- MessageBox.Show("You Win!!");
- Application.Exit();
- return;
- }
- if (ovalShape1.Location.X >= 521)
- {
- GameOver1();
- MessageBox.Show("You Win!!");
- Application.Exit();
- return;
- }
- }
- private void Form1_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == 38)
- {
- UPDOWN = 2;
- //ovalShape1.Location = new Point(ovalShape1.Location.X, ovalShape1.Location.Y - 1);
- }
- if (e.KeyChar == 40)
- {
- UPDOWN = 1;
- //ovalShape1.Location = new Point(ovalShape1.Location.X, ovalShape1.Location.Y + 1);
- }
- }
- private void Form1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Up)
- {
- UPDOWN = 2;
- }
- if (e.KeyCode == Keys.Down)
- {
- UPDOWN = 1;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- UPDOWN = 2;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- UPDOWN = 1;
- }
- public void GameOver()
- {
- DialogResult PlayAgain;
- timer1.Enabled = false;
- MessageBox.Show("You Win!!", "Gravity Ball [Ver 1.0]", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- PlayAgain = MessageBox.Show("Do you want to play again?", "Gravity Ball [Ver 1.0]", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (PlayAgain == DialogResult.No)
- {
- Application.Exit();
- ActiveForm.Close();
- }
- else if (PlayAgain == DialogResult.Yes)
- {
- // System.Diagnostics.Process.Start("Gravity Ball [Version 1.0].exe");
- System.Diagnostics.Process.Start("C-Sharp Gravity Ball SRC.exe");
- Application.Exit();
- ActiveForm.Close();
- }
- }
- public void GameOver1()
- {
- DialogResult PlayAgain;
- timer1.Enabled = false;
- MessageBox.Show("You Lose!!", "Gravity Ball [Ver 1.0]", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- PlayAgain = MessageBox.Show("Do you want to play again?", "Gravity Ball [Ver 1.0]", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (PlayAgain == DialogResult.No)
- {
- Application.Exit();
- ActiveForm.Close();
- }
- else if (PlayAgain == DialogResult.Yes)
- {
- // System.Diagnostics.Process.Start("Gravity Ball [Version 1.0].exe");
- System.Diagnostics.Process.Start("C-Sharp Gravity Ball SRC.exe");
- Application.Exit();
- ActiveForm.Close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement