private void btnNewGame_Click(object sender, EventArgs e) { timer1.Stop(); tg = new tetrixGame(); tg.mainScreen = this; timer1.Start(); }
public Boolean okDown(tetrixGame iCalled) { Boolean retMe = true; for (int i = 0; i < 4; i++) { if (blocks[i].Y >= 19) { return(false); } } Boolean done = false; for (int i = 0; i < 4; i++) { Point block = iCalled.active.piece.blocks[i].getLoc(); if (block.X >= 0 && block.X <= 9 && block.Y >= 0 && block.Y <= 19 && iCalled.bg.matrix[block.X, block.Y + 1] != '0') { done = true; } } if (done) { return(false); } return(retMe); }
private void WINbtn_Click(object sender, EventArgs e) { WINbtn.Visible = false; timer1.Stop(); tg = new tetrixGame(); tg.mainScreen = this; timer1.Start(); }
public override void rotate(tetrixGame iCalled) { int tmp = blocks[0].num; blocks[0].num = blocks[1].num; blocks[1].num = blocks[2].num; blocks[2].num = blocks[3].num; blocks[3].num = tmp; }
private void Form1_Load(object sender, EventArgs e) { paused = false; score = 0; help = 0; win = new Bitmap("W.png"); lose = new Bitmap("L.png"); tg = new tetrixGame(); tg.mainScreen = this; pics = new Bitmap[13]; pics[1] = new Bitmap("numRes\\num2.png"); pics[2] = new Bitmap("numRes\\num4.png"); pics[3] = new Bitmap("numRes\\num8.png"); pics[4] = new Bitmap("numRes\\num16.png"); pics[5] = new Bitmap("numRes\\num32.png"); pics[6] = new Bitmap("numRes\\num64.png"); pics[7] = new Bitmap("numRes\\num128.png"); pics[8] = new Bitmap("numRes\\num256.png"); pics[9] = new Bitmap("numRes\\num512.png"); pics[10] = new Bitmap("numRes\\num1024.png"); pics[11] = new Bitmap("numRes\\num2048.png"); //pics[12] = new Bitmap("numRes\\num4096.png"); web = new PictureBox[10, 20]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 20; j++) { web[i, j] = new PictureBox(); tetrixPanel.Controls.Add(web[i, j]); web[i, j].Size = new Size(30, 30); web[i, j].Location = new Point(i * 30, j * 30); web[i, j].Visible = false; } } ap = new PictureBox[4]; for (int i = 0; i < 4; i++) { ap[i] = new PictureBox(); tetrixPanel.Controls.Add(ap[i]); ap[i].Size = new Size(30, 30); ap[i].Location = new Point(-1, -1); ap[i].Visible = false; } }
public Boolean okRight(tetrixGame iCalled) { Boolean retMe = true; for (int i = 0; i < 4; i++) { if (blocks[i].X > 9) { return(false); } } return(retMe); }
public Boolean check(tetrixGame iCalled) { for (int i = 0; i < 4; i++) { if (blocks[i].X > 9 || blocks[i].Y > 19 || blocks[i].X < 0 || blocks[i].Y < 0) { return(false); } if (blocks[i].Y >= 0 && iCalled.bg.matrix[blocks[i].X, blocks[i].Y] != '0') { return(false); } } return(true); }
public void md(tetrixGame iCalled) { Point[] oldLoc = new Point[4]; oldLoc[0] = new Point(blocks[0].X, blocks[0].Y); oldLoc[1] = new Point(blocks[1].X, blocks[1].Y); oldLoc[2] = new Point(blocks[2].X, blocks[2].Y); oldLoc[3] = new Point(blocks[3].X, blocks[3].Y); for (int i = 0; i < 4; i++) { blocks[i].Y++; } if (!this.check(iCalled)) { blocks[0].setLoc(oldLoc[0]); blocks[1].setLoc(oldLoc[1]); blocks[2].setLoc(oldLoc[2]); blocks[3].setLoc(oldLoc[3]); } }
public override void rotate(tetrixGame iCalled) { Point[] oldLoc = new Point[4]; oldLoc[0] = new Point(blocks[0].X, blocks[0].Y); oldLoc[1] = new Point(blocks[1].X, blocks[1].Y); oldLoc[2] = new Point(blocks[2].X, blocks[2].Y); oldLoc[3] = new Point(blocks[3].X, blocks[3].Y); if (state == 0) { blocks[0].X += 2; blocks[0].Y -= 2; blocks[1].X++; blocks[1].Y--; blocks[3].X--; blocks[3].Y++; state = 1; if (!this.okLeft(iCalled)) { this.mr(iCalled); } if (!this.okRight(iCalled)) { this.ml(iCalled); } if (!this.okDown(iCalled)) { this.md(iCalled); } if (!this.check(iCalled)) { blocks[0].setLoc(oldLoc[0]); blocks[1].setLoc(oldLoc[1]); blocks[2].setLoc(oldLoc[2]); blocks[3].setLoc(oldLoc[3]); state = 0; } return; } if (state == 1) { blocks[0].X += 2; blocks[0].Y += 2; blocks[1].X++; blocks[1].Y++; blocks[3].X--; blocks[3].Y--; state = 2; if (!this.okLeft(iCalled)) { this.mr(iCalled); } if (!this.okRight(iCalled)) { this.ml(iCalled); } if (!this.okDown(iCalled)) { this.md(iCalled); } if (!this.check(iCalled)) { blocks[0].setLoc(oldLoc[0]); blocks[1].setLoc(oldLoc[1]); blocks[2].setLoc(oldLoc[2]); blocks[3].setLoc(oldLoc[3]); state = 1; } return; } if (state == 2) { blocks[0].X -= 2; blocks[0].Y += 2; blocks[1].X--; blocks[1].Y++; blocks[3].X++; blocks[3].Y--; state = 3; if (!this.okLeft(iCalled)) { this.mr(iCalled); } if (!this.okRight(iCalled)) { this.ml(iCalled); } if (!this.okDown(iCalled)) { this.md(iCalled); } if (!this.check(iCalled)) { blocks[0].setLoc(oldLoc[0]); blocks[1].setLoc(oldLoc[1]); blocks[2].setLoc(oldLoc[2]); blocks[3].setLoc(oldLoc[3]); state = 2; } return; } if (state == 3) { blocks[0].X -= 2; blocks[0].Y -= 2; blocks[1].X--; blocks[1].Y--; blocks[3].X++; blocks[3].Y++; state = 0; if (!this.okLeft(iCalled)) { this.mr(iCalled); } if (!this.okRight(iCalled)) { this.ml(iCalled); } if (!this.okDown(iCalled)) { this.md(iCalled); } if (!this.check(iCalled)) { blocks[0].setLoc(oldLoc[0]); blocks[1].setLoc(oldLoc[1]); blocks[2].setLoc(oldLoc[2]); blocks[3].setLoc(oldLoc[3]); state = 3; } return; } }
public abstract void rotate(tetrixGame iCalled);