本学期的项目是一款游戏,但是您将使用Windows Form而不是unity ...我实际上制作了一个游戏,但是播放器仍在继续移动...我想要的是当我按下播放器时只会移动不连续的1个图块...顺便说一句,我们分配做的游戏是Bomber man,如果有人有可以与您共享的资源,我希望您能与我共享...这是我已使用:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StudyControl
{
public partial class FormView : Form
{
enum Position
{
Left, Right, Up, Down
}
private int _x;
private int _y;
private Position _objPosition;
public FormView()
{
InitializeComponent();
_x = 50;
_y = 50;
_objPosition = Position.Down;
}
private void FormView_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(new Bitmap("Character.png"), _x, _y, 100, 100);
}
private void TmrMoving_Tick(object sender, EventArgs e)
{
Invalidate();
}
private void FormView_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Right)
{
_x += 100;
_objPosition = Position.Right;
} else if (e.KeyCode == Keys.Left)
{
_x -= 100;
_objPosition = Position.Left;
} else if (e.KeyCode == Keys.Up){
_y -= 100;
_objPosition = Position.Up;
} else if (e.KeyCode == Keys.Down){
_y += 100;
_objPosition = Position.Down;
}
}
}
}