now this work stable

global restruct fuinish part 1 of 3
This commit is contained in:
2010-02-07 16:18:29 +03:00
parent 6a11d7fbcd
commit 3f8971b113
16 changed files with 157 additions and 110 deletions

View File

@@ -7,8 +7,8 @@ MainWindow::MainWindow(QWidget *parent)
{
qDebug() << "Load START!";
ui->setupUi(this);
sndr = new UdpSender("127.0.0.1",10101);
sndr->connectSend("hellow");
//sndr = new UdpSender("127.0.0.1",10101);
//sndr->connectSend("hellow");
cellsize = 16;
destx = this->width() / cellsize;
desty = this->height() / cellsize / 2;
@@ -17,8 +17,8 @@ MainWindow::MainWindow(QWidget *parent)
adp->clear();
adp->drawgrid();
connect(timer, SIGNAL(timeout()), this, SLOT(ADrender()));
GameMain = new game(this->size(),QPoint(0,this->height()/2),QPoint(this->width()-cellsize,this->height()/2), cellsize);
aliens = new Aliens(GameMain->data);
GameMain = new games(this->size(),QPoint(0,this->height()/2),QPoint(this->width()-cellsize,this->height()/2), cellsize);
aliens = new Aliens(GameMain);
aliens->AddAlien();
this->setGeometry(100,100,this->width(),this->height());
//qDebug() << "QT version" << qVersion();
@@ -45,14 +45,14 @@ void MainWindow::paintEvent(QPaintEvent*)
}
void MainWindow::mouseMoveEvent ( QMouseEvent * event )
void MainWindow::mouseMoveEvent (QMouseEvent *event)
{
if (mousebt == 1) ClearCell(event->pos());
if (mousebt == 2) SetCell(event->pos());
}
void MainWindow::mousePressEvent ( QMouseEvent * event )
void MainWindow::mousePressEvent (QMouseEvent *event)
{
if (event->button() == Qt::RightButton) {
ClearCell(event->pos());
@@ -76,7 +76,7 @@ void MainWindow::SetCell(QPoint pos)
cp.setX(pos.x()/cellsize);
cp.setY(pos.y()/cellsize);
//qDebug() << "click: " << cp.x() << ";" << cp.y();
GameMain->data->Cells[cp.x()][cp.y()] = - 1;
GameMain->Cells[cp.x()][cp.y()] = - 1;
adp->drawcell(cp);
//aliens->clearAliens();
//adp->StepAlien=0;
@@ -95,7 +95,7 @@ void MainWindow::ClearCell(QPoint pos)
cp.setX(pos.x()/cellsize);
cp.setY(pos.y()/cellsize);
//qDebug() << "click: " << cp.x() << ";" << cp.y();
GameMain->data->Cells[cp.x()][cp.y()] = 0;
GameMain->Cells[cp.x()][cp.y()] = 0;
adp->clearcell(cp);
//aliens->clearAliens();
//aliens->AddAlien();
@@ -105,6 +105,17 @@ void MainWindow::ClearCell(QPoint pos)
}
void MainWindow::keyPressEvent(QKeyEvent * e)
{
qDebug() << e->key();
switch(e->key()) {
case 69:
aliens->AddAlien();
break;
}
}
MainWindow::~MainWindow()
{
delete ui;