Skip to content

Commit

Permalink
v5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Nov 14, 2015
1 parent 568f1d3 commit 34c5057
Show file tree
Hide file tree
Showing 33 changed files with 213 additions and 232 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# Boenken
C++ 20-player game that is a mix between soccer and billiards

C++ 20-player game that is a mix between soccer and billiards using Qt.

## Screenshots

Most recent at the top.

![Boenken version 5.0](Screenshots/Boenken_5_0.png)

![Boenken menu version 4.1](Screenshots/BoenkenMenu_4_1.png)
![Boenken version 4.1](Screenshots/Boenken_4_1.png)

![Boenken menu version 3.1](Screenshots/BoenkenMenu_3_1.png)
![Boenken version 3.1](Screenshots/Boenken_3_1.png)

![Boenken version 3.0](Screenshots/Boenken_3_0.png)

![Boenken menu version 2.0](Screenshots/BoenkenMenu_2_0.png)
![Boenken version 2.0](Screenshots/Boenken_2_0.png)

![Boenken menu version 1.0](Screenshots/BoenkenMenu_1_0.png)
![Boenken version 1.0](Screenshots/Boenken_1_0.png)
Binary file added Screenshots/BoenkenMenu_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/BoenkenMenu_2_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/BoenkenMenu_3_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/BoenkenMenu_4_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Boenken_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Boenken_2_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Boenken_3_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Boenken_3_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Boenken_4_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Boenken_5_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int main(int argc, char * argv[])
{
const std::vector<std::string> args { ribi::MenuDialog::ConvertArguments(argc,argv) };
return ribi::Boenken::MenuDialog().Execute(args);
return ribi::bnkn::MenuDialog().Execute(args);
}
18 changes: 9 additions & 9 deletions qtboenkenarenadialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "ui_qtboenkenarenadialog.h"
#pragma GCC diagnostic pop

ribi::bnkn::QtBoenkenArenaDialog::QtBoenkenArenaDialog(QWidget *parent) noexcept :
ribi::bnkn::QtArenaDialog::QtArenaDialog(QWidget *parent) noexcept :
QtHideAndShowDialog(parent),
ui(new Ui::QtBoenkenArenaDialog)
{
ui->setupUi(this);
QObject::connect(
ui->button_done,&QPushButton::clicked,this,&QtBoenkenArenaDialog::close);
ui->button_done,&QPushButton::clicked,this,&QtArenaDialog::close);
}

ribi::bnkn::QtBoenkenArenaDialog::~QtBoenkenArenaDialog() noexcept
ribi::bnkn::QtArenaDialog::~QtArenaDialog() noexcept
{
delete ui;
}

///The purpose of QtBoenkenArenaDialog is to create
///an ArenaSettings
ribi::bnkn::ArenaSettings ribi::bnkn::QtBoenkenArenaDialog::GetSettings() const noexcept
ribi::bnkn::ArenaSettings ribi::bnkn::QtArenaDialog::GetSettings() const noexcept
{
ArenaSettings s;
s.formation = this->GetFormation();
Expand All @@ -58,7 +58,7 @@ ribi::bnkn::ArenaSettings ribi::bnkn::QtBoenkenArenaDialog::GetSettings() const
return s;
}

std::pair<int,int> ribi::bnkn::QtBoenkenArenaDialog::GetScreenSize() const noexcept
std::pair<int,int> ribi::bnkn::QtArenaDialog::GetScreenSize() const noexcept
{
//Makes the code shorter and copy-pastable
const QComboBox * const b = ui->box_screen_size;
Expand Down Expand Up @@ -86,7 +86,7 @@ std::pair<int,int> ribi::bnkn::QtBoenkenArenaDialog::GetScreenSize() const noexc
}
}

int ribi::bnkn::QtBoenkenArenaDialog::GetNballs() const noexcept
int ribi::bnkn::QtArenaDialog::GetNballs() const noexcept
{
//Makes the code shorter and copy-pastable
const QComboBox * const b = ui->box_nballs;
Expand All @@ -105,7 +105,7 @@ int ribi::bnkn::QtBoenkenArenaDialog::GetNballs() const noexcept
}
}

int ribi::bnkn::QtBoenkenArenaDialog::GetNobstacles() const noexcept
int ribi::bnkn::QtArenaDialog::GetNobstacles() const noexcept
{
//Makes the code shorter and copy-pastable
const QComboBox * const b = ui->box_obstacles;
Expand All @@ -123,7 +123,7 @@ int ribi::bnkn::QtBoenkenArenaDialog::GetNobstacles() const noexcept
throw std::logic_error("ribi::bnkn::QtBoenkenArenaDialog::GetNobstacles");
}

ribi::bnkn::Formation ribi::bnkn::QtBoenkenArenaDialog::GetFormation() const noexcept
ribi::bnkn::Formation ribi::bnkn::QtArenaDialog::GetFormation() const noexcept
{
//Makes the code shorter and copy-pastable
const QComboBox * const b = ui->box_formation;
Expand All @@ -144,7 +144,7 @@ ribi::bnkn::Formation ribi::bnkn::QtBoenkenArenaDialog::GetFormation() const noe
throw std::logic_error("ribi::bnkn::QtBoenkenArenaDialog::GetFormation");
}

double ribi::bnkn::QtBoenkenArenaDialog::GetFriction() const noexcept
double ribi::bnkn::QtArenaDialog::GetFriction() const noexcept
{
const QComboBox * const b = ui->box_friction;
assert(b->count()==3);
Expand Down
14 changes: 7 additions & 7 deletions qtboenkenarenadialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ namespace bnkn {
///QtBoenkenArenaDialog
///
///Dialog to setup up the arena
class QtBoenkenArenaDialog : public QtHideAndShowDialog
class QtArenaDialog : public QtHideAndShowDialog
{
Q_OBJECT

public:
explicit QtBoenkenArenaDialog(QWidget *parent = 0) noexcept;
QtBoenkenArenaDialog(const QtBoenkenArenaDialog&) = delete;
QtBoenkenArenaDialog& operator=(const QtBoenkenArenaDialog&) = delete;
~QtBoenkenArenaDialog() noexcept;
explicit QtArenaDialog(QWidget *parent = 0) noexcept;
QtArenaDialog(const QtArenaDialog&) = delete;
QtArenaDialog& operator=(const QtArenaDialog&) = delete;
~QtArenaDialog() noexcept;

std::pair<int,int> GetScreenSize() const noexcept;
int GetNballs() const noexcept;
int GetNobstacles() const noexcept;
bnkn::Formation GetFormation() const noexcept;
Formation GetFormation() const noexcept;
double GetFriction() const noexcept;
bnkn::ArenaSettings GetSettings() const noexcept;
ArenaSettings GetSettings() const noexcept;

private:
Ui::QtBoenkenArenaDialog *ui;
Expand Down
40 changes: 20 additions & 20 deletions qtboenkencontrolsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "ui_qtboenkencontrolsdialog.h"
#pragma GCC diagnostic pop

ribi::bnkn::QtBoenkenControlsDialog::QtBoenkenControlsDialog(QWidget *parent)
ribi::bnkn::QtControlsDialog::QtControlsDialog(QWidget *parent)
: QtHideAndShowDialog(parent),
ui(new Ui::QtBoenkenControlsDialog),
m_keys_accel{},
Expand All @@ -42,7 +42,7 @@ ribi::bnkn::QtBoenkenControlsDialog::QtBoenkenControlsDialog(QWidget *parent)
ui->button_done,
&QPushButton::clicked,
this,
&ribi::bnkn::QtBoenkenControlsDialog::close
&ribi::bnkn::QtControlsDialog::close
);
m_keys_accel.push_back(Qt::Key_W);
m_keys_accel.push_back(Qt::Key_Up);
Expand All @@ -53,35 +53,35 @@ ribi::bnkn::QtBoenkenControlsDialog::QtBoenkenControlsDialog(QWidget *parent)
ui->button_accelerate_1,
&QPushButton::clicked,
this,
&ribi::bnkn::QtBoenkenControlsDialog::onAccelerate1
&ribi::bnkn::QtControlsDialog::onAccelerate1
);
QObject::connect(
ui->button_accelerate_2,
&QPushButton::clicked,
this,
&ribi::bnkn::QtBoenkenControlsDialog::onAccelerate2
&ribi::bnkn::QtControlsDialog::onAccelerate2
);
QObject::connect(
ui->button_turn_1,
&QPushButton::clicked,
this,
&ribi::bnkn::QtBoenkenControlsDialog::onTurn1
&ribi::bnkn::QtControlsDialog::onTurn1
);
QObject::connect(ui->button_turn_2,
&QPushButton::clicked,
this,
&ribi::bnkn::QtBoenkenControlsDialog::onTurn2
&ribi::bnkn::QtControlsDialog::onTurn2
);

showKeys();
}

ribi::bnkn::QtBoenkenControlsDialog::~QtBoenkenControlsDialog() noexcept
ribi::bnkn::QtControlsDialog::~QtControlsDialog() noexcept
{
delete ui;
}

void ribi::bnkn::QtBoenkenControlsDialog::showKeys() noexcept
void ribi::bnkn::QtControlsDialog::showKeys() noexcept
{
ui->button_accelerate_1->setText(
boost::lexical_cast<std::string>(m_keys_accel[0]).c_str() );
Expand All @@ -94,61 +94,61 @@ void ribi::bnkn::QtBoenkenControlsDialog::showKeys() noexcept

}

void ribi::bnkn::QtBoenkenControlsDialog::onAccelerate1() noexcept
void ribi::bnkn::QtControlsDialog::onAccelerate1() noexcept
{
QtBoenkenPressKeyDialog d;
QtPressKeyDialog d;
d.exec();
const int key = d.GetKey();
m_keys_accel[0] = key;
showKeys();
}

void ribi::bnkn::QtBoenkenControlsDialog::onAccelerate2() noexcept
void ribi::bnkn::QtControlsDialog::onAccelerate2() noexcept
{
QtBoenkenPressKeyDialog d;
QtPressKeyDialog d;
d.exec();
const int key = d.GetKey();
m_keys_accel[1] = key;
showKeys();
}

void ribi::bnkn::QtBoenkenControlsDialog::onTurn1() noexcept
void ribi::bnkn::QtControlsDialog::onTurn1() noexcept
{
QtBoenkenPressKeyDialog d;
QtPressKeyDialog d;
d.exec();
const int key = d.GetKey();
m_keys_turn[0] = key;
showKeys();
}

void ribi::bnkn::QtBoenkenControlsDialog::onTurn2() noexcept
void ribi::bnkn::QtControlsDialog::onTurn2() noexcept
{
QtBoenkenPressKeyDialog d;
QtPressKeyDialog d;
d.exec();
const int key = d.GetKey();
m_keys_turn[1] = key;
showKeys();
}

std::vector<int> ribi::bnkn::QtBoenkenControlsDialog::getKeysAccel() const noexcept
std::vector<int> ribi::bnkn::QtControlsDialog::getKeysAccel() const noexcept
{
return m_keys_accel;
}

std::vector<int> ribi::bnkn::QtBoenkenControlsDialog::getKeysTurn() const noexcept
std::vector<int> ribi::bnkn::QtControlsDialog::getKeysTurn() const noexcept
{
return m_keys_turn;
}

std::vector<std::string> ribi::bnkn::QtBoenkenControlsDialog::getNames() const noexcept
std::vector<std::string> ribi::bnkn::QtControlsDialog::getNames() const noexcept
{
std::vector<std::string> v;
v.push_back(ui->edit_name1->text().toStdString());
v.push_back(ui->edit_name2->text().toStdString());
return v;
}

ribi::bnkn::Controls ribi::bnkn::QtBoenkenControlsDialog::GetControls() const noexcept
ribi::bnkn::Controls ribi::bnkn::QtControlsDialog::GetControls() const noexcept
{
bnkn::Controls c;
c.m_keys_accel = this->getKeysAccel();
Expand Down
10 changes: 5 additions & 5 deletions qtboenkencontrolsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ namespace bnkn {
///This dialog connects player names to their controls
///(but it does not connect sprites to their controllers,
///this is what DialogPlayers is for)
class QtBoenkenControlsDialog : public QtHideAndShowDialog
class QtControlsDialog : public QtHideAndShowDialog
{
Q_OBJECT

public:
explicit QtBoenkenControlsDialog(QWidget *parent = 0);
QtBoenkenControlsDialog(const QtBoenkenControlsDialog&) = delete;
QtBoenkenControlsDialog& operator=(const QtBoenkenControlsDialog&) = delete;
~QtBoenkenControlsDialog() noexcept;
explicit QtControlsDialog(QWidget *parent = 0);
QtControlsDialog(const QtControlsDialog&) = delete;
QtControlsDialog& operator=(const QtControlsDialog&) = delete;
~QtControlsDialog() noexcept;

bnkn::Controls GetControls() const noexcept;

Expand Down
58 changes: 18 additions & 40 deletions qtboenkengame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
ribi::bnkn::Game::Game(
const ArenaSettings& arena_settings,
const Controls& controls,
std::vector<boost::shared_ptr<SpritePlayer > > players,
const std::vector<SpritePlayer>& players,
std::vector<boost::shared_ptr<SpriteBall > > balls,
std::vector<boost::shared_ptr<SpriteNonMoving> > obstacles)
: m_players(players),
m_balls(balls),
m_obstacles(obstacles),
m_moving_sprites(CollectMovingSprites(players,balls)),
m_sprites(CollectSprites(players,balls,obstacles)),
m_moving_sprites{},
m_sprites{},
m_arena_settings(arena_settings),
m_controls(controls)
{
#ifndef NDEBUG
Test();
#endif
m_moving_sprites = CollectMovingSprites(m_players,m_balls);
m_sprites = CollectSprites(m_players,m_balls,m_obstacles);

///Reset the score to 0-0
SpriteBall::ResetScore();

Expand All @@ -79,15 +82,15 @@ ribi::bnkn::Game::Game(
SpriteBall::SetGoalPoles(goal_y_top,goal_y_bottom);
}

const std::vector<ribi::bnkn::SpriteMoving*> ribi::bnkn::Game::CollectMovingSprites(
std::vector<boost::shared_ptr<SpritePlayer> > players,
std::vector<boost::shared_ptr<SpriteBall > > balls)
std::vector<ribi::bnkn::SpriteMoving*> ribi::bnkn::Game::CollectMovingSprites(
std::vector<SpritePlayer>& players,
std::vector<boost::shared_ptr<SpriteBall>> balls
)
{
std::vector<SpriteMoving*> v;
for(boost::shared_ptr<SpritePlayer> i: players)
for(auto& i: players)
{
assert(i);
SpriteMoving * const s = i.get();
SpriteMoving * const s = &i;
assert(s);
v.push_back(s);
}
Expand All @@ -101,16 +104,15 @@ const std::vector<ribi::bnkn::SpriteMoving*> ribi::bnkn::Game::CollectMovingSpri
return v;
}

const std::vector<ribi::bnkn::Sprite*> ribi::bnkn::Game::CollectSprites(
std::vector<boost::shared_ptr<SpritePlayer > > players,
std::vector<ribi::bnkn::Sprite*> ribi::bnkn::Game::CollectSprites(
std::vector<SpritePlayer>& players,
std::vector<boost::shared_ptr<SpriteBall > > balls,
std::vector<boost::shared_ptr<SpriteNonMoving> > obstacles)
{
std::vector<Sprite*> v;
for(boost::shared_ptr<SpritePlayer> i: players)
for(auto& i: players)
{
assert(i);
Sprite * const s = i.get();
Sprite * const s = &i;
assert(s);
v.push_back(s);
}
Expand Down Expand Up @@ -160,32 +162,8 @@ void ribi::bnkn::Game::pressKey(const int key)
const std::size_t n_players = m_controls.m_names.size();
for (std::size_t i=0; i!=n_players; ++i)
{
if (key == m_controls.m_keys_accel[i]) m_players[i]->Accelerate();
if (key == m_controls.m_keys_turn[i] ) m_players[i]->TurnRight();
}
switch (key)
{
///F1 is the debugging key
///F2 is the debugging key, after which there is a quit
case Qt::Key_F1:
case Qt::Key_F2:
{
//std::clog << "Player coordinats:\n";
//BOOST_FOREACH(boost::shared_ptr<SpritePlayer>& s,m_players)
{
//std::clog << s.get() << ": (" << s->getX() << "," << s->getY() << ")\n";
}
//std::clog << "Ball coordinats:\n";
//BOOST_FOREACH(boost::shared_ptr<SpriteBall>& s,m_balls)
{
//std::clog << s.get() << ": (" << s->getX() << "," << s->getY() << ")\n";
}
//std::clog << "Moving sprite coordinats (must match above):\n";
//BOOST_FOREACH(SpriteMoving * s,m_moving_sprites)
{
//std::clog << s << ": (" << s->getX() << "," << s->getY() << ")\n";
}
}
if (key == m_controls.m_keys_accel[i]) m_players[i].Accelerate();
if (key == m_controls.m_keys_turn[i] ) m_players[i].TurnRight();
}
if (key == Qt::Key_F2) std::exit(1);
}
Expand Down
Loading

0 comments on commit 34c5057

Please sign in to comment.