テトリスを作っていますがうまくうごきません。
1x4のブロックただまっすぐおとしていくプログラムです。1つ目一番下の枠まで落ち、2つめは1つ目のブロックの1枠上に俳画され、3つ目が俳画されなくなって動かなくなります。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Linq;
using System.Collections;
class Sample1 : Form
{
private static Image WK;
private static GroupBox gb; private static int i, p1, p2, p3, p4, LEVEL, ICHI, p5, p6, p7, p8, p9, p10,p11,p12,p13,p14, saikoro, WUI, WIU, UU, WW; private int WWW; private static int getout = 1; PictureBox[] lbx = new PictureBox[5]; private static int UI; private static int IU; private static int[] yoko; private static Image[] fm; private static int[] tate; private static int[][] GPS; public static void Main() { Application.Run(new Sample1()); } public Sample1() { // MessageBox.Show("start"); //通常設定 this.Text = "サンプル"; this.DoubleBuffered = true; this.Width = 800; this.Height = 800; // PictureBox WAK = new PictureBox(); WAKU W = new WAKU();WAK.Image = W.GetImage();WK = WAK.Image; saikoro = 1; LEVEL = 100; ICHI = 200; //MessageBox.Show("set timer"); Timer tm = new Timer(); tm.Interval = LEVEL; tm.Start(); tate = new int[getout + 21]; yoko = new int[getout + 21]; GPS=new int[12][]; for(p9=0;p9<=11;p9++){ GPS[p9] = new int[18]; } PictureBox[]im = new PictureBox[getout + 21]; //MessageBox.Show("newimage"); fm = new Image[getout + 21]; for (p3 = -1; p3 <= 20; p3++) { im[getout + p3] = new PictureBox(); } for (p6 = -1; p6 <= 20; p6++) { switch (saikoro) { case 1: im[getout + p6].Image = Image.FromFile("C:\\Users\\\\Pictures\\TETRIS\\bar.jpg"); break; case 2: im[getout + p6].Image = Image.FromFile("C:\\Users\\\\Pictures\\TETRIS//.bar.jpg"); break; default: break; } } for (p2 = -1; p2 <= 20; p2++) { fm[getout+ p2] = im[getout + p2].Image; } gb = new GroupBox(); gb.Text = "GPS"; gb.Parent = this; this.Paint += new PaintEventHandler(fm_Paint); tm.Tick += new EventHandler(tm_Tick); this.KeyDown += new KeyEventHandler(fm_KeyDown); } public void fm_KeyDown(Object sender, KeyEventArgs e) { if (IU <= 5) { if (e.KeyCode == Keys.Right) { IU++; yoko[getout] += 33; } } if (IU >= 1) { if (e.KeyCode == Keys.Left) { IU--; yoko[getout] -= 33; } } } public void tm_Tick(Object sender, EventArgs e) { tate[getout] += 28; this.Invalidate(); if (UI <= 15) { UI++; } } //MessageBox.Show("eee"); public void fm_Paint(Object sender, PaintEventArgs e) { //MessageBox.Show("aaa"); Graphics g = e.Graphics; g.DrawImage(WK, ICHI, 0, WK.Width + 265, WK.Height + 300); for (i = 1; i <= getout ; i++) { g.DrawImage(fm[i], ICHI + 40+yoko[i], tate[i], fm[i].Width + 60, fm[i].Height + 9); } GPS[IU][UI] = 1; GPS[IU + 1][UI] = 1; GPS[IU + 2][UI] = 1; GPS[IU + 3][UI] = 1; if (UI > 0) { GPS[IU][UI - 1] = -1; GPS[IU + 1][UI - 1] = -1; GPS[IU + 2][UI - 1] = -1; GPS[IU + 3][UI - 1] = -1; } if (UI <= 14) { for (p7 = 0; p7 < 10; p7++) { for (p8 = 0; p8 < 17; p8++) { UU = GPS[p7][p8] + GPS[p7][p8 + 1]; if (UU == 2) { WW = 1; } } } } if (WW == 1 || UI >= 16) { getout++; UI = 0; IU = 0; WW = 0; } PictureBox[] im = new PictureBox[getout + 21]; fm = new Image[getout + 21]; for (p4 = -1; p4 <= 20; p4++) { im[getout + p4] = new PictureBox(); } for (p1 = -1; p1 <= 20; p1++) { switch (saikoro) { case 1: im[getout + p1].Image = Image.FromFile("C:\\Users\\\\Pictures\\TETRIS\\bar.jpg"); break; case 2: im[getout + p1].Image = Image.FromFile("C:\\Users\\\\Pictures\\TETRIS\\squre.jpg"); break; default: break; } } for (p5= -1; p5 <= 20; p5++) { fm[getout + p5] = im[getout + p5].Image; } }
}
class WAKU
{
private Image WK;
public WAKU()
{
WK = Image.FromFile("C:\Users\\Pictures\TETRIS\WAKU.png");
} public Image GetImage() { return WK; }
}
こちらの質問が他のユーザから「問題・課題が含まれていない質問」という指摘を受けました
teratailでは、漠然とした興味から票を募るような質問や、意見の主張をすることを目的とした投稿は推奨していません。
「編集」ボタンから編集を行い、質問の意図や解決したい課題を明確に記述していただくと回答が得られやすくなります。
こちらの質問が他のユーザから「問題・課題が含まれていない質問」という指摘を受けました
teratailでは、漠然とした興味から票を募るような質問や、意見の主張をすることを目的とした投稿は推奨していません。
「編集」ボタンから編集を行い、質問の意図や解決したい課題を明確に記述していただくと回答が得られやすくなります。
こちらの質問が他のユーザから「やってほしいことだけを記載した丸投げの質問」という指摘を受けました
「質問を編集する」ボタンから編集を行い、調査したこと・試したことを記入していただくと、回答が得られやすくなります。
こちらの質問が他のユーザから「問題・課題が含まれていない質問」という指摘を受けました
teratailでは、漠然とした興味から票を募るような質問や、意見の主張をすることを目的とした投稿は推奨していません。
「編集」ボタンから編集を行い、質問の意図や解決したい課題を明確に記述していただくと回答が得られやすくなります。
回答1件
あなたの回答
tips
プレビュー