using System; using System.IO; using System.Text; using System.Threading; using System.Windows.Forms; using System.Drawing; using System.Resources; using System.Drawing.Drawing2D; using System.Drawing.Text; using System.Reflection; class A:Form{ int horizon=-100; int M=4000; int N=1000; double w=0; double h=0; Point to3(double x,double y){ x=x-w;y=y-h; return new Point((int)(x*N/y+this.Width/2),(int)(M/y+horizon)); } public void init(){ SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); } void drawframe(double x0,double y0,double x1,double y1,Graphics g){ Pen b=new Pen(Color.FromArgb(0,0,100)); Point p0,p1; if(y0-h>2 & y1-h>2){ p0=to3(x0,y0); p1=to3(x1,y1); g.DrawLine(b,p0,p1); } } override protected void OnPaint(PaintEventArgs e){ Graphics g=e.Graphics; int i,j; for(i=0;i<30;i++){ for(j=0;j<30;j++){ drawrect(i,j,g); drawframe(i,j,i,j+1,g); drawframe(i,j,i+1,j,g); drawframe(i+1,j,i+1,j+1,g); drawframe(i,j+1,i+1,j+1,g); } } } void drawrect(double x,double y,Graphics g){ Point[] pt={to3(x,y), to3(x+1,y), to3(x+1,y+1), to3(x,y+1)}; if(y-h>2) g.FillPolygon(new SolidBrush(Color.FromArgb(0,0,200+(int)(x+y)%2*55)),pt); } override sealed protected void OnKeyDown(KeyEventArgs e){ if(e.KeyCode==Keys.Right){ if(w<30)w+=1; } else if(e.KeyCode==Keys.Left){ if(w>0)w-=1; } else if(e.KeyCode==Keys.Up)h+=1; else if(e.KeyCode==Keys.Down)h-=1; else if(e.KeyCode==Keys.K)horizon+=10; else if(e.KeyCode==Keys.J)horizon-=10; else if(e.KeyCode==Keys.T)N+=5; else if(e.KeyCode==Keys.Y)N-=5; else if(e.KeyCode==Keys.Q)M+=20; else if(e.KeyCode==Keys.W)M-=20; else if(e.KeyCode==Keys.Enter)Application.Exit(); else if(e.KeyCode==Keys.Escape)Application.Exit(); Invalidate(); } } class B{ public static void Main(){ A a=new A(); a.Text="Hello"; a.BackColor=Color.FromArgb(30,240,240); a.Width=1000; a.Height=800; a.FormBorderStyle=FormBorderStyle.FixedSingle; a.init(); Application.Run(a); } }