Forum Sveta kompjutera

Nazad   Forum Sveta kompjutera > Test Run > Programiranje
Uputstvo Članstvo Kalendar Današnje poruke Pretraži

Programiranje Programski jezici, tehnike, alatke...

 
 
Alatke vezane za temu Vrste prikaza
Stara 27.5.2015, 21:17   #1
Mosnjo
Novi član
 
Član od: 27.5.2015.
Poruke: 6
Zahvalnice: 0
Zahvaljeno 0 puta na 0 poruka
Određen forumom C# pomoc oko programa

Zelim da napravim u C# igricu na foru ruskog ruleta, imam jedan metak i 6 pokusaja. Posto sam pocetnik ne znam bas ni kako bih poceo,ako vi imate neku ideju ili jos bolje ceo program da mi uradite( do bi bilo najbolje, ali tako ne bih bas puno nauico) bio bih vam zahvalan.

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;
using System.Diagnostics;
using System.IO;
using System.Media;
using System.Threading;

namespace WindowsFormsApplication1
{
internal partial class form1 : Form
{
_Player Player = new _Player();
_life life = new _life();
_Gun Gun = new _Gun();





int counter = 0;
const int _hugeballs = 25;



public form1()
{
InitializeComponent();
life.Location = new Point(24, 21);

Controls.Add(life);
label1.Text = "Lets play game " ;
scoreLabel.Text = Player.Score.ToString();



}

private void button1_Click(object sender, EventArgs e)
{


counter++;
if (counter == 1)
{
Controls.Remove(label1);
Controls.Remove(label2);
Controls.Remove(panel2);
timer1.Enabled = false;
}

if (Player.Score < _hugeballs)
{

if (Gun.fire() == Chamber.blank)
{
UpdateScore();

life.Bigger();
}

else
{

GameOver();
Thread.Sleep(3000);
MessageBox.Show("You Lose");



}
}

else
{
MessageBox.Show("You Win");
Application.Exit();
}
}

internal void UpdateScore()
{
Player.Score++;
scoreLabel.Text = Player.Score.ToString();
}

internal void GameOver()
{
foreach (Control c in this.Controls)
{
Controls.Remove(c);
}

BackColor = System.Drawing.Color.Black;
Label l = new Label();
l.Text = "FAIL!";
l.ForeColor = System.Drawing.Color.White;
l.Size = new Size(400, 172);
l.Location = new Point(141, 202);
Controls.Add(l);
Refresh();
}

private void timer1_Tick(object sender, EventArgs e)
{
FlashPic(panel1);
FlashPic(panel2);
}

internal void FlashPic(Control c)
{
if (c.Visible == true)
c.Visible = false;
else
c.Visible = true;
}
}

internal class _life : PictureBox
{
internal _life()
{
this.BackgroundImageLayout = ImageLayout.Stretch;
this.Size = new Size(50, 55);
}

internal void Bigger()
{
this.Height += 11;
this.Width += 10;
}
}


internal class _Player
{
private string _name;
private short _score;

internal string Name
{
get { return _name; }
}

internal short Score
{
get { return _score; }
set { _score = value; }
}

internal _Player()
{
_name = System.Environment.UserName;
Score = 0;
}
}

internal class _Gun
{
Random r = new Random(System.DateTime.Now.Millisecond);

internal Chamber fire()
{
int i = r.Next(1, 7);

if (i != 6)
return Chamber.blank;

else
return Chamber.bullet;

}
}


}
internal enum Chamber { blank, bullet };

Ja sam nesto napravio , ali brojac ide u nedogled ne do 6.
Mosnjo je offline   Odgovor sa citatom ove poruke
 

Bookmarks sajtovi


Vaš status
Ne možete postavljati teme
Ne možete odgovarati na poruke
Ne možete slati priloge uz poruke
Ne možete prepravljati svoje poruke

BB kod: uključeno
Smajliji: uključeno
[IMG] kod: uključeno
HTML kod: isključeno


Slične teme
tema temu započeo forum Odgovora Poslednja poruka
Gledanje filmova putem Android telefona? Pomoc hitno Kobilic Aparati i oprema 34 13.8.2015 11:24
Identifikacija programa Y2K986 Programiranje 4 13.8.2012 0:21
Pomoc oko programa!!! Number3 Programiranje 5 7.6.2012 23:58
Pomoc oko programa u C-u absonic Programiranje 28 21.5.2012 23:27
Kako postici anonimnost kod koriscenja P2P programa The Finest Serbian Since '82 Internet tehnologije 31 7.8.2007 1:35


Sva vremena su po Griniču +2 h. Sada je 11:28.


Powered by vBulletin® verzija 3.8.7
Copyright ©2000–2024, vBulletin Solutions, Inc.
Hosted by Beograd.com