こんにちは、ビジュアル スタジオで C# を使用してこのトップ ダウン シューティング ゲームを作成していますが、何らかの理由でピクチャ ボックスが境界線からはみ出すのを止めることができません。現在、ピクチャ ボックスを右下に配置すると、ハンドコーナーでは機能しますが、画像ボックスを中央に配置すると機能しません。これが私のコードです:
private void Level_1_of__desolor_KeyDown(object sender, KeyEventArgs e)
{
int xpos = CharacterMain.Location.X;
int ypos = CharacterMain.Location.Y;
if (e.KeyCode == Keys.A)
{
this.CharacterMain.Load(@"../Graphics\Energy L.png");
}
else if (e.KeyCode == Keys.D)
{
this.CharacterMain.Load(@"../Graphics\Energy R.png");
CharacterMain.Left += speed;
}
else if (e.KeyCode == Keys.W)
{
this.CharacterMain.Load(@"../Graphics\Energy F.png");
CharacterMain.Top -= 10;
}
else if (e.KeyCode == Keys.S)
{
this.CharacterMain.Load(@"../Graphics\Energy B.png");
CharacterMain.Top += 10;
}
if (xpos > 12 && xpos < 1096 && ypos == 523)
{
if (ypos == 523)
{
CharacterMain.Top -= 10;
}
}
if (CharacterMain.Location.Y < 523 && CharacterMain.Location.Y > 12)
{
if (CharacterMain.Location.X == 12)
{
CharacterMain.Left += 10;
}
}
if (CharacterMain.Location.Y < 523 && CharacterMain.Location.Y > 12)
{
if (CharacterMain.Location.X == 12)
{
CharacterMain.Left += 10;
}
}
if (CharacterMain.Location.X > 12 && CharacterMain.Location.X < 1102)
{
if (CharacterMain.Location.Y == 12)
{
CharacterMain.Top += 10;
}
}
}