Is this ridiculous or what?

Started by
15 comments, last by Ivyn 21 years, 8 months ago
What you were doing is basically equivalent to what he said. You were going to use pascal as your intermediate code. Intermediate code can be anything, it doesn''t have to be assembly like.

An app to translate one syntax to another is commonly called a ''compiler''. If you want to program one, I recommend the book ''Compilers: Principles, Techniques, and Tools.'' You can get get it off amazon, or out of your local university''s library. You probably also want to google for lex, yacc, and/or ANTLR.

Virtual machines are programs that simulate computers. You might have heard of emulators before? Those are virtual machines.

This is a pretty big undertaking... you might want to reconsider embedding some ready-made scripting engine, such as python or Lua.
Advertisement
GameDev.net - Articles & Resources - Game Programming - Scripting

Creating a Scripting System in C++ Part I: An Introduction
Creating a Scripting System in C++ Part II: Data Manipulation
Creating a Scripting System in C++ Part III: Dynamic Loading
Creating a Scripting System in C++ Part IV: The Stack and Program Flow

EDIT1: Fixed link...

[edited by - dalleboy on August 15, 2002 1:31:41 PM]
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
Nah this doesn''t really seem that ridiculous

I''d probably go with the virtual machine way, but both ways seem viable
quote:Original post by Auron
How about using precompiled scripts? Set up your own scripting language and everything but make an external compiler that compiles the scripts you make to intermediary code. This intermediary code can then be run through the virtual machine in your game without needing to parse anything. And thus, the performance hit is minimized.


How do you avoid having to parse? Would you make a function for each instruction e.g ADD(), which reads what ever it needs as its arguments? You could have say 255 instructions and an array of 255 function pointers I guess, then you read the op and call func[op] which reads arguments from the script thing. But why would the scripts necessarily need compiling for this?
Is this what is meant by virtual machines?




Read about my game, project #1
NEW (13th August): A new screenshot is up, plus diaries for week #3

John 3:16
why are you doing this again?
its more work than building a game and once you''ve made it, will it be flexible enough?

why not use a IDE for the programming, a graphics editor for the graphics and a level builder for the levels.
If you want you can tile the windows on your desktop so it looks like they''re in an IDE itself..

it is ridiculous (to me at least)
script compiler :
allows you to type stuph into a text file in easy syntax (ala C++/VB/whatever), then run it through a program to convert it to a binary file that only contains op-codes and parameters.

it''s quite a bit faster( not to mention more readable ) to have :

script >> op;
functs[op](&script);

than:

script.getline(buffer, 256, ''('');
if(strcmp(buffer, "functionOne")
functionOne(&script);
if(strcmp(buffer, "functionTwo")
functionTwo(&script);

it makes it faster by doing all of the parsing once, rather than every time you run a script...
I''m not making this only for my own use. And besides, it''s a great learning experience and I wouldn''t want to program my entire game in pure C/C++...etc anyway. Even Unreal Tournament, Freedom Force, Spider-Man, Jedi Knight, and tons of other commercial games used a scripting language to simplify the development process.

-- Ivyn --
-- Ivyn --

This topic is closed to new replies.

Advertisement