Jump to content

C++ vs Lua


Go to solution Solved by Josh,

Recommended Posts

Posted

Thinking about my project, it seems that I am evaluating to try it in C++, because of the performance. Do you really advise me to do that? 

 

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

  • Solution
Posted

In Leadwerks, C++ will probably be a bit faster. In Ultra, it probably won't make any difference because all your game logic runs on its own thread.

  • Like 1
  • Upvote 1

Let's build cool stuff and have fun. :)

Posted

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

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted
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

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted
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

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

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

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

I found C++ in Leadwerks a lot faster than Lua.  If your making a small game then Lua is fine and a lot quicker to get results.  But if you want a large open world then C++ will be faster and give you more access to underlying commands in Leadwerks.  It's C++ all the way for me. 😎

  • Like 1
Posted
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

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

The engine commands won't run any faster in C++ than in Lua. Physics and graphics will run at the same speed, it's just your own game code that executes faster.

  • Like 1
  • Upvote 2

Let's build cool stuff and have fun. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...