Игровая система "Тетрис"

Курсовой проект - Компьютеры, программирование

Другие курсовые по предмету Компьютеры, программирование

oord));

state = 3;

remove();

copy(coord, tcoord);

}(state == 3)

{

tmoveCoord(3, "Left");

tmoveCoord(3, "Down", 2);

tmoveCoord(2, "Left");

tmoveCoord(2, "Down", 2);(!checkCoord(tcoord));

state = 2;

remove();

copy(coord, tcoord);

}(state == 2)

{

tmoveCoord(0, "Up");

tmoveCoord(1, "Up");

tmoveCoord(0, "Left", 2);

tmoveCoord(1, "Left", 2);

tmoveCoord(2, "Left");

tmoveCoord(3, "Right");(!checkCoord(tcoord));

state = 1;

remove();

copy(coord, tcoord);

};5:(state == 1)

{

tmoveCoord(2, "Left");

tmoveCoord(3, "Right");

tmoveCoord(1, "Left", 2);

tmoveCoord(1, "Down");

tmoveCoord(0, "Left", 2);

tmoveCoord(0, "Down");(!checkCoord(tcoord));

state = 4;

remove();

copy(coord, tcoord);

}(state == 4)

{

tmoveCoord(2, "Up", 2);

tmoveCoord(3, "Up", 2);

tmoveCoord(3, "Left", 2);(!checkCoord(tcoord));

state = 3;

remove();

copy(coord, tcoord);

}(state == 3)

{

tmoveCoord(0, "Right", 2);

tmoveCoord(0, "Up");

tmoveCoord(1, "Right", 2);

tmoveCoord(1, "Up");(!checkCoord(tcoord));

state = 2;

remove();

copy(coord, tcoord);

}(state == 2)

tmoveCoord(2, "Down", 2);

tmoveCoord(2, "Right");

tmoveCoord(3, "Down", 2);

tmoveCoord(3, "Right");(!checkCoord(tcoord));

state = 1;

remove();

copy(coord, tcoord);;

}();.Inv();

}remove()

{x = 0;y = 0;(int i = 0; i < 4; i++)

{

x = coord[i, 0];

y = coord[i, 1];.table[x, y] = false;

}

}clear()

{(int i = 0; i < 4; i++)

{

coord[i, 0] = coord[i, 1] = 0;

}

lastShape = count = nextShape = 0;

}toTable()

{(int i = 0; i < 4; i++).table[coord[i, 0], coord[i, 1]] = true;

 

}RandomShape()

{rand = newRandom();type = 0;

{

type = rand.Next(1, 7);(type == lastShape)

{

count++;(count < 4);

};

} while (true);type;

}createShape(int type)

{(type)

{1: //квадрат

setCoord(4, 0, 4, 1, 5, 0, 5, 1); break;2: //палка

setCoord(5, 0, 5, 1, 5, 2, 5, 3); break;3: //_|_

setCoord(5, 0, 5, 1, 4, 1, 6, 1); break;4: //|_

setCoord(4, 0, 4, 1, 4, 2, 5, 2); break;5: //_|

setCoord(5, 0, 5, 1, 5, 2, 4, 2); break;6: //левая

setCoord(5, 0, 5, 1, 4, 1, 4, 2); break;7: //правая

setCoord(4, 0, 4, 1, 5, 1, 5, 2); break;

}

state = 1;

lastShape = type;.Inv();

}

}

}

КлассBuild - отвечает за игровой процесс игры стройка.System;System.Collections.Generic;System.Linq;System.Text;System.Threading.Tasks;System.Windows.Forms;System.Threading;TetrixSystem

{

{Level = 0;Score = 0;mode = 1;Shapes = 0;LinesRemoved = 0;speed = 600;space = false;isPaused = false;thr = null;Start(int m)

{

ClearTable();

Level = 1;

Score = 0;

Shapes = 0;

mode = m;= newThread(newThreadStart(tableProc));

thr.Start();

}tableProc()

{.nextShape = Shape.RandomShape();(; ; )

{.createShape(Shape.nextShape);.nextShape = Shape.RandomShape();.MF.nextPaint = true;++;(mode)

{1:(Shapes % 60 == 0)

{

Level++;

speed -= 50;.MF.setLevel(Level);

};2:(Shapes % 30 == 0)

{

Level++;

speed -= 50;.MF.setLevel(Level);

};3:(Shapes % 20 == 0)

{

Level++;

speed -= 50;.MF.setLevel(Level);

};

}

{.Sleep(speed);

} while(MainWindow.Shape_.down());

space = false;(mode)

{1:

Score += 12;;2:

Score += 15;;3:

Score += 18;;

}.MF.setScoreShape(Score, Shapes);

LineRem();(int i = 0; i < 4; i++)

{(Shape.y(i) == 0)

{.MF.EndGame();;

}

}

}

}LineRem()

{f = true;y = 0;(y = 18; y != 0; y--)

{

f = true;(int x = 0; x < 10; x++)

{(MainWindow.table[x, y] != true)

f = false;

}(f == true)

{(int y_ = y; y_ != 0; y_--)

{(int x_ = 0; x_ < 10; x_++)

{.table[x_, y_] = MainWindow.table[x_, (y_ - 1)];

}

}

y++;

LinesRemoved++;

Score += 100;.MF.setRemovLines(LinesRemoved);.MF.setScoreShape(Score, Shapes);

}

}

}ClearTable()

{(int i = 0; i < 10; i++)(int j = 0; j < 19; j++).table[i, j] = false;.Inv();

}

}

}

КлассShot - отвечает за пулю выпущенную из конкретного танка в игре гоники(танки).

using System;System.Collections.Generic;System.Linq;System.Text;System.Threading.Tasks;System.Windows.Forms;System.Threading;TetrixSystem

{

{time;x = 0,

y = 0;tank;Shot(Tank t, int t_ = 250)

{

tank = t;

time = t_;

x = tank.coord[0, 0];

y = tank.coord[0, 1];

}go()

{(tank.state)

{1: y--; break;2: x--; break;3: y++; break;4: x++; break;

}(!checkCoords());temp = tank.state;(true)

{

remove();(temp)

{1:

y--;(!checkCoords());;2:

x--;(!checkCoords());;3:

y++;(!checkCoords());;4:

x++;;

}(!checkCoords());

toTable();.Inv();.Sleep(time);

}

}toTable()

{.table[x, y] = true;

}remove()

{.table[x, y] = false;

}

checkCoords()

{(y < 0)

{

y++;

remove();.Inv();;

}(y > 18)

{

y--;

remove();.Inv();;

}(x < 0)

{

x++;

remove();.Inv();;

}(x > 9)

{

x--;

remove();.Inv();;

}(MainWindow.table[x, y] == true)

{

remove();.Inv();

DestroyObj();;

};

}DestroyObj()

{(MainWindow.Tanks_.Tank_.inMe(x, y))

{.Tanks_.Tank_.wounded();;

}(MainWindow.Tanks_.Tank_1.inMe(x, y))

{.Tanks_.Tank_1.wounded();;

}

}

}

}

КлассTank - отвечает за танк в игре гоники(танки).System;System.Collections.Generic;System.Linq;System.Text;System.Threading.Tasks;System.Windows.Forms;System.Threading;TetrixSystem

{

{Tank(string p = null, bool ToTable = false, string n = "player")

{(p != null)

createTank(p);(ToTable)

toTable();

name = n;

}health = 3;score = 0;cheat = 5;name = "";[,] coord = {

{0,0}, //x,y

{0,0},

{0,0},

{0,0}

};[,] tcoord = {

{0,0}, //x,y

{0,0},

{0,0},

{0,0}

};state = 1;speedShots = 0;setCoord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)

{

coord[0, 0] = x1;

coord[0, 1] = y1;

coord[1, 0] = x2;

coord[1, 1] = y2;

coord[2, 0] = x3;

coord[2, 1] = y3;

coord[3, 0] = x4;

coord[3, 1] = y4;

}tmoveCoord(int id, string d, int c = 1)

{(int i = 0; i < c; i++)

{(d)

{"Left":

tcoord[id, 0] = tcoord[id, 0] - 1; break;"Right":

tcoord[id, 0] = tcoord[id, 0] + 1; break;"Up":

tcoord[id, 1] = tcoord[id, 1] - 1; break;"Down":

tcoord[id, 1] = tcoord[id, 1] + 1; break;

}

}

}checkCoord(int[,] m)

{(int i = 0; i < 4; i++)

9);(m[i,1] 18);(MainWindow.table[m[i, 0], m[i, 1]] == true)

{f = false;(int i_ = 0; i_ < 4; i_++)

{(m[i, 0] == coord[i_, 0] && m[i, 1] == coord[i_, 1])

f = true;

}(!f);

}

};

}remove()

{x = 0;y = 0;(int i = 0; i < 4; i++)

{

x = coord[i, 0];

y = coord[i, 1];.table[x, y] = false;

}

}createTank(string pose)

{(pose)

{"center":

setCoord(5, 8, 5, 9, 4, 9, 6, 9);;"down":

setCoord(4, 17, 4, 18, 3, 18, 5, 18);;"up":

setCoord(6, 1, 6, 0, 7, 0, 5, 0);

state = 3;;"left":

setCoord(1, 7, 0, 7, 0, 6, 0, 8);

state = 2;;"right":

setCoord(8, 9, 9, 9, 9, 10, 9, 8);

state = 4;;

}

}toTable()

{(int i = 0; i < 4; i++).table[coord[i, 0], coord[i, 1]] = true;.Inv();

}copy(int[,] m1, int[,] m2)

{(int i = 0; i < 4; i++)

{(int j = 0; j < 2; j++)

{

m1[i, j] = m2[i, j];

}

}

}left()

{(coord[0, 0] == 0 || coord[1, 0] == 0 || coord[2, 0] == 0 || coord[3, 0] == 0);x = 0;y = 0;x1 = 0;y1 = 0;f = false;(int i = 0; i < 4; i++)

{

x = coord[i, 0];

y = coord[i, 1];(MainWindow.table[x - 1, y] == true)

{(int j = 0; j < 4; j++)

{

x1 = coord[j, 0];

y1 = coord[j, 1];(x - 1 ==