fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. int x = 0;
  15.  
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23. //ダブルバッファリング
  24. this.SetStyle(ControlStyles.DoubleBuffer, true);
  25. this.SetStyle(ControlStyles.UserPaint, true);
  26. this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  27. }
  28.  
  29. protected override void OnPaint(PaintEventArgs e)
  30. {
  31. base.OnPaint(e);
  32.  
  33. //四角形描画
  34. e.Graphics.FillRectangle(Brushes.Red, x, 50, 100, 100);
  35.  
  36. }
  37.  
  38. private void Form1_Shown(object sender, EventArgs e)
  39. {
  40. //ゲームループ
  41. System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
  42. sw.Start();
  43. double nextframe = (double)sw.ElapsedMilliseconds;
  44. float wait = 1000f / 60f;
  45. while (this.Created)
  46. {
  47.  
  48. if ((double)sw.ElapsedMilliseconds >= nextframe)
  49. {
  50.  
  51. //計算処理
  52. x++;
  53.  
  54. if ((double)sw.ElapsedMilliseconds < nextframe + wait)
  55. {
  56. //描画処理
  57. this.Invalidate();
  58. }
  59.  
  60. nextframe += wait;
  61. }
  62.  
  63. Application.DoEvents();
  64. }
  65. }
  66. }
  67. }
  68.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(4,14): error CS0234: The type or namespace name `Data' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(5,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(8,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 3 error(s), 0 warnings
stdout
Standard output is empty