Advertisement
Wessel

Untitled

Apr 26th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1.  public void Tick()
  2.         {
  3.             a = a++;
  4.             screen.Clear(0);
  5.             //top-left
  6.             float x1 = -1, y1 = 1.0f;
  7.             float rx1 = (float)(x1 * Math.Cos(a + 180) - y1 * Math.Sin(a + 180));
  8.             float ry1 = (float)(x1 * Math.Sin(a + 180) + y1 * Math.Cos(a+ 180));
  9.  
  10.             //bot left
  11.             float x2 = -1, y2 = -1;
  12.             float rx2 = (float)(x2 * Math.Cos(a + 270) - y2 * Math.Sin(a + 270));
  13.             float ry2 = (float)(x2 * Math.Sin(a + 270) + y2 * Math.Cos(a + 270));
  14.  
  15.             //bot right
  16.             float x3 = 1.0f, y3 = -1;
  17.             float rx3 = (float)(x3 * Math.Cos(a) - y3 * Math.Sin(a));
  18.             float ry3 = (float)(x3 * Math.Sin(a) + y3 * Math.Cos(a));
  19.  
  20.             //top right
  21.             float x4 = 1.0f, y4 = 1.0f;
  22.             float rx4 = (float)(x4 * Math.Cos(a + 90) - y4 * Math.Sin(a + 90));
  23.             float ry4 = (float)(x4 * Math.Sin(a + 90) + y4 * Math.Cos(a + 90));
  24.  
  25.             screen.Line(TX(x1), TY(y1), TX(x2), TY(y2), 0x0000ff);
  26.             screen.Line(TX(x2), TY(y2), TX(x3), TY(x3), 0x00ff00);
  27.             screen.Line(TX(x3), TY(y3), TX(x4), TY(x4), 0xff0000);
  28.             screen.Line(TX(x4), TY(y4), TX(x1), TY(x1), 0xffffff);
  29.  
  30.             /*
  31.             screen.Line(220, 100, 420, 100, 0x0000ff);
  32.             screen.Line(220, 100, 220, 300, 0x00ff00);
  33.             screen.Line(420, 100, 420, 300, 0xff0000);
  34.             screen.Line(220, 300, 420, 300, 0xffffff);
  35.             */
  36.  
  37.             screen.Print("hello world", 2, 2, 0xffffff);
  38.             }
  39.  
  40.         public static int CreateColor(int red, int green, int blue)
  41.          {
  42.             return (red << 16) + (green << 8) + blue;
  43.         }
  44.  
  45.         public int TY(float y) {
  46.             y = y * -1;
  47.             y = y + 2;
  48.             y = (400 / 4) * y;
  49.             return (int)y;
  50.         }
  51.  
  52.         public int TX(float x){
  53.             x = x + 2;
  54.             x = (640 / 4 )* x / 1.6f;
  55.             return (int)x;
  56.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement