Exemplo 001 / GDI C#
/*
* Created by SharpDevelop.
* User: Luigi
* Date: 03/12/2016
* Time: 07:03
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;
namespace gdi{
public partial class MainForm : Form{
System.Drawing.Graphics grafico;
int x = 100, y = 100;
public MainForm(){
InitializeComponent();
grafico = CreateGraphics();
}
void MainFormKeyDown(object sender, KeyEventArgs e){
grafico.Clear(Color.White);
if(e.KeyCode == Keys.Up){
y--;
}
if(e.KeyCode == Keys.Down){
y++;
}
if(e.KeyCode == Keys.Left){
x--;
}
if(e.KeyCode == Keys.Right){
x++;
}
grafico.FillRectangle(Brushes.Blue, new RectangleF(x, y, 32, 32));
}
}
}
Nenhum comentário:
Postar um comentário