now is enable build and delete towers in game and improve graphic perfomance
find and correct many-many bugs
This commit is contained in:
@@ -11,11 +11,44 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
scene = new QGraphicsScene();
|
||||
setScene(scene);
|
||||
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
//setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
mapimg = new QImage(data->map->rect().size()*cellSize,QImage::Format_ARGB32);
|
||||
//setDragMode(RubberBandDrag);
|
||||
//gsw = new QGraphicsWidget();
|
||||
//scene->addWidget(new QPushButton());
|
||||
QPainter p(mapimg);
|
||||
for (int i=0; i<data->map->cells().size(); i++) {
|
||||
for (int j=0; j<data->map->cells().at(i).size(); j++) {
|
||||
QPen pen;
|
||||
QBrush brush;
|
||||
pen.setColor(Qt::white);
|
||||
brush.setColor(Qt::white);
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
int cel = data->map->cells().at(i).at(j);
|
||||
if (cel == Map::Wall)
|
||||
{
|
||||
pen.setColor(Qt::black);
|
||||
brush.setColor(Qt::black);
|
||||
}
|
||||
// if (cel <= Map::PlayerTower && cel !=Map::Wall) {
|
||||
// pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
||||
// brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
||||
// }
|
||||
// if (cel >= Map::PlayerAlien) {
|
||||
// pen.setColor(Qt::yellow);
|
||||
// brush.setColor(Qt::yellow);
|
||||
// }
|
||||
if (cel >= Map::Player || (cel <= Map::PlayerTower && cel !=Map::Wall))
|
||||
{
|
||||
pen.setColor(QColor(qAbs(cel)*345%255,(qAbs(cel)*721)%255,(qAbs(cel)*75)%255,50));
|
||||
brush.setColor(QColor(qAbs(cel)*345%255,(qAbs(cel)*721)%255,(qAbs(cel)*75)%255,50));
|
||||
}
|
||||
p.setPen(pen);
|
||||
p.setBrush(brush);
|
||||
p.drawRect(i*cellSize,j*cellSize,cellSize,cellSize);
|
||||
}
|
||||
}
|
||||
|
||||
startTimer(25);
|
||||
show();
|
||||
@@ -55,37 +88,7 @@ void AD_Graphics::timerEvent(QTimerEvent * )
|
||||
|
||||
void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
|
||||
{
|
||||
for (int i=0; i<data->map->cells().size(); i++) {
|
||||
for (int j=0; j<data->map->cells().at(i).size(); j++) {
|
||||
QPen pen;
|
||||
QBrush brush;
|
||||
pen.setColor(Qt::white);
|
||||
brush.setColor(Qt::white);
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
int cel = data->map->cells().at(i).at(j);
|
||||
if (cel == Map::Wall)
|
||||
{
|
||||
pen.setColor(Qt::black);
|
||||
brush.setColor(Qt::black);
|
||||
}
|
||||
// if (cel <= Map::PlayerTower && cel !=Map::Wall) {
|
||||
// pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
||||
// brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
|
||||
// }
|
||||
// if (cel >= Map::PlayerAlien) {
|
||||
// pen.setColor(Qt::yellow);
|
||||
// brush.setColor(Qt::yellow);
|
||||
// }
|
||||
if (cel >= Map::Player || (cel <= Map::PlayerTower && cel !=Map::Wall))
|
||||
{
|
||||
pen.setColor(QColor(qAbs(cel)%255,(qAbs(cel)*100)%255,(qAbs(cel)+100)%255,50));
|
||||
brush.setColor(QColor(qAbs(cel)%255,(qAbs(cel)*100)%255,(qAbs(cel)+100)%255,50));
|
||||
}
|
||||
p->setPen(pen);
|
||||
p->setBrush(brush);
|
||||
p->drawRect(i*cellSize,j*cellSize,cellSize,cellSize);
|
||||
}
|
||||
}
|
||||
p->drawImage(0,0,*mapimg);
|
||||
//qDebug() << "t:" << data->curTowers.size();
|
||||
for (QHash<QPoint, TowerType>::iterator i = data->curTowers.begin(); i != data->curTowers.end(); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user