Jump to content

Recommended Posts

Posted

I didn't find , but perhaps would know if there is somewhere an example of minimal game framework in C++ or .Net ?

 

I mean :

From a created level in the editor with entites placed on it, call the code to manage each entity and the player ?

I mean code to manage a level a,d NPC created from the level editor.

Stop toying and make games

Posted

Maybe my Guess A Number game tutorial? It's in the community tutorial section.

In the final step I have added also FPS player movement, but i'm still polishing the game a bit before I release it.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

I agrre Guess a Number is a framework !

In fact i searched more for a tutorial where the game loads a level that contains NPC and that manages them.

A simple terrain with monsters at some places, when you are near they attack you, but only by loading the level , in fact with no creation of entities by code (liek Furious Franck demo) ,

but instead a program game that uses the entities already placed in the map level made with the editor !

Stop toying and make games

Posted

There are tutorials that load a level but not much more than that. It would be nice to have a mini adventure game with code available in something other than lua.Aint happened yet.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted

Lua makes a lot of that unnecessary. You can just load the scene and all Lua code for objects in the scene will be run.

 

As for AI and gameplay mechanics, that's up to the programmer to code for whatever kind of game they are making.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Thanks guys !

 

@ Engineer Ken :

like you said this is the closest tutorial for such games using level data and entitie placement !

It's standard game functionnality in fact, people place entities on the level editor and when you run the game they are managed by code.

Other indie engines uses script also to manage entities directly from world editor !

 

So from what i understood , i see two main solution :

Scripting :

- you just put Lua code on each entities when palcing them in the editor

Direct programming :

- You make the world and place entities

- by code you load the level, than by code you make some array containing all entities NPC on the level to manage them !

 

I think i'll take an Hybrid way for more performance :

Use of LUA than call to C++ Classes and functions for performance.

Now what can be put in the C++ part :

- Management of attributes: life , attack power , AI state and decision etc ... etc ... It's just parameters passed to a C++ method

- Can collision detection with others entities management be on a C++ class and called from Lua ? I 'm not sure caus it would require

to have a whole reference to the world and entities !

 

A last question :

IS Lua call to C++ fast or not ? Or it is better for few lines of code to saty in Lua instaed of calling C++ ?

Stop toying and make games

Posted

As I think you're discovering LE2 is more of a game engine API than an actual game engine. You need to write the game engine in order to bring life to the levels you design within the editor. Yes, Lua can be used for object level scripting and quite effectively. However, the Lua implementation will not talk natively to C++ classes and methods as Lua does not support that as of itself. You can either implement one of the many library solutions out there (Luabind, ToLua to name but a few) for doing this, or provide C Style function wrappers for the functions you want to interface with.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Guest Red Ocktober
Posted

what he said above... x 2

 

and like Josh said... if all you wanna do is load up a level and an actor... lua will pretty much do that for you when you put your scene together in the editor...

 

all you need do is call LoadScene() in your code...

 

a minimal c++ coded app that uses the framework to load a scene in 2.43 would look something like this...

 


//	====================================================================
//	This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard
//	Written by Rimfrost Software
//	http://www.rimfrost.com 
//	====================================================================

#include "engine.h"

int WINAPI WinMain( HINSTANCE hInstance,
				HINSTANCE hPrevInstance,
				LPSTR lpCmdLine,
				int nShowCmd ) 
{
Initialize() ;
RegisterAbstractPath("C:/Program Files/Leadwerks Engine SDK243");
SetAppTitle( "Minimal Scene Loading App" ) ;
Graphics( 800,600 ) ;
AFilter() ;
TFilter() ;

TWorld		world;
TBuffer		gbuffer;
TCamera		camera;
TMesh		mesh;
TLight		light;
TMesh		ground;
TMaterial	material;
TFramework  fw;
TLayer      layer;

fw=CreateFramework();
layer=GetFrameworkLayer(0);


// Set Lua framework object    and variables so that lua stuff
       // in the scene gets loaded   

SetGlobalObject( "fw", fw );                
BP lua = GetLuaState();        
lua_pushobject( lua, fw );        
lua_setglobal( lua, "fw" );        
lua_pop( lua, 1 );  

//  get the camera and position it
camera=GetLayerCamera(layer);
PositionEntity(camera,Vec3(0,18,-2));

      //  load your scene
TEntity scene = LoadScene("abstract::mynew.sbx");


//   mainloop
while( !AppTerminate() &&  !KeyHit() )        
{              

    if(KeyDown(KEY_A))TurnEntity(camera,Vec3(0,-1,0));
    if(KeyDown(KEY_D))TurnEntity(camera,Vec3(0,1,0));

		UpdateFramework();
		RenderFramework();

		// Send to screen
		Flip(0) ;

}

// Done

return Terminate() ;
}

 

 

this should be enough to load the entire scene, including any lua scripted actors...

 

hope this helped... good luck...

 

--Mike

Posted

Thanks Red Ocktober :

 

So that means if i have a village with NPC on it and some doing particular actions , and you can dialog with some and do actiosn with some others ....

I must put all tehm in the level editor, than screap for each particular NPC it's behaviour and AI in LUA.

Then in C++ for example i just load the level , and manage the player input and player character ?

 

If i have a game having different levels and towns, i presumei must have main ++ method to change levels according to player position or map button action,

 

So it's just for level loading ? all other stuff like NPC and ennemies will be driven by Lua Script that i will have put when editing the level ?

 

--------

 

I'll try that tommorow night so B)

Stop toying and make games

Posted

Your AI logic can be anywhere. C++, Lua, BMax, whatever. There is no right/wrong way to handle it sorta. Generally with complex AI you'd want the fastest means to run it so Lua generally won't be the best choice but if your AI is simple enough then Lua is fine. Don't want to get into another language war but in general that's the idea. I would say if you are starting out just use whatever language you feel the most comfortable with.

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...