Jump to content

tipforeveryone

Members
  • Content Count

    374
  • Joined

  • Last visited

Posts posted by tipforeveryone


  1. Thanks guys, by I figure out the best way to get the goal.

    1. Only create model of whole structure

    2 Create another version with only basic shapes the use it as physic mesh

    3. Create other elements of building as sperated models with their own physic mesh

    4. Put them together. Here is the result

     


  2. I have a plan to put a building into game, I wonder which is the best way to do that, I thinkabout some solutions but doubt about physics performance as well

    1. Import a whole building model in blender (rooms, walls, stairs, roof etc), then create a physic mesh to apply to it. my character will move around inside the building with its physic mesh.

    image.png.bfb9f70ec0d1714a03cc12e2bb4d4a28.pngimage.png.67299b4246807efd0e35543a9bc9f5e7.png

    2. Create each elements of building in blender (stairs, walls, columns, roof as sperated meshes), import into game, reposition those elements to construct whole building, each element has it own physic mesh

    3. Import whole building model then use premitive shape to construct the building's physic. I will assign invisible material on those shapes to hide them later.


  3. 9 minutes ago, Josh said:

    There is nothing I see there that would cause any slowdown in C++ or even in Lua, with 20 enemies.

    Hmm.. I found out the problem is not Time functions stuff, it is Point() and AllignToAxis() which I used to make character model turn to player position. are they expensive ?


  4. Situation: I have 20 enemy characters in a map. 

    Goal: Everytime I fire a weapon, some of enemy who are in range from my position can hear and reaction after a small period of time (ex: 2 seconds - 2000ms)

    Current solution:

    • Each fire shot calls a function Gun_Sound(), this function will scan all enemy character and if in range, call character's function Sound_Reaction()
    for (auto it = enemyList.begin(); it != enemyList.end(); it++){
      if ((*it)->GetDistance(myPosition) < range){
        (*it)->Sound_Reaction();
        (*it)->reactionActive = true;
        (*it)->timeMark = Time::GetCurrent();
      }
    }
    • To simulate "reaction" feature of character, I use this popular method
    //This function is put in UpdateWorld() of each Character Actor Class
    void Character::Sound_Reaction(){
      if (reactionActive){
        if (Time::GetCurrent() - timeMark > reactionDuration){ //reactionDuration can be 2000 for example
          reactionActive = false; //stop and finish reaction process
          //Do some code
        }
      }
    }

    Problem: iterating through characterList each shot is ok, but each time I fire weapon, that Sound_Reaction() with Time calculation stuff drops my FPS dramaticaly. As my expectation, I don't think it can make FPS worse like this.

    Questions:

    1. Is there any better solution to scan enemy in range ? I wonder if I have more enemy (50?), must I iterate through all of them each time I shoot to collect in-range one?
    2. Is there any better solution for character reaction ? depend on time like I need

  5. I use ifstream to read a file which I used to save some configuration data

    ifstream weaponData("Data/Weapons.dat");
    	while (weaponData >> configVariable1 >> configVariable2 > ...){
        	//Some code
    	}

    I included *.dat files in to publish process and I got them in data.zip succesfully.

    But it seems published game can not read those files. But if I create a same folder structure outside zipped package, my game can read it normally

    How can I use ifstream to read files in zipped package ?


  6. I have this code

    std::vector<Texture*> spriteSequences;
    for (int i = 1; i <= 20; i++)
    {
    	Texture* texture = nullptr;
    	texture = Texture::Load(folderPath + "/" + String(i) + ".tex");
    	spriteSequences.push_back(texture);
    }

    in Destructor of my class

    MyClass::~MyClass()
    {
      delete[] spriteSequences; //this is not working
    }

    How can I delete a vector of Pointer ?


  7. I created my project in cpp from scratch, and here is the code I used in main.cpp

    #include "Leadwerks.h"
    #include "GameControl.h"
    using namespace Leadwerks;
    
    int main()
    {	
    	iVec2 gfxmode = System::GetGraphicsMode(System::CountGraphicsModes() - 1);
    	gfxmode.x = Math::Min(700, gfxmode.x);
    	gfxmode.y = Math::Round(gfxmode.x * 9 / 16);
    
    	Window* window = Window::Create("CSCDVMP cpp", 600, 600, gfxmode.x, gfxmode.y, Window::Titlebar);
    	Context* context = Context::Create(window, 0);
    	World* world = World::Create();
    	
    	Pivot* gameControl = Pivot::Create();
    	GameControl* actor = new GameControl(); //this actor has PostRender() which I used to draw image
    	gameControl->SetActor(actor);
    
    	while (true)
    	{
    		if (window->Closed() || window->KeyDown(Key::Escape)) return false;
    		Time::Update();
    		world->Update();
    		world->Render();
    		context->Sync();
    	}
    	return 0;
    }

    In PostRender() function of my actor

    Context::GetCurrent()->DrawImage(
      myimage,
      Window::GetCurrent()->GetWidth() - myimage->GetWidth(),
      0,
      myimage->GetWidth(),
      myimage->GetHeight()
    );

    as my expectation, myimage will be displayed on the top right corner of screen, but this look like this instead

    image.png.ef84ba5ba3dc510af677481bdb770cfe.png

    window size seems to be larger than actual game display. It is ok if I use Window::FullScreen in Window::Create()


  8. I put some Pivots in Editor around my map and attach a script to each of them, here is the script

    function Script:Start()
      self.entity:SetKeyValue("type","spawnPosition")
    end

    In spawn.php

    //#include <iostream> was on top
    //#include <list> was on top
    
    std::list<Entity> spawnPosition;
    
    for (int x = 0; x < world->CountEntities(); x++)
    {
      Entity* entity = world->GetEntity(x);
      if (entity->GetKeyValue("type") == "spawnPosition")
      {
        spawnPosition.push_back(entity);
      }
    }

    and I got this error

    Severity    Code    Description    Project    File    Line    Suppression State
    Error    C2664    'void std::list<int,std::allocator<_Ty>>::push_back(const _Ty &)': cannot convert argument 1 from 'Leadwerks::Entity *' to '_Ty &&'    CSCDVMP    d:\google drive\w3ateam\game development\cscdvmp\projects\windows\playerclass.cpp    160    
     

    what is the right way?

    • Sad 1

  9. On 5/7/2019 at 1:54 PM, Lethal Raptor Games said:

    Isn't it supposed to be self.entity?  You are creating a new variable called myEntity and setting it to nil, no where is it being assigned the entity the script belongs too.

    He put "Sol" entity to the input, this is really weird. What is that Sol object ? a pivot ?

    • Like 1
×
×
  • Create New...