Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • NoHelp
  • architecture-refactoring
  • box2d
  • building
  • buildingFeatures
  • building_interaction
  • clang-tidy
  • clang-tidy-cleanup
  • cleanUpMenus
  • david-author
  • documentation
  • doxygen-cleanup
  • engine-scaling
  • helpMenu
  • interpolation
  • level-from-commandline
  • leveleditor
  • leveleditor-fix
  • leveleditor-placement
  • main
  • player
  • project-structure-refactoring
  • read-level
  • text-rendering
  • ui-components
  • uiInteraction/building
  • unit-branch
  • unit_contextmenu
  • unit_movement
  • units
  • units+xml
  • units2+xml
  • updated_unit_contextmenu
  • win_end_screen
  • xml
35 results

Target

Select target project
  • david.maul/cpp-project
1 result
Select Git revision
  • NoHelp
  • architecture-refactoring
  • box2d
  • building
  • buildingFeatures
  • building_interaction
  • clang-tidy
  • clang-tidy-cleanup
  • cleanUpMenus
  • david-author
  • documentation
  • doxygen-cleanup
  • engine-scaling
  • helpMenu
  • interpolation
  • level-from-commandline
  • leveleditor
  • leveleditor-fix
  • leveleditor-placement
  • main
  • player
  • project-structure-refactoring
  • read-level
  • text-rendering
  • ui-components
  • uiInteraction/building
  • unit-branch
  • unit_contextmenu
  • unit_movement
  • units
  • units+xml
  • units2+xml
  • updated_unit_contextmenu
  • win_end_screen
  • xml
35 results
Show changes

Commits on Source 9

......@@ -78,6 +78,8 @@ add_executable(advanced_wars ${ADVANCED_WARS_SOURCES})
set(CMAKE_MODULE_PATH ${ADVANCED_WARS_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH})
find_package(Qt6 REQUIRED COMPONENTS Widgets)
# Plattform-spezifische Konfiguration
if(APPLE)
# SDL2 Frameworks für macOS
......@@ -96,6 +98,7 @@ if(APPLE)
${SDL2_PATH}/SDL2.framework/SDL2
${SDL2_PATH}/SDL2_image.framework/SDL2_image
${SDL2_PATH}/SDL2_ttf.framework/SDL2_ttf
Qt6::Core
Boost::graph
box2d
)
......@@ -127,6 +130,7 @@ else()
target_link_libraries(advanced_wars
${HDF5_LIBRARIES}
Qt6::Core
-lSDL2
-lSDL2_image
-lSDL2_ttf
......@@ -138,7 +142,6 @@ endif()
# leveleditor
# Find Qt
find_package(Qt6 REQUIRED COMPONENTS Widgets)
file(GLOB_RECURSE LEVELEDITOR_SOURCES
"${PROJECT_SOURCE_DIR}/src/editor/*.cpp"
......
......@@ -40,7 +40,6 @@
<Weapons>
<PrimaryWeapon name="Bazooka">
<DamageTable>
<Damage unitId="recon" value="85"/>
<Damage unitId="apc" value="75"/>
<Damage unitId="anti_air_tank" value="65"/>
......@@ -50,7 +49,6 @@
<Damage unitId="artillery" value="70"/>
<Damage unitId="rocket_artillery" value="85"/>
<Damage unitId="anti_air_missile_launcher" value="85"/>
</DamageTable>
</PrimaryWeapon>
<SecondaryWeapon name="Machine-Gun">
......@@ -139,7 +137,6 @@
<Damage unitId="anti_air_missile_launcher" value="55"/>
<Damage unitId="transport_helicopter" value="105"/>
<Damage unitId="battle_helicopter" value="105"/>
<Damage unitId="stealth" value="75"/>
<Damage unitId="fighter" value="65"/>
<Damage unitId="bomber" value="75"/>
</DamageTable>
......@@ -244,7 +241,6 @@
<Weapons>
<PrimaryWeapon name="New Cannon">
<DamageTable>
<Damage unitId="recon" value="125"/>
<Damage unitId="apc" value="125"/>
<Damage unitId="anti_air_tank" value="115"/>
......@@ -254,7 +250,6 @@
<Damage unitId="artillery" value="115"/>
<Damage unitId="rocket_artillery" value="125"/>
<Damage unitId="anti_air_missile_launcher" value="125"/>
</DamageTable>
</PrimaryWeapon>
<SecondaryWeapon name="Machine-Gun">
......@@ -301,7 +296,6 @@
<Damage unitId="rocket_artillery" value="80"/>
<Damage unitId="anti_air_missile_launcher" value="80"/>
<Damage unitId="lander" value="55"/>
<Damage unitId="black_boat" value="55"/>
<Damage unitId="cruiser" value="50"/>
<Damage unitId="submarine" value="60"/>
<Damage unitId="battleship" value="40"/>
......@@ -334,7 +328,6 @@
<Damage unitId="rocket_artillery" value="85"/>
<Damage unitId="anti_air_missile_launcher" value="90"/>
<Damage unitId="lander" value="60"/>
<Damage unitId="black_boat" value="60"/>
<Damage unitId="cruiser" value="60"/>
<Damage unitId="submarine" value="85"/>
<Damage unitId="battleship" value="55"/>
......@@ -423,7 +416,6 @@
<PrimaryWeapon name="Torpedoes">
<DamageTable>
<Damage unitId="lander" value="95"/>
<Damage unitId="black_boat" value="95"/>
<Damage unitId="cruiser" value="25"/>
<Damage unitId="submarine" value="55"/>
<Damage unitId="battleship" value="55"/>
......@@ -456,7 +448,6 @@
<Damage unitId="rocket_artillery" value="85"/>
<Damage unitId="anti_air_missile_launcher" value="90"/>
<Damage unitId="lander" value="95"/>
<Damage unitId="black_boat" value="95"/>
<Damage unitId="cruiser" value="95"/>
<Damage unitId="submarine" value="95"/>
<Damage unitId="battleship" value="50"/>
......@@ -505,8 +496,6 @@
<DamageTable>
<Damage unitId="infantry" value="75"/>
<Damage unitId="mechanized_infantry" value="75"/>
</DamageTable>
</SecondaryWeapon>
</Weapons>
......@@ -526,7 +515,6 @@
<DamageTable>
<Damage unitId="transport_helicopter" value="100"/>
<Damage unitId="battle_helicopter" value="100"/>
<Damage unitId="fighter" value="55"/>
<Damage unitId="bomber" value="100"/>
</DamageTable>
......@@ -558,7 +546,6 @@
<Damage unitId="rocket_artillery" value="105"/>
<Damage unitId="anti_air_missile_launcher" value="105"/>
<Damage unitId="lander" value="95"/>
<Damage unitId="black_boat" value="95"/>
<Damage unitId="cruiser" value="85"/>
<Damage unitId="submarine" value="95"/>
<Damage unitId="battleship" value="75"/>
......
......@@ -82,22 +82,22 @@ std::shared_ptr<Level> Level::loadLevel(const std::string& path, Engine& engine)
// if level is smaler than 20x20 surround with water tiles
if (width < 20 || height < 20)
{
int w_start = (20 - width) / 2;
int h_start = (20 - height) / 2;
int x_start = (20 - width) / 2;
int y_start = (20 - height) / 2;
std::vector<uint8_t> transformed_tiles_array;
transformed_tiles_array.reserve(20 * 20);
for (int y = 0; y < 20; y++)
{
for (int x = 0; x < 20; x++)
{
if (x < w_start || y < h_start || x >= w_start + width || y >= h_start + height)
if (x < x_start || y < y_start || x >= x_start + width || y >= y_start + height)
{
transformed_tiles_array.push_back(1);
}
else
{
transformed_tiles_array.push_back(
level_tilesarray[x - w_start + (y - h_start) * width]);
level_tilesarray[x - x_start + (y - y_start) * width]);
}
}
}
......@@ -112,31 +112,31 @@ std::shared_ptr<Level> Level::loadLevel(const std::string& path, Engine& engine)
std::vector<Unit> units;
tiles.reserve(width * height);
bool has_factions[] = {false, false, false, false, false};
for (int i = 0; i < level_tilesarray.size(); i++)
for (size_t i = 0; i < level_tilesarray.size(); i++)
{
int x = i % width;
int y = i / width;
if (level_tilesarray[i] >= 50)
{
// tile id >= 50 -> building -> have to add Plain Tile and Building
tiles.push_back(Tile(TileId(TileId::PLAIN), x, y));
BuildingId building_id = static_cast<BuildingId>((level_tilesarray[i] - 50) % 5);
BuildingFaction faction_id =
static_cast<BuildingFaction>((level_tilesarray[i] - 50) / 5);
if (building_id == BuildingId::HEADQUARTER)
{
int index = static_cast<int>(faction_id);
if (!has_factions[index])
{
// an infantery unit should be added onto every HQ
units.push_back(Unit(
x, y, static_cast<UnitFaction>(faction_id), UnitId::INFANTERY,
UnitState::UNAVAILABLE, engine.getUnitConfig()));
}
has_factions[static_cast<int>(faction_id)] = true;
has_factions[static_cast<int>(faction_id)] = true; // collect existing factions
// for later building turnQ
}
buildings.push_back(Building(x, y, building_id, faction_id));
}
else
{
// if tile id belongs to terrain tile, just a tile needs to added
TileId tile_id = static_cast<TileId>(level_tilesarray[i]);
tiles.push_back(Tile(tile_id, x, y));
}
......@@ -155,7 +155,6 @@ std::shared_ptr<Level> Level::loadLevel(const std::string& path, Engine& engine)
Level level(name, width, height, tiles, buildings, units, std::vector<Effect>{}, turnQ);
level.m_turnQ.front().startTurn(level.m_units, level.m_buildings);
std::cout << "exiting" << std::endl;
return std::make_shared<Level>(level);
}
......@@ -728,7 +727,7 @@ void Level::handleSelectingEvents(Engine& engine, SDL_Event& event)
for (auto& [id, building] : m_buildings)
{
if (building.getXPosition() == u.getXPosition() &&
building.getXPosition() == u.getYPosition())
building.getYPosition() == u.getYPosition())
{
if (building.getFaction() !=
static_cast<BuildingFaction>(u.getFaction()))
......
......@@ -6,20 +6,49 @@
#include <SDL2/SDL.h>
#include <SDL_image.h>
#include <QCoreApplication>
#include <QCommandLineParser>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <vector>
#include <string>
#include <optional>
#include <filesystem>
using namespace advanced_wars;
std::optional<std::string> get_level_filepath(int argc, char* argv[])
{
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationVersion("1.0.0");
QCommandLineParser parser;
parser.addVersionOption();
parser.addHelpOption();
parser.setApplicationDescription("Advanced Wars is a multi player strategy game.\nCapture citys, build units and defeat your opponents. No mercy!");
parser.addPositionalArgument("path", "The path to the HDF5 level file from which the level should be loaded.", "<path>");
parser.process(app);
if (parser.positionalArguments().size() != 1)
{
std::cerr << "Command not recognized." << std::endl;
parser.showHelp();
return std::nullopt;
}
std::string filepath = parser.positionalArguments()[0].toStdString();
if (!std::filesystem::exists(filepath))
{
std::cerr << "The hdf5 level file path: '" << filepath <<"' does not exist." << std::endl;
return std::nullopt;
}
return parser.positionalArguments()[0].toStdString();
}
int main(int argc, char* argv[])
{
if (argc <= 1)
std::optional<std::string> level_filepath = get_level_filepath(argc, argv);
if (!level_filepath.has_value())
{
std::cerr << "Please provide the path to the level that you want to play as a command line "
"argument."
<< std::endl;
return 1;
}
......@@ -43,7 +72,7 @@ int main(int argc, char* argv[])
engine.setSpritesheet(spritesheet);
std::shared_ptr<Menu> menu = std::make_shared<Menu>(0, argv[1]);
std::shared_ptr<Menu> menu = std::make_shared<Menu>(0, level_filepath.value());
std::shared_ptr<ContextMenu> context_menu = std::make_shared<ContextMenu>();
context_menu->setOptions({"Move", "Info", "Wait"});
......