Jump to content

  • Log In with Google      Sign In   
  • Create Account

A Mini-Compiler?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Spirrwell   Members   -  Reputation: 279

Like
0Likes
Like

Posted 15 January 2013 - 04:16 PM

I'm not quite sure how to specify my question so I hope the title isn't confusing. I'm sure there's a proper term for what I'm looking for, but I'm too stupid to know it.

 

Basically I've created many programs where I'm constantly rewriting the same code over and over again and I could probably import the same code I need from another project I've worked on, but then it becomes a real hassle.

 

If people are familiar with the game Quake you may be familiar with it's modified language of C\C++ known as QuakeC. It's a way to modify the game without having to go and modify the original games source code and the code that you would write is in QC files. These files would then be compiled into a progs.dat file and you wouldn't mess with essential background code that might deal with rendering or specific calculations that the game needs to do.

 

I'm looking to do relatively the same thing. Say I have a bunch of background code such as classes, structures, and data that I wouldn't need to mess with unless I needed to do something really specific. So I would have just a few files that the programmer would use (me) that would contain functions for specific purposes such as initialization, loading files, updating game variables, and rendering. It would be all I need access to so I could create my own functions and do what I want with the classes and stuff I already have that I don't need to mess with and recreate for each new project.

 

I'm sorry if something like this has been asked before, but I honestly don't have a clue what to search for. This would be a really cool thing to learn how to do and I find it oddly exciting. So if anybody has any information on this it would be very much appreciated. Thank you all!



Sponsor:

#2 Servant of the Lord   Crossbones+   -  Reputation: 20990

Like
4Likes
Like

Posted 15 January 2013 - 04:45 PM

This is called 'scripting'. Typically you'd use a 'scripting language', like Lua or AngelScript.

 

Your C++ (or whatever) code then loads, parses, and executes a script. One of the huge benefits of scripts is that they don't need to be 'compiled' in the usual sense of the word, so you can rapidly edit the script, have the program reload the script, and then see the changes very quickly.

 

Scripting languages often times can be compiled (or pre-parsed) for faster loading once you're ready to ship your game, but usually they are quite fast already.


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#3 Aiive   GDNet+   -  Reputation: 1012

Like
1Likes
Like

Posted 15 January 2013 - 04:51 PM

This could be off from what what you are asking but after reading your post a few times this is what I thought:

  • You have code you rewrite each time you start a new project
  • You don't like having to import the entire code base between projects - .cpp/.h if you are using C++ (if I am reading this correctly)
  • You want a set of core components and then use something external to build an application from (much like Unreal's approach before where they created everything but the core in Unrealscript).

If the above is true (meaning I read it correctly rolleyes.gif ) maybe you could look into creating a library of core components and link against that library? If you have a great set of core classes from project A and want to use them in project B - just compile it and use the headers for the library. This way you do not have 5 versions of the same MyFile class   living within your system.

 

Once you have that, and as the post above me states, you can just bind your core methods to a scripting language. If you need to add more functionality you can add the ability for creating plugins for your application and use the plugins in the scripting language. The Ethanon Engine followed this approach where you were able to export angelscript functions from a DLL library and then use it in the scripting. It was as simple as just adding the plugin name to a config file.



#4 Spirrwell   Members   -  Reputation: 279

Like
0Likes
Like

Posted 15 January 2013 - 04:51 PM

Oh, no wonder why people hold Lua in respect, I actually never knew what it was I just knew that people liked it. Well this is useful, I'll look into it, but if somebody has further recommendations let me know. All I know is I'll be working exclusively with SDL, OpenGL, and the like for portability, so I'm not entirely sure what will work best. Thank you very much!

 

Edit:

Yeah, I think I'll go with the library idea for now, that seems simpler and I think I'll learn Lua or something eventually.


Edited by Spirrwell, 15 January 2013 - 05:03 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS