public partial class Form1 : Form
{
PictureBox[] ObjectsLevel1;
Rectangle[] Objects;
Rectangle PlayerRectangle;
public Form1()
{
InitializeComponent();
ObjectsLevel1 = new PictureBox[]
{
pictureBox1,
pictureBox2,
pictureBox3,
pictureBox4,
pictureBox5,
pictureBox6,
pictureBox7,
Roof,
Paul,
pictureBox8,
pictureBox9
};
Objects = new Rectangle[ObjectsLevel1.Length];
for (int i = 0; i < ObjectsLevel1.Length; i++)
{
Objects[i] = ObjectsLevel1[i].DisplayRectangle;
Objects[i].Location = ObjectsLevel1[i].Location;
}
PlayerRectangle = Player.DisplayRectangle;
}
bool isGround = false;
double MoveX = 0, MoveY = 0, gravitySpeed = 0;
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.D)
{
MoveX = 5;
}
if (e.KeyCode == Keys.A)
{
MoveX = -5;
}
if (e.KeyCode == Keys.W && isGround == true)
{
MoveY = 7;
isGround = false;
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.D && MoveX > 0)
{
MoveX = 0;
}
if (e.KeyCode == Keys.A && MoveX < 0)
{
MoveX = 0;
}
}
private void PlayerController_Tick(object sender, EventArgs e)
{
if (MoveX != 0)
{
Player.Left += Convert.ToInt32(MoveX);
PlayerRectangle.Location = Player.Location;
for (int i = 0; i < Objects.Length; i++)
{
if (PlayerRectangle.IntersectsWith(Objects[i]))
{
Player.Left -= Convert.ToInt32(MoveX);
}
}
}
MoveY -= 0.1;
Player.Top -= Convert.ToInt32(MoveY);
PlayerRectangle.Location = Player.Location;
for (int i = 0; i < Objects.Length; i++)
{
if (PlayerRectangle.IntersectsWith(Objects[i]) || Player.Location.Y == 790)
{
if (MoveY > 0)
{
Player.Top = Objects[i].Top + Objects[i].Height;
}
else
{
Player.Top = Objects[i].Top - Player.Height;
isGround = true;
}
gravitySpeed = 0;
MoveY = 0;
}
}
label1.Text = "X = " + Player.Location.X + " Y = " + Player.Location.Y + "\nMoveY = " + MoveY + "\nisGround = " + isGround;
}
}
Ну вы предоставили код с ответом на ваш вопрос, что не так?
import discord
client = discord.Client()
@client.event
import discord
client = RoleReactClient(intents=intents)
@client.event