Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About JoachimKlahr

  • Rank
  1. Hi, I have written a game engine which purpose is to power 2D games. The engine is written in C++ (even though some parts are written in Objective-C and Java since it runs on mobile devices), and it is very time consuming to design things like GUI and such. Add a button, start the game and realize that you have to move it a couple of pixels, shut down, make the fix, recompile and start again. You're probably familiar with the scenario and knows that it sucks. My solution to this is to make a simple editor. The editor will support an outline (SceneGraph) with its corresponding nodes and entities such as sprites and widgets. With this editor I will be able to add sprits to the scene and position them pretty fast with the mouse and text input fields. But since the entities shouldn't be plain dead I want to be able to add a script to each and every node and entity. I can see it in front of me where you add a sprite to the scene, right-click on it and clicks on "Add Script" where a text window appears and you can write your script. The scripting language I have begin implementing in my engine is Lua, and I have mapped some classes with tolua++ and it works fine. But now I'm stuck with some design issues... How should I design the Lua usage? My first idea was to have one script file for each and every node and entity I add to the scene. Those files would look something like this, with functions called from C++. function onCreate() end function onRender() end function onTick() end function onDestroy() end The problem is that I haven't ever worked with a game engine using a scripting language so I don't really know how people wants to work with it. So to my question. How do game engines usually utilize scripts and are there any good sites about this I should read? Also, is my initial approach something that sounds OK or what should I think about. Just need some help to get me started. Thanks for your time!
  2. JoachimKlahr

    tolua++ and namespaces

    Got it to work!This is what I did.Player.pkg$#include "Player.h"$using namespace MyNamespace;module MyNamespace{class Player { ...};}Then in the script I did like this:script.luaplayer = MyNamespace.Player:new()
  3. JoachimKlahr

    tolua++ and namespaces

    [font="arial, verdana, tahoma, sans-serif"]Hi, I'm about to implement Lua support into my engine, but have stumbled upon a little problem that hopefully is pretty simple to solve.[/font] I've been following this guide http://usefulgamedev...ua-example.html and it works without any issues. The problem is that all my engine classes is inside a namespace. So I tried to add a namespace around the Player class (in the example), and the files gets generated and the project still compiles. So to my question: How do I create an instance of MyNameSpace::Player class in Lua? #ifndef PLAYER_H #define PLAYER_H namespace MyNameSpace { // THIS IS ADDED BY ME! class Player { private: int health; public: Player(); ~Player(); void setHealth(int _health); int getHealth(); }; } #endif // PLAYER_H[font="arial, verdana, tahoma, sans-serif"] [/font][font="arial, verdana, tahoma, sans-serif"]How should this file look like after I've added the namespace?[/font][font="arial, verdana, tahoma, sans-serif"] [/font] -- Create new Player object and set health player = Player:new() player:setHealth(4) -- Display players health io.write("LUA: Player's health is "..player:getHealth());[font="arial, verdana, tahoma, sans-serif"] [/font][font="arial, verdana, tahoma, sans-serif"]Thanks for your help! [/font]
  4. JoachimKlahr

    Scripting library for C++ and C#

    I didn't stated that C++ and C# were platforms - I said "cross-platform scripting language _library_". Anyway, I get the point of your post and should probably wait for a WP7/8 NDK that will probably never be released... Thanks for taking time.
  5. Hi, I am working on a cross-platform game engine that currently runs on Windows, Ubuntu, Android and iOS. Since it is written in C++ I will not be able to run it on WP7, unless I port the source code to C# which I have now decided to do. But before I begin with that I want to implement support for a scripting language so I don't have to port the code for the future games that will be powered by the engine. So to be able to use the exact same game code on all devices I need a scripting language library that has been implemented for both C++ and C#. So my question is: Does anybody here know about a cross-platform scripting language library that is available for both C++ and C# applications? Thanks for your help! /Klarre
  6. JoachimKlahr

    Multithreaded resource loading

    Thanks for your input!
  7. Hi, I am writing an OpenGL game engine running on multiple platforms. Now I want to implement a nice real-time rendered loading screen but don't really know how to do this in a good way. I did two attempts though. In my first attempt I did like this: 1. Begin rendering of loading screen. 2. Create a new thread. 3. Begin loading and generate textures in the newly created thread. (The loading screen is being rendered parallel) 4. But, crash. Of course this crashed since I made OpenGL function calls like glTexImage2D in the new thread. Not in the main OpenGL thread - not OK. In my second attempt I made some kind of resource loading queue in my resource manager. Each time the resource manager got an update it loaded one resource, and then the loading screen was rendered. Next update (frame) it loaded another resource, until the queue was empty and all resources loaded. This was pretty ugly and didn't work that well. Also, the loading screen didn't get that smooth using this approach since it only got redrawn after a new resource had been loaded. So, how do you guys do?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!