一秒たつごとにブロックが45下に落ちるプログラムを作っていますが、
何秒たっても変化がありません。
説明:
im=ゲームの枠
fm[1]=2x2の四角
fm[2]=2x2の四角
fm[3=2x2の四角
fm[4]=2x2の四角
fm[5]=2x2の四角
fm[6]=2x2の四角
fm[7]=2x2の四角
UI=tm.Start();から何秒たったか、(16秒たつごとに0に戻る)
getout=イベントごとに変化させていくつもりですが、今は特に意味はありません。
C#
1コード 2using System.Windows.Forms; 3using System.Drawing; 4using System; 5using System.Collections.Generic; 6 7class Sample1 :Form 8{ 9 private static Image im; 10 private static int i, getout, IU, UI, big, side, hichi; 11 private static int[] saikoro = new int[80]; 12 private static Image[] fm = new Image[8]; 13 private static Label lb = new Label(), f_hichi = new Label(), f_big = new Label(); 14 [STAThread] 15 public static void Main(){ 16 17 Application.Run(new Sample1()); 18 } 19 20public Sample1(){ 21 this.Text="サンプル"; 22 this.Width=800; 23 this.Height = 800; 24 hichi = 0; 25 26 getout = 1; 27 System.Random r = new System.Random(7); 28 saikoro[getout] = r.Next(1, 7); 29 lb = new Label(); 30 lb.Top = 500; 31 lb.Width = 20; 32 lb.Height = 10; 33 lb.Left=0; 34 f_hichi.Top = 500; 35 f_hichi.Width = 20; 36 f_hichi.Height = 10; 37 f_hichi.Left = 29; 38 f_big.Top = 600; 39 f_big.Width = 100; 40 f_big.Height = 10; 41 f_big.Left = 0; 42 f_big.Parent = this; 43 f_hichi.Parent = this; 44 lb.Parent = this; 45 46 im = Image.FromFile(":\\Users\\name\\Pictures\\TETRIS\\WAKU.png"); 47 fm[1] = Image.FromFile(":\\Users\\name\\Pictures\\TETRIS\\barcpp.jpg"); 48 fm[2] = Image.FromFile(":\\Users\\name\\Pictures\\TETRIS\\animalcpp.jpg"); 49 fm[3] = Image.FromFile(":\\Users\\name\\Pictures\\TETRIS\\jcpp.jpg"); 50 fm[4] = Image.FromFile(":\\Users\\name\\Pictures\\TETRIS\\KEYcpp.jpg"); 51 fm[5] = Image.FromFile(":\\Users\\name\\Pictures\\TETRIS\\PEEKcpp.jpg"); 52 fm[6] = Image.FromFile(":\\Users\\name\\Pictures\\TETRIS\\squrecpp.jpg"); 53 fm[7] = Image.FromFile(":\\Users\\name\\Pictures\\TETRIS\\トcpp.jpg"); 54 Timer tm=new Timer(); 55 tm.Interval = 1000; 56 tm.Start(); 57 58 tm.Tick += new EventHandler(tm_Tick); 59 this.Paint += new PaintEventHandler(fm_Paint); 60 61} 62public void fm_Paint(Object sender, PaintEventArgs e) 63{ 64 Graphics g = e.Graphics; 65 66 g.DrawImage(im, 0, 0, im.Width * 2 + 100, im.Height * 2); 67 g.DrawImage(fm[saikoro[getout]], 45, 4+UI*45, fm[saikoro[getout]].Width + 10, fm[saikoro[getout]].Height + 10); 68} 69 70public void tm_Tick(Object sender,EventArgs e) 71{ 72 UI++; 73 74 if (UI == 17) 75 { 76 UI = 0; 77 } 78 79 80 81 82 lb.Text = UI.ToString(); 83 84} 85}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。