mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 11:22:45 +01:00
Improve test state
* Move test spawn to the parking garage * Add --test option to start a new testing session * Add information about camera position to DebugState
This commit is contained in:
parent
1d3bcfe42b
commit
a54e4a384e
@ -32,6 +32,7 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
|||||||
size_t w = GAME_WINDOW_WIDTH, h = GAME_WINDOW_HEIGHT;
|
size_t w = GAME_WINDOW_WIDTH, h = GAME_WINDOW_HEIGHT;
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
bool newgame = false;
|
bool newgame = false;
|
||||||
|
bool test = false;
|
||||||
bool debugscript = false;
|
bool debugscript = false;
|
||||||
|
|
||||||
for( int i = 1; i < argc; ++i )
|
for( int i = 1; i < argc; ++i )
|
||||||
@ -52,6 +53,10 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
newgame = true;
|
newgame = true;
|
||||||
}
|
}
|
||||||
|
if( strcmp( "--test", argv[i] ) == 0 )
|
||||||
|
{
|
||||||
|
test = true;
|
||||||
|
}
|
||||||
if( strcmp( "--debug", argv[i] ) == 0 )
|
if( strcmp( "--debug", argv[i] ) == 0 )
|
||||||
{
|
{
|
||||||
debugscript = true;
|
debugscript = true;
|
||||||
@ -123,7 +128,7 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
|||||||
auto loading = new LoadingState(this);
|
auto loading = new LoadingState(this);
|
||||||
if( newgame )
|
if( newgame )
|
||||||
{
|
{
|
||||||
loading->setNextState(new IngameState(this));
|
loading->setNextState(new IngameState(this,test));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <ai/PlayerController.hpp>
|
#include <ai/PlayerController.hpp>
|
||||||
#include <objects/CharacterObject.hpp>
|
#include <objects/CharacterObject.hpp>
|
||||||
#include <objects/VehicleObject.hpp>
|
#include <objects/VehicleObject.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
void jumpCharacter(RWGame* game, CharacterController* controller, const glm::vec3& target)
|
void jumpCharacter(RWGame* game, CharacterController* controller, const glm::vec3& target)
|
||||||
{
|
{
|
||||||
@ -155,6 +157,22 @@ void DebugState::tick(float dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugState::draw(GameRenderer* r)
|
||||||
|
{
|
||||||
|
// Draw useful information like camera position.
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Camera Position: " << glm::to_string(_debugCam.position);
|
||||||
|
|
||||||
|
TextRenderer::TextInfo ti;
|
||||||
|
ti.text = ss.str();
|
||||||
|
ti.font = 2;
|
||||||
|
ti.screenPosition = glm::vec2( 10.f, 10.f );
|
||||||
|
ti.size = 15.f;
|
||||||
|
r->text.renderText(ti);
|
||||||
|
|
||||||
|
State::draw(r);
|
||||||
|
}
|
||||||
|
|
||||||
void DebugState::handleEvent(const sf::Event &e)
|
void DebugState::handleEvent(const sf::Event &e)
|
||||||
{
|
{
|
||||||
switch(e.type) {
|
switch(e.type) {
|
||||||
|
@ -17,6 +17,7 @@ public:
|
|||||||
virtual void exit();
|
virtual void exit();
|
||||||
|
|
||||||
virtual void tick(float dt);
|
virtual void tick(float dt);
|
||||||
|
virtual void draw(GameRenderer* r);
|
||||||
|
|
||||||
virtual void handleEvent(const sf::Event& event);
|
virtual void handleEvent(const sf::Event& event);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ IngameState::IngameState(RWGame* game, bool test)
|
|||||||
|
|
||||||
void IngameState::startTest()
|
void IngameState::startTest()
|
||||||
{
|
{
|
||||||
auto playerChar = getWorld()->createPedestrian(1, {-1000.f, -990.f, 13.f});
|
auto playerChar = getWorld()->createPedestrian(1, {270.f, -605.f, 40.f});
|
||||||
auto player = new PlayerController(playerChar);
|
auto player = new PlayerController(playerChar);
|
||||||
|
|
||||||
getWorld()->state.player = player;
|
getWorld()->state.player = player;
|
||||||
@ -31,7 +31,7 @@ void IngameState::startTest()
|
|||||||
_playerCharacter->addToInventory(bat);
|
_playerCharacter->addToInventory(bat);
|
||||||
_playerCharacter->setActiveItem(bat->getInventorySlot());*/
|
_playerCharacter->setActiveItem(bat->getInventorySlot());*/
|
||||||
|
|
||||||
glm::vec3 itemspawn(-1000.f, -980.f, 11.0f);
|
glm::vec3 itemspawn( 276.5f, -609.f, 36.5f);
|
||||||
for( auto& w : getWorld()->gameData.weaponData ) {
|
for( auto& w : getWorld()->gameData.weaponData ) {
|
||||||
if( w.first == "unarmed" ) continue;
|
if( w.first == "unarmed" ) continue;
|
||||||
getWorld()->objects.insert(new ItemPickup(getWorld(), itemspawn,
|
getWorld()->objects.insert(new ItemPickup(getWorld(), itemspawn,
|
||||||
@ -39,8 +39,10 @@ void IngameState::startTest()
|
|||||||
itemspawn.x += 2.5f;
|
itemspawn.x += 2.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto carPos = glm::vec3( -1000.f, -1000.f, 12.f );
|
auto carPos = glm::vec3( 286.f, -591.f, 37.f );
|
||||||
auto boatPos = glm::vec3( -1000.f, -1040.f, 5.f );
|
auto carRot = glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 0.f, 1.f));
|
||||||
|
//auto boatPos = glm::vec3( -1000.f, -1040.f, 5.f );
|
||||||
|
int i = 0;
|
||||||
for( auto& vi : getWorld()->objectTypes ) {
|
for( auto& vi : getWorld()->objectTypes ) {
|
||||||
switch( vi.first ) {
|
switch( vi.first ) {
|
||||||
case 140: continue;
|
case 140: continue;
|
||||||
@ -48,21 +50,14 @@ void IngameState::startTest()
|
|||||||
}
|
}
|
||||||
if( vi.second->class_type == ObjectInformation::_class("CARS") )
|
if( vi.second->class_type == ObjectInformation::_class("CARS") )
|
||||||
{
|
{
|
||||||
|
if ( i++ > 20 ) break;
|
||||||
auto vehicle = std::static_pointer_cast<VehicleData>(vi.second);
|
auto vehicle = std::static_pointer_cast<VehicleData>(vi.second);
|
||||||
|
|
||||||
auto sp = carPos;
|
auto& sp = carPos;
|
||||||
if( vehicle->type == VehicleData::BOAT ) {
|
auto& sr = carRot;
|
||||||
sp = boatPos;
|
auto v = getWorld()->createVehicle(vi.first, sp, sr);
|
||||||
}
|
|
||||||
|
|
||||||
auto v = getWorld()->createVehicle(vi.first, sp, glm::quat());
|
sp += sr * glm::vec3( 2.f + v->info->handling.dimensions.x, 0.f, 0.f);
|
||||||
|
|
||||||
if( vehicle->type == VehicleData::BOAT ) {
|
|
||||||
boatPos -= glm::vec3( 2.f + v->info->handling.dimensions.x, 0.f, 0.f);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
carPos -= glm::vec3( 2.f + v->info->handling.dimensions.x, 0.f, 0.f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user