C++ / Jetman Oyunu Yapmak

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Uzman Üye
Katılım
28 Kas 2015
Mesajlar
255
Tepki puanı
0
Yaş
26
10 HİZMET YILI
[font='Open Sans', Tahoma, Verdana, Arial, sans-serif]Menü stripin ilk text'i oyun olacak. Bu text'in içinde yeni oyun ve seviye alt menüleri olacak. Seviye alt menüsünde de kolay, orta, zor alt menüleri olacak. [/FONT]

[font='Open Sans', Tahoma, Verdana, Arial, sans-serif]Picturebox1'e istediğimiz resimi koyalım. Diğer 2 picturebox'ta ise ikisi de aynı resim olmalı, siyah bir resim olabilir.[/FONT]

[font='Open Sans', Tahoma, Verdana, Arial, sans-serif]Kodlar şöyle:[/FONT]

[font='Open Sans', Tahoma, Verdana, Arial, sans-serif]PHP Kod:[/FONT]
Kod:
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;

namespace jetman
{
    public partial class Form1 : Form
    {
        int a, b,a1,b1,a2,b2,s;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            timer1.Enabled = true;
            timer2.Enabled = false;
            timer3.Enabled = true;
            label1.Text = "";
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            a1 = 550;
            b1 = 12;
            a2 = 850;
            b2 = 30;
            a = 76;
            b = 76;
            pictureBox1.Location = new System.Drawing.Point(a, b);
            timer1.Interval=15;
            timer2.Interval = 15;
            timer3.Interval = 50;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            pictureBox1.Location = new System.Drawing.Point(a, b=b-2);
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            pictureBox1.Location = new System.Drawing.Point(a, b = b + 2);
        }

        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            timer2.Enabled = true;
            timer1.Enabled = false;
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            
            Random r = new Random();
            s = s + 1;
            label3.Text = s.ToString();

            pictureBox2.Location = new System.Drawing.Point(a1 = a1 - 5, b1);
            if (a1 <= -30) { a1 = 550; b1 = r.Next(250);  }
            if (a >= a1 - 69 && a <= a1 + 30 && b >= b1 - 31 && b <= b1 + 80)
            { timer1.Enabled = false;
            timer2.Enabled = false;
            timer3.Enabled = false;
            MessageBox.Show("gameover");
            }
            pictureBox3.Location = new System.Drawing.Point(a2 = a2 - 5, b2);
            if (a2 <= -30) { a2 = 550; b2 = r.Next(250); }
            if (a >= a2 - 69 && a <= a2 + 30 && b >= b2 - 31 && b <= b2 + 80)
            {
                timer1.Enabled = false;
                timer2.Enabled = false;
                timer3.Enabled = false;
                MessageBox.Show("gameover");
                
            }
            if (b <= 0 || b >= 225)
            {
                timer1.Enabled = false;
                timer2.Enabled = false;
                timer3.Enabled = false;
                MessageBox.Show("gameover");
            }
        }

        private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
        {
            timer2.Enabled = true;
            timer1.Enabled = false;

        }

        private void pictureBox2_MouseUp(object sender, MouseEventArgs e)
        {
            timer2.Enabled = true;
            timer1.Enabled = false;
        }

        private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
        {
            timer1.Enabled = true;
            timer2.Enabled = false;
        }

        private void pictureBox2_MouseDown(object sender, MouseEventArgs e)
        {
            timer1.Enabled = true;
            timer2.Enabled = false;
        }

        private void ortaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            timer3.Interval = 20;
        }

        private void kolayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            timer3.Interval = 50;
        }

        private void zorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer3.Interval = 1;
        }

        private void yeniOyunToolStripMenuItem_Click(object sender, EventArgs e)
        {
            a1 = 550;
            b1 = 12;
            a2 = 850;
            b2 = 30;
            a = 76;
            b = 76;
            pictureBox1.Location = new System.Drawing.Point(a, b);
            pictureBox2.Location = new System.Drawing.Point(a1, b1);
            pictureBox3.Location = new System.Drawing.Point(a2, b2);
            timer1.Enabled = false;
            timer2.Enabled = false;
            timer3.Enabled = false;
            s = 0;
        }
    }
}
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst