Subversion Repositories QTron

Compare Revisions

Ignore whitespace Rev 1 → Rev 3

/ui_mainwindow.h
File deleted
/mainwindow.ui
File deleted
/QTron.pro
1,7 → 1,7
# -------------------------------------------------
# Project created by QtCreator 2010-05-31T15:59:14
# -------------------------------------------------
QT += network
QT += network opengl
TARGET = QTron
TEMPLATE = app
SOURCES += main.cpp \
9,5 → 9,5
bike.cpp
HEADERS += mainwindow.h \
bike.h
FORMS += mainwindow.ui
FORMS +=
OTHER_FILES += docs.txt
/mainwindow.h
6,16 → 6,12
#include <QTcpServer>
#include <QList>
#include <QTimer>
#include <QGLWidget>
 
#include "bike.h"
 
namespace Ui
class MainWindow : public QGLWidget
{
class MainWindow;
}
 
class MainWindow : public QMainWindow
{
Q_OBJECT
 
public:
24,11 → 20,9
void reset();
 
protected:
void changeEvent(QEvent *e);
void paintEvent(QPaintEvent *e);
 
private:
Ui::MainWindow *ui;
QTcpServer *server;
QList<Bike *> bikes;
QTimer *timer;
/mainwindow.cpp
1,16 → 1,10
#include "mainwindow.h"
#include "ui_mainwindow.h"
 
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
QGLWidget(parent)
{
ui->setupUi(this);
this->setFixedSize(800, 600);
 
this->setMinimumSize(800, 600);
this->resize(800, 600);
this->setMaximumSize(800, 600);
 
server = new QTcpServer(this);
connect(server, SIGNAL(newConnection()), this, SLOT(newConnection()));
server->listen(QHostAddress::Any, 4567);
24,7 → 18,6
 
MainWindow::~MainWindow()
{
delete ui;
delete server;
}
 
36,24 → 29,12
}
}
 
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
 
void MainWindow::paintEvent(QPaintEvent *e)
{
e->accept();
QPainter painter(this);
 
painter.setRenderHint(QPainter::Antialiasing, true);
painter.fillRect(0, 0, 800, 600, Qt::white);
 
bool ready = true;
for (int i = 0; i < bikes.count(); i++)
70,16 → 51,18
{
if (bikes[i]->show)
{
bikes[i]->hasHadGo = false;
bikes[i]->run(bikes);
bikes[i]->hasHadGo = false;
bikes[i]->run(bikes);
bikes[i]->draw(&painter);
}
}
Bike *bike;
foreach(bike,bikes){
while(!bike->hasHadGo){
}
}
Bike *bike;
foreach(bike,bikes)
{
while(!bike->hasHadGo)
{
}
}
}
 
checkClients();