- Katılım
- 6 Mayıs 2022
- Konular
- 48,280
- Mesajlar
- 48,590
- Tepkime puanı
- 75
- M2 Yaşı
- 3 yıl 11 ay 10 gün
- Trophy Puan
- 48
- M2 Yang
- 488,769
Windows Forms Application ile yapılmıştır.
Pek fazla görselliği olmasa da işinize yarayabilir.
Zar oyunundaki amaç 30 puanı geçen ilk oyuncu kazanıyor. 1. oyuncu başlamadan 2. oyuncu başlıyamıyor.
İşte Kodlar:
### REKLMA YASAK ###
C# Zar Oyunu
Günümüzde oyun geliştirme alanında C# programlama dili, özellikle Unity gibi oyun motorları ile birlikte oldukça yaygın bir şekilde kullanılmaktadır. Ancak sadece büyük oyunlar değil, aynı zamanda küçük çaplı örnek uygulamalar da öğrenme sürecinde oldukça faydalıdır. Bu yazıda, C# ile yazılmış basit bir zar oyunu geliştireceğiz. Bu proje, özellikle Metin2 özel sunucularında geliştirme yapan ya da C++ sistemlerine alternatif olarak Python veya C# kullanmayı düşünen geliştiriciler için bir temel oluşturabilir.
Zar Oyununun Temel Yapısı
Zar oyunumuz iki oyunculu bir yapıya sahip olacak. Her oyuncu sırayla zar atacak ve belirlenen tur sayısına göre kazanan belirlenecektir. Oyun sonunda, en yüksek skoru elde eden oyuncu galip gelecektir. Bu tarz sistemler, Metin2 özel sunucularında mini oyun modları olarak da kullanılabilir.
Oyunun Geliştirilmesi
Oyunu C# dilinde konsol üzerinden geliştireceğiz. İlk adım olarak rastgele sayı üretimi için Random sınıfı kullanılacaktır. Bu sayede zar atımı simüle edilecektir. Oyunun akışı şu şekilde olacaktır:
- Oyuncuların isimleri alınacak
- Belirlenen tur sayısı kadar zar atışı yapılacak
- Her turda iki oyuncu da kendi zarlarını atacak
- En yüksek toplam puana sahip olan oyuncu kazanacak
Kod Örneği
using System;
namespace DiceGame
{
class Program
{
static void Main(string[*] args)
{
Console.WriteLine('Zar Oyununa Hosgeldiniz!');
Console.Write('1. Oyuncu adi: ');
string player1 = Console.ReadLine();
Console.Write('2. Oyuncu adi: ');
string player2 = Console.ReadLine();
Random random = new Random();
int score1 = 0, score2 = 0;
for (int i = 0; i < 5; i++) // 5 tur oynanacak
{
int roll1 = random.Next(1, 7);
int roll2 = random.Next(1, 7);
Console.WriteLine($'{player1} zar atti: {roll1}');
Console.WriteLine($'{player2} zar atti: {roll2}');
score1 += roll1;
score2 += roll2;
}
Console.WriteLine($'Toplam Skorlar: {player1}: {score1}, {player2}: {score2}');
if (score1 > score2)
Console.WriteLine($'Kazanan: {player1}');
else if (score2 > score1)
Console.WriteLine($'Kazanan: {player2}');
else
Console.WriteLine('Beraberlik!');
Console.ReadKey();
}
}
}
Metin2 Özel Sunucular İçin Uygulama Potansiyeli
Bu tarz zar oyunları, Metin2 özel sunucularında PvP sistemlerinin haricinde eğlence amaçlı mini oyunlar olarak da eklenebilir. Özellikle oyun içi etkinliklerde veya turnuvalarda kullanılmak üzere geliştirilebilir. C# veya Python ile yazılmış bu tür sistemler, oyun sunucusuna entegre edilerek dinamik mini oyunlar oluşturulabilir. Bu, oyuncu deneyimini zenginleştirmek için harika bir yöntemdir.
Sonuç
C# ile yazılmış bu zar oyunu örneği, hem öğrenmek isteyen geliştiriciler için harika bir başlangıç noktası olabilir hem de Metin2 özel sunucularında mini oyun geliştirme konusunda ilham verebilir. Geliştirme sürecinde farklı özellikler eklenerek oyun daha da zenginleştirilebilir. Örneğin bonus puanlar, özel zar efektleri veya oyun içi item kazanma gibi sistemler eklenebilir.
C# Dice Game
Today, in the field of game development, the C# programming language is widely used especially with game engines such as Unity. However, not only large-scale games but also small sample applications can be quite beneficial during the learning process. In this article, we will develop a simple dice game written in C#. This project can serve as a foundation for developers working on Metin2 private servers or considering alternatives like Python or C# instead of C++ systems.
Basic Structure of the Dice Game
Our dice game will have a two-player structure. Each player will roll the dice in turns, and the winner will be determined based on the number of rounds played. At the end of the game, the player with the highest total score will win. Such systems can also be implemented as mini-game modes in Metin2 private servers.
Development of the Game
We will develop the game via console in C#. As the first step, the Random class will be used to generate random numbers, thus simulating dice rolls. The flow of the game will be as follows:
- Player names will be entered
- Dice rolls will occur for a predetermined number of rounds
- Each round, both players will roll their dice
- The player with the highest total points wins
Code Example
using System;
namespace DiceGame
{
class Program
{
static void Main(string[*] args)
{
Console.WriteLine('Welcome to the Dice Game!');
Console.Write('Player 1 name: ');
string player1 = Console.ReadLine();
Console.Write('Player 2 name: ');
string player2 = Console.ReadLine();
Random random = new Random();
int score1 = 0, score2 = 0;
for (int i = 0; i < 5; i++) // 5 rounds will be played
{
int roll1 = random.Next(1, 7);
int roll2 = random.Next(1, 7);
Console.WriteLine($'{player1} rolled: {roll1}');
Console.WriteLine($'{player2} rolled: {roll2}');
score1 += roll1;
score2 += roll2;
}
Console.WriteLine($'Final Scores: {player1}: {score1}, {player2}: {score2}');
if (score1 > score2)
Console.WriteLine($'Winner: {player1}');
else if (score2 > score1)
Console.WriteLine($'Winner: {player2}');
else
Console.WriteLine('Tie!');
Console.ReadKey();
}
}
}
Potential Application for Metin2 Private Servers
Such dice games can also be added as entertainment-based mini-games within Metin2 private servers, apart from PvP systems. They can be particularly useful during in-game events or tournaments. Systems developed in C# or Python can be integrated into the game server to create dynamic mini-games. This is an excellent way to enhance the overall player experience.
Conclusion
This example of a dice game written in C# can serve as an excellent starting point for aspiring developers and can inspire ideas for creating mini-games in Metin2 private servers. Additional features can be added during the development process to further enrich the game. For instance, bonus points, special dice effects, or in-game item rewards can be implemented.
Pek fazla görselliği olmasa da işinize yarayabilir.
Zar oyunundaki amaç 30 puanı geçen ilk oyuncu kazanıyor. 1. oyuncu başlamadan 2. oyuncu başlıyamıyor.
İşte Kodlar:
Kod:
[/COLOR][SIZE=3][COLOR=#0000FF][COLOR=#333333][B]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 Zar_oyunu { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int Oyuncu1Puan = 0, Oyuncu2Puan = 0; bool Oyuncu1Durum = false, Oyuncu2Durum = false; private string Rasgele(Label label) { Random rastgele = new Random(); int zar = rastgele.Next(1, 7); label.Text = zar.ToString(); return label.Text; } void ButonKontrol() { if(Oyuncu1Durum==false) { button1.Enabled=true; button2.Enabled=false; } if (Oyuncu2Durum == false) { button2.Enabled = true; button1.Enabled = false; } } void YeniOyun() { Oyuncu1Durum = false; Oyuncu2Durum = false; Oyuncu1Puan = 0; Oyuncu2Puan = 0; button1.Enabled = true; button2.Enabled = true; label1.Text = ""; label2.Text = ""; label3.Text = ""; label4.Text = ""; } private void button1_Click(object sender, EventArgs e) { Rasgele(label1); Oyuncu1Puan = Oyuncu1Puan + Convert.ToInt16(label1.Text); label3.Text = Oyuncu1Puan.ToString(); Oyuncu1Durum = true; Oyuncu2Durum = false; ButonKontrol(); if (Oyuncu1Puan >= 30) { MessageBox.Show("Tebrikler, 1.Oyuncu Kazandı.", "Tebrikler.."); } } private void button2_Click(object sender, EventArgs e) { if (button1.Enabled == true) { MessageBox.Show("Önce 1.Oyuncu Oynamalıdır!", "Hata"); } else { Rasgele(label2); Oyuncu2Puan = Oyuncu2Puan + Convert.ToInt16(label2.Text); label4.Text = Oyuncu2Puan.ToString(); Oyuncu2Durum = true; Oyuncu1Durum = false; ButonKontrol(); if (Oyuncu2Puan >= 30) { MessageBox.Show("Tebrikler, 2.Oyuncu Kazandı.", "Tebrikler.."); } } } private void button3_Click(object sender, EventArgs e) { YeniOyun(); } private void Form1_Load(object sender, EventArgs e) { YeniOyun(); } } }[/B][/COLOR][/COLOR][/SIZE][COLOR=#0000ff]
### REKLMA YASAK ###
C# Zar Oyunu
Günümüzde oyun geliştirme alanında C# programlama dili, özellikle Unity gibi oyun motorları ile birlikte oldukça yaygın bir şekilde kullanılmaktadır. Ancak sadece büyük oyunlar değil, aynı zamanda küçük çaplı örnek uygulamalar da öğrenme sürecinde oldukça faydalıdır. Bu yazıda, C# ile yazılmış basit bir zar oyunu geliştireceğiz. Bu proje, özellikle Metin2 özel sunucularında geliştirme yapan ya da C++ sistemlerine alternatif olarak Python veya C# kullanmayı düşünen geliştiriciler için bir temel oluşturabilir.
Zar Oyununun Temel Yapısı
Zar oyunumuz iki oyunculu bir yapıya sahip olacak. Her oyuncu sırayla zar atacak ve belirlenen tur sayısına göre kazanan belirlenecektir. Oyun sonunda, en yüksek skoru elde eden oyuncu galip gelecektir. Bu tarz sistemler, Metin2 özel sunucularında mini oyun modları olarak da kullanılabilir.
Oyunun Geliştirilmesi
Oyunu C# dilinde konsol üzerinden geliştireceğiz. İlk adım olarak rastgele sayı üretimi için Random sınıfı kullanılacaktır. Bu sayede zar atımı simüle edilecektir. Oyunun akışı şu şekilde olacaktır:
- Oyuncuların isimleri alınacak
- Belirlenen tur sayısı kadar zar atışı yapılacak
- Her turda iki oyuncu da kendi zarlarını atacak
- En yüksek toplam puana sahip olan oyuncu kazanacak
Kod Örneği
using System;
namespace DiceGame
{
class Program
{
static void Main(string[*] args)
{
Console.WriteLine('Zar Oyununa Hosgeldiniz!');
Console.Write('1. Oyuncu adi: ');
string player1 = Console.ReadLine();
Console.Write('2. Oyuncu adi: ');
string player2 = Console.ReadLine();
Random random = new Random();
int score1 = 0, score2 = 0;
for (int i = 0; i < 5; i++) // 5 tur oynanacak
{
int roll1 = random.Next(1, 7);
int roll2 = random.Next(1, 7);
Console.WriteLine($'{player1} zar atti: {roll1}');
Console.WriteLine($'{player2} zar atti: {roll2}');
score1 += roll1;
score2 += roll2;
}
Console.WriteLine($'Toplam Skorlar: {player1}: {score1}, {player2}: {score2}');
if (score1 > score2)
Console.WriteLine($'Kazanan: {player1}');
else if (score2 > score1)
Console.WriteLine($'Kazanan: {player2}');
else
Console.WriteLine('Beraberlik!');
Console.ReadKey();
}
}
}
Metin2 Özel Sunucular İçin Uygulama Potansiyeli
Bu tarz zar oyunları, Metin2 özel sunucularında PvP sistemlerinin haricinde eğlence amaçlı mini oyunlar olarak da eklenebilir. Özellikle oyun içi etkinliklerde veya turnuvalarda kullanılmak üzere geliştirilebilir. C# veya Python ile yazılmış bu tür sistemler, oyun sunucusuna entegre edilerek dinamik mini oyunlar oluşturulabilir. Bu, oyuncu deneyimini zenginleştirmek için harika bir yöntemdir.
Sonuç
C# ile yazılmış bu zar oyunu örneği, hem öğrenmek isteyen geliştiriciler için harika bir başlangıç noktası olabilir hem de Metin2 özel sunucularında mini oyun geliştirme konusunda ilham verebilir. Geliştirme sürecinde farklı özellikler eklenerek oyun daha da zenginleştirilebilir. Örneğin bonus puanlar, özel zar efektleri veya oyun içi item kazanma gibi sistemler eklenebilir.
C# Dice Game
Today, in the field of game development, the C# programming language is widely used especially with game engines such as Unity. However, not only large-scale games but also small sample applications can be quite beneficial during the learning process. In this article, we will develop a simple dice game written in C#. This project can serve as a foundation for developers working on Metin2 private servers or considering alternatives like Python or C# instead of C++ systems.
Basic Structure of the Dice Game
Our dice game will have a two-player structure. Each player will roll the dice in turns, and the winner will be determined based on the number of rounds played. At the end of the game, the player with the highest total score will win. Such systems can also be implemented as mini-game modes in Metin2 private servers.
Development of the Game
We will develop the game via console in C#. As the first step, the Random class will be used to generate random numbers, thus simulating dice rolls. The flow of the game will be as follows:
- Player names will be entered
- Dice rolls will occur for a predetermined number of rounds
- Each round, both players will roll their dice
- The player with the highest total points wins
Code Example
using System;
namespace DiceGame
{
class Program
{
static void Main(string[*] args)
{
Console.WriteLine('Welcome to the Dice Game!');
Console.Write('Player 1 name: ');
string player1 = Console.ReadLine();
Console.Write('Player 2 name: ');
string player2 = Console.ReadLine();
Random random = new Random();
int score1 = 0, score2 = 0;
for (int i = 0; i < 5; i++) // 5 rounds will be played
{
int roll1 = random.Next(1, 7);
int roll2 = random.Next(1, 7);
Console.WriteLine($'{player1} rolled: {roll1}');
Console.WriteLine($'{player2} rolled: {roll2}');
score1 += roll1;
score2 += roll2;
}
Console.WriteLine($'Final Scores: {player1}: {score1}, {player2}: {score2}');
if (score1 > score2)
Console.WriteLine($'Winner: {player1}');
else if (score2 > score1)
Console.WriteLine($'Winner: {player2}');
else
Console.WriteLine('Tie!');
Console.ReadKey();
}
}
}
Potential Application for Metin2 Private Servers
Such dice games can also be added as entertainment-based mini-games within Metin2 private servers, apart from PvP systems. They can be particularly useful during in-game events or tournaments. Systems developed in C# or Python can be integrated into the game server to create dynamic mini-games. This is an excellent way to enhance the overall player experience.
Conclusion
This example of a dice game written in C# can serve as an excellent starting point for aspiring developers and can inspire ideas for creating mini-games in Metin2 private servers. Additional features can be added during the development process to further enrich the game. For instance, bonus points, special dice effects, or in-game item rewards can be implemented.
