Skip to content

Commit

Permalink
Fixed includes and some whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomatower committed Feb 18, 2017
1 parent c492807 commit 843521d
Show file tree
Hide file tree
Showing 30 changed files with 196 additions and 421 deletions.
1 change: 1 addition & 0 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Dependency list:
CRA python >=3.4
C cython >=0.23
C cmake >=3.1.0
CR ncurses
A numpy
A python imaging library (PIL) -> pillow
CR opengl >=2.1
Expand Down
4 changes: 4 additions & 0 deletions libopenage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ find_package(Opusfile REQUIRED)
find_package(Epoxy REQUIRED)
find_package(HarfBuzz 1.0.0 REQUIRED)

set(CURSES_NEED_NCURSES TRUE)
find_package(Curses REQUIRED)

set(QT_VERSION_REQ "5.5")
find_package(Qt5Core ${QT_VERSION_REQ} REQUIRED)
find_package(Qt5Quick ${QT_VERSION_REQ} REQUIRED)
Expand Down Expand Up @@ -175,6 +178,7 @@ target_link_libraries(libopenage
${SDL2_LIBRARY}
${UTIL_LIB}
${HarfBuzz_LIBRARIES}
${CURSES_LIBRARIES}
# TODO: change to PUBLIC (or, alternatively, remove all keywords
# of this type) when qt cmake scripts change declarations of the
# IMPORTED libraries to GLOBAL.
Expand Down
4 changes: 1 addition & 3 deletions libopenage/tubes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

add_library(tube STATIC
add_sources(libopenage
base.cpp
container_iterator.cpp
event.cpp
Expand All @@ -13,7 +13,5 @@ add_library(tube STATIC
unordered_map.cpp
)

set_property(TARGET tube PROPERTY CXX_STANDARD 11)

add_subdirectory(test)
add_subdirectory(demo)
2 changes: 0 additions & 2 deletions libopenage/tubes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
An experiment how one can work with tubes and predictionmagic in a stateless physical game engine.

This is a Pong-like game build on top of tubes.


1 change: 0 additions & 1 deletion libopenage/tubes/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ namespace openage {
namespace tube {

}} // openage::tube

20 changes: 10 additions & 10 deletions libopenage/tubes/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ class tubebase {
};

/**
* A element of the double-linked list tubebase
>* A element of the double-linked list tubebase
*/
template <typename _T>
class tubeelement {
friend class tubebase<_T>;
friend class tubebase<_T>;
public:
tubeelement *next = nullptr;
tubeelement *prev = nullptr;
private:
// These folks are for tubebase only!
tubeelement(const tube_time_t &time) :
time(time)
{}
tubeelement(const tube_time_t &time)
:
time(time) {}

// Contruct it from time and value
tubeelement(const tube_time_t &time, const _T &value) :
time(time),
value(value)
{}
{}

public:
const tube_time_t time = 0;
Expand Down Expand Up @@ -106,7 +106,7 @@ tubeelement<_T> *tubebase<_T>::last(const tube_time_t &time, tubeelement<_T> *hi
return e;
}

if (begin->time > time){
if (begin->time > time) {
// This will never happen due to the begin->time == -Inf magic!
assert(false);
return nullptr;
Expand All @@ -127,7 +127,7 @@ tubeelement<_T> *tubebase<_T>::last(const tube_time_t &time, tubeelement<_T> *hi
while (e->prev != nullptr && time < e->time) {
e = e->prev;
}
// e is now one of two options:
// e is now one of two options:
// 1. e == begin: The time was before every element in the queue
// 2. e != begin: There was an element with `e->time` > `time`
}
Expand Down Expand Up @@ -196,7 +196,7 @@ void tubebase<_T>::erase_after(tubeelement<_T> *last_valid) {
}
}

/**
/**
* Delete the element from the list and call delete on it.
*/
template <typename _T>
Expand All @@ -215,7 +215,7 @@ void tubebase<_T>::erase(tubeelement<_T> *e) {
if (e->prev != nullptr) {
e->prev->next = e->next;
}

delete e; // TODO Memory management magic!
}

Expand Down
1 change: 0 additions & 1 deletion libopenage/tubes/container_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ namespace openage {
namespace tube {

}} // openage::tube

25 changes: 6 additions & 19 deletions libopenage/tubes/demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses)

IF (${CURSES_FOUND})

include_directories(${CURSES_INCLUDE_DIR})
link_libraries (tube ${CURSES_LIBRARIES})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -pedantic -Wall -Wextra")
add_executable (tubepong
main.cpp
physics.cpp
gui.cpp
aicontroller.cpp
)

set_property(TARGET tubepong PROPERTY CXX_STANDARD 14)
ENDIF()

add_sources (libopenage
main.cpp
physics.cpp
gui.cpp
aicontroller.cpp
)
8 changes: 5 additions & 3 deletions libopenage/tubes/demo/aicontroller.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2015-2017 the openage authors. See copying.md for legal info.

#include "aicontroller.h"

namespace openage {
Expand All @@ -8,12 +10,12 @@ std::vector<event> &AIInput::getInputs(
const PongBall &ball,
const tube::tube_time_t &now) {
this->event_cache.clear();

auto position = player.position.get(now);

// Yes i know, there is /3 used - instead of the logical /2 - this is to
// Yes i know, there is /3 used - instead of the logical /2 - this is to
// create a small safety boundary of 1/3 for enhanced fancyness

// Ball is below position
if (ball.position.get(now)[1] > position + player.size.get(now) / 3) {
event_cache.push_back(event(player.id, event::DOWN));
Expand Down
2 changes: 2 additions & 0 deletions libopenage/tubes/demo/aicontroller.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2017-2017 the openage authors. See copying.md for legal info.

#pragma once

#include <vector>
Expand Down
10 changes: 6 additions & 4 deletions libopenage/tubes/demo/gamestate.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright 2015-2017 the openage authors. See copying.md for legal info.

#pragma once


#include "../simple_continuous.h"
#include "../simple_discrete.h"
#include "../object.h"
#include "vertex.h"
#include "../../util/vector.h"

namespace openage {
namespace tubepong {
Expand Down Expand Up @@ -41,8 +43,8 @@ class PongPlayer : public tube::TubeObject {

class PongBall : public tube::TubeObject {
public:
tube::SimpleDiscrete<util::vertex<2, float>> speed;
tube::SimpleContinuous<util::vertex<2, float>> position;
tube::SimpleDiscrete<util::Vector<2>> speed;
tube::SimpleContinuous<util::Vector<2>> position;
};

class PongState {
Expand All @@ -52,7 +54,7 @@ class PongState {

PongBall ball;

util::vertex<2, float> resolution;
util::Vector<2> resolution;
};

}} // openage::tubepong
Loading

0 comments on commit 843521d

Please sign in to comment.