@@ -2,7 +2,7 @@
#define MAINWINDOW_H

#include <QMainWindow>

#include <connectwindow.h>
namespace Ui {
class MainWindow;
}
@@ -11,12 +11,21 @@ class MainWindow : public QMainWindow
{
Q_OBJECT

friend class ConnectWindow;
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private slots:

void on_joinToGameButton_clicked();
void on_exitButton_clicked();

void back(); //back to main window and delete ConnectWindow

private:
Ui::MainWindow *ui;
ConnectWindow *win;
};

#endif // MAINWINDOW_H
@@ -1,24 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="joinToGameButton">
<property name="geometry">
<rect>
<x>150</x>
<y>30</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>91</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Dołącz do gry</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>150</x>
<y>110</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="text">
<string>Opcje</string>
</property>
</widget>
<widget class="QPushButton" name="exitButton">
<property name="geometry">
<rect>
<x>150</x>
<y>190</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="text">
<string>Wyjście</string>
</property>
</widget>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>Graphics/tank1.png</file>
</qresource>
</RCC>
@@ -0,0 +1,8 @@
#include "tank.h"

Tank::Tank(QString playerName):name(playerName)
{
czolg = new TankModel;
czolg->setFocus();
}

@@ -0,0 +1,37 @@
#ifndef TANK_H
#define TANK_H
#include <QString>
#include <QGraphicsPixmapItem>
#include <QGraphicsView>
#include "tankmodel.h"

class Tank
{
private:
int coordinateX;
int coordinateY;
int lifes;
QString name;



public:
Tank(QString playerName);
void updateCoordinates(int x, int y)
{
coordinateX+=x;
coordinateY+=y;
}
void updateLife(int life ){lifes=life;}
TankModel *czolg;





signals:

public slots:
};

#endif // TANK_H
@@ -0,0 +1,50 @@
#include "tankmodel.h"

TankModel::TankModel(QGraphicsItem *parent): QGraphicsItem(parent)
{
setFlag(QGraphicsItem::ItemIsFocusable);
}

QRectF TankModel::boundingRect() const
{
return QRectF(0,0,70,70);

}

void TankModel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{

painter->drawPixmap(10,10, QPixmap(":/Graphics/tank1.png"));
}

void TankModel::keyPressEvent(QKeyEvent *event)
{
switch(event->key())
{
case Qt::Key_Right:

moveBy(5,0);
break;


case Qt::Key_Left:

moveBy(-5,0);
break;


case Qt::Key_Up:

moveBy(0,-5);
break;


case Qt::Key_Down:

moveBy(0,5);

break;

}

}
@@ -0,0 +1,18 @@
#ifndef TANKMODEL_H
#define TANKMODEL_H
#include <QGraphicsItem>
#include <QGraphicsView>
#include <QKeyEvent>
class TankModel: public QGraphicsItem
{
public:
virtual void keyPressEvent(QKeyEvent *event);

TankModel(QGraphicsItem *parent =NULL);
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QRectF boundingRect() const;

};

#endif // TANKMODEL_H
@@ -8,6 +8,8 @@ client::client(QObject *parent)

int client::connectToServer(QString address, QString port)
{


QHostAddress hostAddress;
hostAddress.setAddress(address);

@@ -26,6 +28,7 @@ int client::connectToServer(QString address, QString port)
this->address = address;
this->port = port;
return 1;

}

int client::updatePosition()
@@ -40,4 +43,3 @@ int client::updatePosition()

return true;
}

@@ -15,6 +15,7 @@ class client : public QObject
int connectToServer(QString address, QString port);
int updatePosition();
private:

QString address,port;
QTcpSocket socket;