Jump to content

Yue

Members
  • Posts

    2,291
  • Joined

  • Last visited

Posts posted by Yue

  1. 8 hours ago, Alienhead said:

    Try calling collectgarbage(), right after you resume the time.  See if it returns to the value it was at when you called a time:pause.

            HideMenuStart();
            Time::Resume();
            collectgarbage();

    It sorta looks like to me you continuously calling 

    		ShowMenuStart();
    		Time::Pause();

    Is ShowMenuStart() loading or creating anything each time it's called?

    o.O??
    image.thumb.png.76cd97bd67d0db429fc37e0193a6c634.png

     

    1>------ Operación Compilar iniciada: proyecto: AstrocucoX, configuración: Release Win32 ------
    1>cl : Línea de comandos warning D9035: La opción 'Gm' está desusada y se quitará en próximas versiones
    1>cl : Línea de comandos warning D9030: '/Gm' es incompatible con el multiprocesamiento; se omitirá el modificador /MP
    1>CGUI.cpp
    1>f:\leadwerks\projects\astrocucox\source\cgui.cpp(51): error C3861: 'collectgarbage': no se encontró el identificador
    1>Generando código...
    1>Compilando...
    1>CInput.cpp
    1>Generando código...
    1>Omitiendo... (no se detectaron cambios relevantes)
    1>main.cpp
    1>CWorld.cpp
    1>CWindow.cpp
    1>CRover.cpp
    1>CPlayer.cpp
    1>Compilación del proyecto "AstrocucoX.vcxproj" terminada -- ERROR.
    ========== Compilar: 0 correctos, 1 incorrectos, 0 actualizados, 0 omitidos ==========

     

  2. void CGUI::Update()
    {
    	//HideMenuStart(); << Solved temporal.
    
    	
    
    	if (show)
    	{
    		ShowMenuStart();
    		Time::Pause();
    	}
    	else
    	{
    		HideMenuStart();
    		Time::Resume();
    	}
    
    	if (input.GetKeyHit(Key::Escape))
    	{
    		show = 1 - show;
    
    	}
    
    
    
    }

     

    This partially solves the problem. When I uncomment that line of code it no longer uploads the memory when the game is paused. 

    What happens now is that it goes up a little, for each time I make visible the start menu of the three buttons, the memory usage in C++ and in Script goes up. If someone has any idea why this happens I would appreciate it, or if it is something normal.

     

  3.  

    I only have a terrain, a directional light, the character and the vehicle.  The code is structured in the Input object, Player object, Rover object, Windows object.

    But the strange thing is that it only happens when I pause the game and show the menu. Time::Pause().


     

    //Code Main. 
    
    #include "App.h"
    
    using namespace Leadwerks;
    
    
    
    
    int main()
    {
    	CWindow window("App Title", 1280, 720);
    	
    	CWorld menu;
    	menu.LoadMap("Menu.map");
    	CInput input;
    	CRover rover(input);
    	CGUI  gui(input);
    	CPlayer player(input,rover,gui);
    	
    	
    
    	// Bucle principal.
    	while (!window.GetClosed())
    	{
    		
    		if (input.GetKeyDown(Key::H))
    		{
    			return 0;
    		}
    
    		
    		Time::Update();
    		gui.Update();
    		menu.Update();
    		menu.Render();
    		
    		player.Update();
    		rover.Update();
    
    		window.ShowDebugInfo();
    		player.DrawHand(window.GetContext());
    		window.Update(false);
    
    		
    	}
    
    	return 0;
    }

    GUI Show HIde Menu. 

    #include "CGUI.h"
    
    using namespace Leadwerks;
    
    // Constructor.
    CGUI::CGUI(CInput& input)
    	:input(input)
    
    {
    	
    
    	window = Window::GetCurrent();
        context = Context::GetCurrent();
    	gui = GUI::Create(context);
    	base = gui->GetBase();
    
    
    
    	StartHUD();
    	StartMenu();
    	show = 0;
    }
    
    void CGUI::StartHUD()
    {
    
    	Widget* pnlHud = Widget::Panel(window->GetWidth() - 230, 10, 200, 100, base);
    
    }
    
    void CGUI::StartMenu()
    {
    	 pnlMenu = Widget::Panel(window->GetWidth()/2-250, window->GetHeight()-150, 500, 75, base);
    
    	// Butons.
    	btnStart   = Widget::Button("START", 10, 15, 150, 50, pnlMenu);
    	btnOptions = Widget::Button("OPTIONS", pnlMenu->GetSize(true).x/2-75,15,150,50,pnlMenu);
    	btnExit = Widget::Button("EXIT", pnlMenu->GetSize(true).x -160, 15, 150, 50, pnlMenu);
    	
    }
    
    void CGUI::HideMenuStart()
    {
    	pnlMenu->Hide();
    
    }
    
    void CGUI::ShowMenuStart()
    {
    
    	pnlMenu->Show();
    }
    
    
    void CGUI::Update()
    {
    	HideMenuStart();
    
    	
    
    	if (show)
    	{
    		ShowMenuStart();
    		Time::Pause();
    	}
    	else
    	{
    		HideMenuStart();
    		Time::Resume();
    	}
    
    	if (input.GetKeyHit(Key::Escape))
    	{
    		show = 1 - show;
    
    	}
    
    
    
    }
    
    bool CGUI::GetShow()
    {
    
    	return(show);
    }

     

     

  4. Memory remains where it was last time.  For example, if the game is paused, it goes up in value, but when you continue the game, it stays at the last value. If it was for example in 100, it goes up continuously until I continue the game, and it remains in for example in 500, if I pause it again it continues going up.

  5.  

    Well, dabbling in C++, the results delight me in terms of performance, and focused on optimizing my code, I have to say I thought I would never do things in c++, and in relation to Lua, I feel like I'm a real programmer. xD

    Sure, the process is slower, the compile times a bit longer, it's just habit, but the performance is encouraging. Besides learning new concepts of classes, constructors, destructors, pointers, all this in coordination with ChatGPT is going slowly but with good results.

     

    image.thumb.png.579a2ddd93f14c2296fa4921de1f08b4.png

    • Like 3
  6. 5 hours ago, WazMeister said:

    How odd, the command win:GetKeyDown...

    I used that and get errors, it does not reference win or GetKeyDown in the documentation either..

    Where does that come from?

     

    It is my coding, lua script is not oriented to the object programming paradigm (Poo), however it can be used without any problem to organize the code. Ç

    In other words win is a custom object, and instead of using KeyDown, the identifier encapsulates this with a GetKeyDown. But internally it is KeyHit, the most readable would be to call it Input.

     

  7. I hope this gives you an idea.

     

    CMove={
    	
    
    	-- Constructor.
    	Create = function(self,player,camera)
    		local this={}
    		setmetatable(this,self)
    		self.__index = self
    
    			function this:Init()
    				self.camera = camera
    				self.player = player
    				self.vel    = 0
    				self.angle = 0
    				
    			
    			end
    
    
    			function this:Update(startEngine)
    				self.vel = 0
    				if startEngine == false then 
    
    					self.player:SetPhysicsMode(Entity.CharacterPhysics)
    					self.player:SetCollisionType(Collision.Character)
    					self.player:SetMass(200)
    					
    
    					if win:GetKeyDown(Key.Shift) == false then 
    						if 	win:GetKeyDown(Key.W) then 
    							self.vel = -1.2
    							self.angle = self.camera:GetRotation(true).y  - 180
    							
    						elseif win:GetKeyDown(Key.S) then 
    							self.vel = -1.2
    							self.angle = self.camera:GetRotation(true).y 
    						
    						end
    					else
    						if 	win:GetKeyDown(Key.W) then 
    							self.vel = -3.0
    							self.angle = self.camera:GetRotation(true).y  - 180
    							
    						elseif win:GetKeyDown(Key.S) then 
    							self.vel = -3.0
    							self.angle = self.camera:GetRotation(true).y 
    						
    						end
    					end
    
    					self.rotCamera = self.camera:GetRotation(true).y
    					self.player:SetInput(self.angle, self.vel, 0, 0,false)
    
    				else 
    					self.player:SetPhysicsMode(Entity.RigidBodyPhysics)
    					self.player:SetMass(0)
    					self.player:SetCollisionType(Collision.None)
    					self.player:StopAnimation()
    				end
    
    			end
    
    
    	
    
    			
    			
    		
    		this:Init()
    		return(this)
    	end
    
    }

     

  8. 	if (World::GetCurrent()->Pick(0, 0, 0, 0, 0, 0, pickinfo, true))
    	{
    
    
    	}

    The pick for the world is not working. Any suggestions, in c++ it underlines something in red and I don't understand.

     

    image.thumb.png.5e8bf4ebf18be39b1e8baeef6455166c.png

  9. 16 minutes ago, SpiderPig said:

    Encontré C++ en Leadwerks mucho más rápido que Lua. Si estás haciendo un juego pequeño, entonces Lua está bien y es mucho más rápido para obtener resultados. Pero si quiere un gran mundo abierto, entonces C++ será más rápido y le dará más acceso a los comandos subyacentes en Leadwerks. Es C++ todo el camino para mí. 😎

    You're absolutely right, I think for me it's a breakthrough, I'm taking a leap that initially I never thought to do it, moving to C++ is a milestone. And everything I have learned in lua, is not in the trash can. The weird thing in C++ is the compile times, but this is more because in Lua this was flying. On the other hand, it is necessary to go slower in the coding, in my case, because I am learning things like -> or to put a semicolon if not everything does not compile. But it's really fun.

     

    • Like 1
  10. This is encouraging, the performance if I am looking at it. In this scene in Lua the performance was down to 150 frames per second. It is a character controller, and I have to assume because I manage it from C++ code and not from the map editor and lua script.

    Rendimiento.thumb.jpg.142f3b4b113a3ab076db633142a79acf.jpg

  11. 12 hours ago, SpiderPig said:

    Sí, depende en gran medida del alcance del juego que construyas.

     

    An open world full of rocks on mars I think would be a good approach to move to C++, however I will do some more testing in C++ to see how this goes. 

    But it is really exciting for me to understand c++ with the basics I have learned while programming in Lua.

     

    • Like 2
  12. 13 hours ago, aiaf said:

    I think you should continue with lua and finish the game.

    One disadvantage of c++ can be the  build times.

    You will be much faster to experiment in game with lua.

    Depends on what is your goal.

    I think you are absolutely right, since I know this I have focused more on learning things and the strange thing is that with what I have learned in Lua, I feel that the step to C++ is not so complicated and I find it epic to program in C++. In the end the project is not very advanced, it is like a pre-alpha. And if the compilation times are tedious especially when I come from environments like Lua, or blitzbasic products, but for me it is still something exciting to learn new things. 

    • Like 2
  13. I have a better load of frames per second, going from 220 to almost 300, and a better render time in a simple scene.

    This makes me feel like a programmer, everything I learned with Lua is here.

    #include "App.h"
    #include "CWindow.h"
    
    using namespace Leadwerks;
    
    int main(int argc, const char* argv[])
    {
    	CWindow window(800, 600);
    
    	Context* context = Context::Create(window.Get());
    	World* menu = World::Create();
    
    	Camera* camera = Camera::Create();
    	Model* cube = Model::Box();
    	Light* sun = DirectionalLight::Create();
    	cube->SetPosition(0, 0, 3);
    
    	while (!window.Get()->Closed())
    	{
    		cube->Turn(0, 1 * Time::GetSpeed(), 0);
    		Time::Update();
    		menu->Update();
    		menu->Render();
    		context->DrawStats(0, 0);
    		context->Sync(false);
    	}
    
    	return 0;
    }

     

    FPS.png

    • Like 1
×
×
  • Create New...