new class Alien
global restruct ALL!!
This commit is contained in:
@@ -25,12 +25,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
//AnimAlien = 0;
|
||||
timer->start(50);
|
||||
qDebug() << "Load DONE!";
|
||||
mousebt = 0;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::ADrender()
|
||||
{
|
||||
adp->drawAliens(aliens->curAliens[0].path, &aliens->curAliens[0].Position);
|
||||
adp->drawAliens(aliens->curAliens[0].AlienPath(), aliens->curAliens[0].pos());
|
||||
this->repaint();
|
||||
}
|
||||
|
||||
@@ -46,49 +47,53 @@ void MainWindow::paintEvent(QPaintEvent*)
|
||||
|
||||
void MainWindow::mouseMoveEvent ( QMouseEvent * event )
|
||||
{
|
||||
if (mousebt == 1) ClearCell(event->x(),event->y());
|
||||
else SetCell(event->x(),event->y());
|
||||
if (mousebt == 1) ClearCell(event->pos());
|
||||
if (mousebt == 2) SetCell(event->pos());
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mousePressEvent ( QMouseEvent * event )
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
ClearCell(event->x(),event->y());
|
||||
ClearCell(event->pos());
|
||||
mousebt = 1;
|
||||
} else {
|
||||
SetCell(event->x(),event->y());
|
||||
mousebt = 0;
|
||||
return;
|
||||
}
|
||||
if(event->button() == Qt::LeftButton) {
|
||||
SetCell(event->pos());
|
||||
mousebt = 2;
|
||||
return;
|
||||
}
|
||||
mousebt = 0;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::SetCell(int x, int y)
|
||||
void MainWindow::SetCell(QPoint pos)
|
||||
{
|
||||
QPoint cp;
|
||||
QRect wdrect(0, 0, (this->width() / cellsize) * cellsize, (this->height() / cellsize) * cellsize);
|
||||
if (wdrect.contains(x,y)) {
|
||||
cp.setX((int) x / cellsize);
|
||||
cp.setY((int) y / cellsize);
|
||||
if (wdrect.contains(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;
|
||||
adp->drawcell(cp);
|
||||
//aliens->clearAliens();
|
||||
//adp->StepAlien=0;
|
||||
//adp->AnimAlien=0;
|
||||
if (!aliens->CreatePath(&(aliens->curAliens[0]))) ClearCell(x,y);
|
||||
if (!aliens->CreatePath(&(aliens->curAliens[0]))) ClearCell(pos);
|
||||
else adp->StepAlien=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::ClearCell(int x, int y)
|
||||
void MainWindow::ClearCell(QPoint pos)
|
||||
{
|
||||
QPoint cp;
|
||||
QRect wdrect(0, 0, (this->width() / cellsize) * cellsize, (this->height() / cellsize) * cellsize);
|
||||
if (wdrect.contains(x,y)) {
|
||||
cp.setX((int) x / cellsize);
|
||||
cp.setY((int) y / cellsize);
|
||||
if (wdrect.contains(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;
|
||||
adp->clearcell(cp);
|
||||
|
||||
Reference in New Issue
Block a user