Игровая система "Тетрис"
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
x1 && y == y1)
{
f = true;;
}
}(!f) return;
f = false;
}
}();
coord[0, 0]--;
coord[1, 0]--;
coord[2, 0]--;
coord[3, 0]--;
toTable();.Inv();
}right()
{(coord[0, 0] == 9 || coord[1, 0] == 9 || coord[2, 0] == 9 || coord[3, 0] == 9);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 == x1 && y == y1)
{
f = true;;
}
}(!f) return;
f = false;
}
}();
coord[0, 0]++;
coord[1, 0]++;
coord[2, 0]++;
coord[3, 0]++;
toTable();.Inv();
}down()
{(coord[0, 1] == 18 || coord[1, 1] == 18 || coord[2, 1] == 18 || coord[3, 1] == 18);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, y + 1] == true)
{(int j = 0; j < 4; j++)
{
x1 = coord[j, 0];
y1 = coord[j, 1];(x == x1 && y + 1 == y1)
{
f = true;;
}
}(!f);
f = false;
}
}();
coord[0, 1]++;
coord[1, 1]++;
coord[2, 1]++;
coord[3, 1]++;
toTable();.Inv();;
}up()
{(coord[0, 1] == 0 || coord[1, 1] == 0 || coord[2, 1] == 0 || coord[3, 1] == 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, y - 1] == true)
{(int j = 0; j < 4; j++)
{
x1 = coord[j, 0];
y1 = coord[j, 1];(x == x1 && y - 1 == y1)
{
f = true;;
}
}(!f);
f = false;
}
}();
coord[0, 1]--;
coord[1, 1]--;
coord[2, 1]--;
coord[3, 1]--;
toTable();.Inv();;
}rightRot(string test = "no test")
{
copy(tcoord, coord);stateBackup = state;(state == 1)
{
tmoveCoord(1, "Left");
tmoveCoord(1, "Up");
tmoveCoord(3, "Left", 2);
tmoveCoord(3, "Up", 2);(!checkCoord(tcoord));
state = 4;
}(state == 4)
{
tmoveCoord(1, "Up");
tmoveCoord(1, "Right");
tmoveCoord(2, "Right", 2);
tmoveCoord(2, "Up", 2);(!checkCoord(tcoord));
state = 3;
}(state == 3)
{
tmoveCoord(1, "Right");
tmoveCoord(1, "Down");
tmoveCoord(3, "Down", 2);
tmoveCoord(3, "Right", 2);(!checkCoord(tcoord));
state = 2;
}(state == 2)
{
tmoveCoord(1, "Down");
tmoveCoord(1, "Left");
tmoveCoord(2, "Down", 2);
tmoveCoord(2, "Left", 2);(!checkCoord(tcoord));
state = 1;
}(test == "no test")
{
remove();
copy(coord, tcoord);
toTable();.Inv();
}
state = stateBackup;
;
}leftRot(string test = "no test")
{
copy(tcoord, coord);stateBackup = state;(state == 1)
{
tmoveCoord(1, "Right");
tmoveCoord(1, "Up");
tmoveCoord(2, "Right", 2);
tmoveCoord(2, "Up", 2);(!checkCoord(tcoord));
state = 2;
}(state == 2)
{
tmoveCoord(1, "Up");
tmoveCoord(1, "Left");
tmoveCoord(3, "Left", 2);
tmoveCoord(3, "Up", 2);(!checkCoord(tcoord));
state = 3;
}(state == 3)
{
tmoveCoord(1, "Left");
tmoveCoord(1, "Down");
tmoveCoord(2, "Down", 2);
tmoveCoord(2, "Left", 2);(!checkCoord(tcoord));
state = 4;
}(state == 4)
{
tmoveCoord(1, "Down");
tmoveCoord(1, "Right");
tmoveCoord(3, "Down", 2);
tmoveCoord(3, "Right", 2);(!checkCoord(tcoord));
state = 1;
}(test == "no test")
{
remove();
copy(coord, tcoord);
toTable();.Inv();
}
state = stateBackup;;
}go()
{(state)
{1:
up(); break;2:
left(); break;3:
down(); break;4:
right(); break;
}
}goBack()
{(!rightRot("test"))(!leftRot("test"))(state)
{1: down(); break;2: right(); break;3: up(); break;4: left(); break;
}
}push()
{sh = newShot(this);
score -= 40;thr = newThread(sh.go);
thr.Start();
}inMe(int x, int y, bool fl = false)
{(y == 0 && fl)
{(int i = 0; i < 4; i++)
{(coord[i, 0] == x);
}
}(x == 0 && fl)
{(int i = y + 1; i < 4; i++)
{(coord[i, 1] == y);
}
}(int i = 0; i < 4; i++)
{(coord[i, 0] == x && coord[i, 1] == y);
};
}destroy()
{
remove();.Inv();
}wounded()
{
health--;
score -= 50;
toTable();(health == 0)
{.Tanks_.GameOver(name);
}.MF.updateT();
}cheatUse(string dir)
{(cheat == 0);
cheat--;(cheat >= 0)
{(dir == "l")
{
left();
}(dir == "r")
{
right();
}
};
score -= 200;.MF.updateT();
}
}
}
КлассTanks - отвечает за игровой процесс игры гоники(танки).System;System.Collections.Generic;System.Linq;System.Text;System.Threading.Tasks;System.Windows.Forms;System.Threading;TetrixSystem
{
{thr;Tank_;Tank_1;gOver = false;Start()
{
ClearTable();
thr = newThread(newThreadStart(tableProc));
thr.Start();
}tableProc()
{
Tank_ = newTank("down", true);
Tank_1 = newTank("up", true);.Inv();
}isTable(Tank t)
{(int i = 0; i < 4; i++)
{(MainWindow.table[t.coord[i, 0], t.coord[i, 1]] == true);
};
}ClearTable()
{(int i = 0; i < 10; i++)(int j = 0; j < 19; j++).table[i, j] = false;.Inv();
}GameOver(string name)
{
gOver = true;.MF.gOver(name);
}
}
}
КлассMainWindow - отвечает за обработку всех событий устройств ввода, а так же отображения информации на экран пользователю текущей информации.System;System.Collections.Generic;System.ComponentModel;System.Data;System.Drawing;System.Drawing.Drawing2D;System.Linq;System.Text;System.Threading.Tasks;System.Collections;System.Windows.Forms;System.IO;System.Threading;TetrixSystem
{: Form
{game = "";fullPaint = true;nextPaint = false;MF;thrTime;Build_ = newBuild();Shape_ = newShape();Tanks_ = null;[,] table = newbool[10, 19];Inv()
{
MF.PanelPad.Invalidate();
}EndGame()
{_build End = newEnd_build();
End.ShowDialog();
}toRecords(string name)
{
listView1.Items.Add(name);
listView1.Items[listView1.Items.Count - 1].SubItems.Add(Build.Score.ToString());
listView1.Items[listView1.Items.Count - 1].SubItems.Add(Build.Level.ToString());
listView1.Items[listView1.Items.Count - 1].SubItems.Add(Build.LinesRemoved.ToString());
listView1.Items[listView1.Items.Count - 1].SubItems.Add(Build.mode.ToString());
Sort();
saveRecords();
}saveRecords()
{tw = newStreamWriter("records.dat", false);(ListViewItem item inthis.listView1.Items)
{(ListViewItem.ListViewSubItem subItem in item.SubItems)
{
tw.WriteLine(subItem.Text);
}
}.Close();
}Sort(int e = 2)
{
// Create an instance of the ColHeader class.clickedCol = (ColHeader)this.listView1.Columns[e];
// Set the ascending property to sort in the opposite order.
clickedCol.ascending = !clickedCol.ascending;
// Get the number of items in the list.numItems = this.listView1.Items.Count;
// Turn off display while data is repoplulated..listView1.BeginUpdate();
// Populate an ArrayList with a SortWrapper of each list item.SortArray = newArrayList();(int i = 0; i < numItems; i++)
{
SortArray.Add(newSortWrapper(this.listView1.Items[i], e));
}
// Sort the elements in the ArrayList using a new instance of the SortComparer
// class. The parameters are the starting index, the length of the range to sort,
// and the IComparer implementation to use for comparing elements. Note that
// the IComparer implementation (SortComparer) requires the sort
// direction for its constructor; true if ascending, othwise false.
SortArray.Sort(0, SortArray.Count, newSortWrapper.SortComparer(clickedCol.ascending));
// Clear the list, and repopulate with the sorted items..listView1.Items.Clear();(int i = 0; i < numItems; i++).listView1.Items.Add(((SortWrapper)SortArray[i]).sortItem);
// Turn display back on..listView1.EndUpdate();
}setScoreShape(int s, int s_)
{
label1.Text = s.ToString();
label4.Text = s_.ToString();
}setRemovLin