#include <QtCore>
#include <QtGui>
#include <QDebug>
#include <CoordinateValue.h>
#include <mainwindow.h>
#include <Level.h>
//#include <Coordinate.h>
//#include<Graphics.h>
int main(int argc, char *argv[])
{
lvlone.
load(QString::fromUtf8("C:/Users/Agup/Desktop/Map1.bmp"));
ftowpic.
load(QString::fromUtf8("C:/Users/Agup/Desktop/FreshmenTower.bmp"));
CoordinateValue cv;
//cv.setValid(1);
//load pixmap into icon for button
ftowicon.addPixmap(ftowpic);
// next code is to check if worked or not
//qDebug() << goodLoad << lvlone.isNull() << lvlone.size() << lvlone.depth();
//make mappaint use the map as background
mappaint.setPen(Black);
for(int i = 0;i<501;i += 50)
{
mappaint.drawLine(0,i,500,i);
}
for(int j = 0;j<501;j += 50)
{
mappaint.drawLine(j,0,j,500);
}
//use this code to draw towers depenrding on valid spots.
//mappaint.drawPixmap(200,150,50,50, ftowpic);
//QPushButton Start("Start", &window);
//Start.setGeometry(200,200,50,50);
//QObject::connect(&Start,SIGNAL(clicked()),g,SLOT(PaintIT()));
//freshmen tower button
QPushButton FTower
(ftowicon,
"Freshmen\n Tower",
&window
);
FTower.
setFont(QFont("Purisa",
8));
FTower.setGeometry(500,0,100,100);
FTower.setIconSize(ftowsize);
cv.getPainter(mappaint);
QObject::connect(&FTower,
SIGNAL(clicked
()),
&cv,
SLOT(paintValid
()));
quit.
setFont(QFont("Purisa",
12));
quit.setGeometry(575,400,100,50);
QObject::connect(&quit,
SIGNAL(clicked
()),
&app,
SLOT(quit
()));
window.resize(750,500);
window.setPixmap(lvlone);
window.show();
cv.paintValid();
return app.exec();
}
#include <QtCore>
#include <QtGui>
#include <QDebug>
#include <CoordinateValue.h>
#include <mainwindow.h>
#include <Level.h>
//#include <Coordinate.h>
//#include<Graphics.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel window;
QPixmap lvlone;
QPixmap ftowpic;
QIcon ftowicon;
lvlone.load(QString::fromUtf8("C:/Users/Agup/Desktop/Map1.bmp"));
ftowpic.load(QString::fromUtf8("C:/Users/Agup/Desktop/FreshmenTower.bmp"));
CoordinateValue cv;
//cv.setValid(1);
//load pixmap into icon for button
ftowicon.addPixmap(ftowpic);
QSize ftowsize(25,25);
// next code is to check if worked or not
//qDebug() << goodLoad << lvlone.isNull() << lvlone.size() << lvlone.depth();
//make mappaint use the map as background
QPainter mappaint(&lvlone);
QPen Black((QColor::QColor(0,0,0)),1);
mappaint.setPen(Black);
for(int i = 0;i<501;i += 50)
{
mappaint.drawLine(0,i,500,i);
}
for(int j = 0;j<501;j += 50)
{
mappaint.drawLine(j,0,j,500);
}
//use this code to draw towers depenrding on valid spots.
//mappaint.drawPixmap(200,150,50,50, ftowpic);
//QPushButton Start("Start", &window);
//Start.setGeometry(200,200,50,50);
//QObject::connect(&Start,SIGNAL(clicked()),g,SLOT(PaintIT()));
//freshmen tower button
QPushButton FTower(ftowicon,"Freshmen\n Tower", &window);
FTower.setFont(QFont("Purisa",8));
FTower.setGeometry(500,0,100,100);
FTower.setIconSize(ftowsize);
cv.getPainter(mappaint);
QObject::connect(&FTower,SIGNAL(clicked()),&cv, SLOT(paintValid()));
QPushButton quit("Quit", &window);
quit.setFont(QFont("Purisa", 12));
quit.setGeometry(575,400,100,50);
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
window.resize(750,500);
window.setPixmap(lvlone);
window.show();
cv.paintValid();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
#ifndef COORDINATEVALUE_H
#define COORDINATEVALUE_H
#include <QtCore>
#include <QtGui>
#include <QDebug>
#include <Coordinate.h>
class CoordinateValue
: public QObject{
Q_OBJECT
Coordinate coor[100];
public:
//makes 100 coordinates
int getSpot(int x,int y)
{
//returns numerical spot corresponding
//with array coor for which spot coordinate is in
return (x%50)+((y/50)*10);
}
void setValues()
{
//sets each value of grid in image
//to a value of 1-100 based on location
int c = 0;
for(int i = 0; i<500; i+= 50){
for(int j = 0;j<500; j+=50)
{
coor[c].setX(j);
coor[c].setY(i);
c++;
}
}
}
//get X Drawing Coordinates
int getXDC(int spot)
{
return coor[spot].getX();
}
//get Y Drawing Coordinates
int getYDC(int spot)
{
return coor[spot].getY();
}
void setValid(int levelnum)
{
// switch (levelnum)
// case 1:
// break;
// case 2:
// break;
}
{
plzwrk = painter;
}
public slots:
void paintValid()
{
linepen.setWidth(2);
linepen.setColor(Qt::green);
plzwrk.setPen(linepen);
transbrush.setColor(Qt::green);
transbrush.setStyle(Qt::Dense5Pattern);
path.addPolygon(poly);
plzwrk.drawPolygon(poly);
plzwrk.fillPath(path,transbrush);
}
void doNothing()
{
qDebug()<<new1;
}
};
#endif // COORDINATEVALUE_H
#ifndef COORDINATEVALUE_H
#define COORDINATEVALUE_H
#include <QtCore>
#include <QtGui>
#include <QDebug>
#include <Coordinate.h>
class CoordinateValue: public QObject
{
Q_OBJECT
Coordinate coor[100];
public:
QPixmap newImage;
QLabel newWindow;
QPainter plzwrk;
//makes 100 coordinates
int getSpot(int x,int y)
{
//returns numerical spot corresponding
//with array coor for which spot coordinate is in
return (x%50)+((y/50)*10);
}
void setValues()
{
//sets each value of grid in image
//to a value of 1-100 based on location
int c = 0;
for(int i = 0; i<500; i+= 50){
for(int j = 0;j<500; j+=50)
{
coor[c].setX(j);
coor[c].setY(i);
c++;
}
}
}
//get X Drawing Coordinates
int getXDC(int spot)
{
return coor[spot].getX();
}
//get Y Drawing Coordinates
int getYDC(int spot)
{
return coor[spot].getY();
}
void setValid(int levelnum)
{
// switch (levelnum)
// case 1:
// break;
// case 2:
// break;
}
void getPainter(QPainter &painter)
{
plzwrk = painter;
}
public slots:
void paintValid()
{
QPen linepen;
linepen.setWidth(2);
linepen.setColor(Qt::green);
plzwrk.setPen(linepen);
QPolygon poly;
poly<< QPoint(0,0);
poly<< QPoint(0,50);
poly<< QPoint(50,50);
poly<< QPoint(50,0);
QBrush transbrush;
transbrush.setColor(Qt::green);
transbrush.setStyle(Qt::Dense5Pattern);
QPainterPath path;
path.addPolygon(poly);
plzwrk.drawPolygon(poly);
plzwrk.fillPath(path,transbrush);
}
void doNothing()
{
QString new1 = "hi";
qDebug()<<new1;
}
};
#endif // COORDINATEVALUE_H
To copy to clipboard, switch view to plain text mode
Bookmarks