using System.Numerics;
using System.Reflection;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace gorilla
{
public partial class Form1 : Form
{
private Random r = new Random();
private Rectangle rRectangle;
List Buildings = new List();
List Players = new List();
List PlayerBases = new List();
float g = 9.8f;
public Form1()
{
InitializeComponent();
this.Paint += Form1_Paint;
this.ClientSize = new Size(1920, 1080);
CreateBuildings();
CreateBuildings2();
CreateBuildings3();
Player1();
Player2();
Player1Base();
Player2Base();
}
int totalwidth = 0;
public void GenerateRRectangle()
{
int minHeight = 500;
int maxHeight = 800;
int width = 216;
int rHeight = r.Next(minHeight, maxHeight + 1);
int x = (0 + totalwidth);
int y = (1080 - rHeight);
Rectangle rRectangle = new Rectangle(x, y, width, rHeight);
totalwidth = (totalwidth + 216);
Buildings.Add(rRectangle);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Random rgb1 = new Random();
Random rgb2 = new Random();
Random rgb3 = new Random();
foreach (Rectangle r in Buildings)
{
var solidBrush = new SolidBrush(Color.FromArgb(rgb1.Next(0, 45), rgb2.Next(0, 25), rgb3.Next(0, 40)));
using SolidBrush brush = solidBrush;
e.Graphics.FillRectangle(brush, r);
}
foreach (Rectangle r in Players)
{
var solidBrush = new SolidBrush(Color.Orange);
using SolidBrush brush = solidBrush;
e.Graphics.FillRectangle(brush, r);
}
foreach (Rectangle r in PlayerBases)
{
var solidBrush = new SolidBrush(Color.Black);
using SolidBrush brush = solidBrush;
e.Graphics.FillRectangle(brush, r);
}
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
GenerateRRectangle();
this.Invalidate();
}
private void GameTimer_Tick(object sender, EventArgs e)
{
}
private void CreateBuildings()
{
while (totalwidth < 216)
{
GenerateRRectangle();
}
totalwidth = 432;
}
private void CreateBuildings2()
{
while (totalwidth < 1512)
{
GenerateRRectangle();
}
totalwidth = 1727;
}
private void CreateBuildings3()
{
while (totalwidth < 1728)
{
GenerateRRectangle();
}
}
public void Player1()
{
int playerHeight = 100;
int playerWidth = 100;
int x = 280;
int y = 400;
Rectangle Player1Rectangle = new Rectangle(x, y, playerWidth, playerHeight);
Players.Add(Player1Rectangle);
}
public void Player2()
{
int playerHeight = 100;
int playerWidth = 100;
int x = 1580;
int y = 400;
Rectangle player2 = new Rectangle(x, y, playerWidth, playerHeight);
Players.Add(player2);
}
public void Player1Base()
{
int baseHeight = 750;
int baseWidth = 216;
int x = 216;
int y = 500;
Rectangle player1base = new Rectangle(x, y, baseWidth, baseHeight);
PlayerBases.Add(player1base);
}
public void Player2Base()
{
int baseHeight = 750;
int baseWidth = 216;
int x = 1512;
int y = 500;
Rectangle player2base = new Rectangle(x, y, baseWidth, baseHeight);
PlayerBases.Add(player2base);
}
public void Throwing()
{
}
}
}
Пытаюсь сделать функцию Throwing(), даже не знаю, с чего начать XD
Особо ничего не пробовал тем не менее, поскольку я понятия не имею, с чего начать, и мои знания этого языка действительно базовые, поскольку я впервые попробовал его вчера.
Если есть какие-либо мастера C# кто может помочь мне с моей игрой, при необходимости я могу добавить дополнительные файлы/информацию! https://gist.github.com/caffo/1326838 — это код QBasic Gorilla п>
[code]using System.Numerics; using System.Reflection; using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace gorilla { public partial class Form1 : Form {
private Random r = new Random(); private Rectangle rRectangle; List Buildings = new List(); List Players = new List(); List PlayerBases = new List(); float g = 9.8f;
public Form1() { InitializeComponent(); this.Paint += Form1_Paint; this.ClientSize = new Size(1920, 1080); CreateBuildings(); CreateBuildings2(); CreateBuildings3(); Player1(); Player2(); Player1Base(); Player2Base(); }
int totalwidth = 0; public void GenerateRRectangle() { int minHeight = 500; int maxHeight = 800; int width = 216; int rHeight = r.Next(minHeight, maxHeight + 1);
int x = (0 + totalwidth); int y = (1080 - rHeight);
Rectangle rRectangle = new Rectangle(x, y, width, rHeight); totalwidth = (totalwidth + 216); Buildings.Add(rRectangle);
}
private void Form1_Paint(object sender, PaintEventArgs e) { Random rgb1 = new Random(); Random rgb2 = new Random(); Random rgb3 = new Random(); foreach (Rectangle r in Buildings) { var solidBrush = new SolidBrush(Color.FromArgb(rgb1.Next(0, 45), rgb2.Next(0, 25), rgb3.Next(0, 40))); using SolidBrush brush = solidBrush; e.Graphics.FillRectangle(brush, r); } foreach (Rectangle r in Players) { var solidBrush = new SolidBrush(Color.Orange); using SolidBrush brush = solidBrush; e.Graphics.FillRectangle(brush, r); } foreach (Rectangle r in PlayerBases) { var solidBrush = new SolidBrush(Color.Black); using SolidBrush brush = solidBrush; e.Graphics.FillRectangle(brush, r); } }
public void Player1() { int playerHeight = 100; int playerWidth = 100;
int x = 280; int y = 400;
Rectangle Player1Rectangle = new Rectangle(x, y, playerWidth, playerHeight); Players.Add(Player1Rectangle); }
public void Player2() { int playerHeight = 100; int playerWidth = 100;
int x = 1580; int y = 400;
Rectangle player2 = new Rectangle(x, y, playerWidth, playerHeight); Players.Add(player2); }
public void Player1Base() { int baseHeight = 750; int baseWidth = 216;
int x = 216; int y = 500;
Rectangle player1base = new Rectangle(x, y, baseWidth, baseHeight); PlayerBases.Add(player1base); }
public void Player2Base() { int baseHeight = 750; int baseWidth = 216;
int x = 1512; int y = 500;
Rectangle player2base = new Rectangle(x, y, baseWidth, baseHeight); PlayerBases.Add(player2base); }
public void Throwing() {
} } } [/code] Пытаюсь сделать функцию Throwing(), даже не знаю, с чего начать XD Особо ничего не пробовал тем не менее, поскольку я понятия не имею, с чего начать, и мои знания этого языка действительно базовые, поскольку я впервые попробовал его вчера. Если есть какие-либо мастера C# кто может помочь мне с моей игрой, при необходимости я могу добавить дополнительные файлы/информацию! https://gist.github.com/caffo/1326838 — это код QBasic Gorilla п>