Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / [DGDK] JemEngine

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Dec 2007 19:36 Edited at: 16th Dec 2007 00:46
Hello all, been a while since I started a WIP. Well this is my latest one, and it's about an engine I am working on for the release of the DarkGDK.

JemEngine


Currently, the engine only consists of about 1.5 components, but it's still worthy of a WIP, because they are large components and are helpful. I will add to the list of features through time:

List of features:
- OOP DarkGDK programming in C++
- JemScript Scripting System

- OOP DarkGDK:
The OOP DarkGDK was also posted in the DarkGDK section, but I have changed a few things around here and there, just to make it more Jem-ish.

- JemScript:
Ok, I will be doing most of the explaining here for now, since this is the component I have been working on the longest (I have only been working on it specifically for this engine a short while, but actually working on a scripting system: over a year).

It's features include:
- C-Style syntax
- Functions
- Variables
- Arrays (with linked lists capabilities)
- Control structutes ("if" and "do" so far )
- A total of 4 built in commands!!!!! (...so far)
- Typecasting (despite it being weakly typed)
- Ability to pass arrays to and from functions
- Speed

Here is a simple example:


It starts by calling the function main() (which parameters can also be passed to). It then creates a blank array, and pushes some messages onto it (linked list stuff). Then, it calls the display() function, and passes the whole array to it (take that DB!). The display() function loops through the array, and breaks when it's finished.

I still have to add a whole range of commands to make it any sort of useful. So far, there is only print, push, pop, and empty.


I will keep posting updates to this as I go along. By tonight or tomorrow there should be some ability for 2D graphics

Comments and critics are welcome (and encouraged.. I hate starting threads that get 0.01 replies)

Cheers


[Update: 15 Dec]
- Started adding DGDK functions to scripting engine: dbSync(), dbSyncOn(), dbSyncRate(), dbKeyState() and dbBox().
- Project handler: Loads Jem project files (for scripting)
- Preprocessor: So far, ability to include files in the local dir, and the project's "root" dir, which is accessible from anywhere.
- Standard library: Simple functions as of yet.

n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 20:47
May I just say that Arrays are only really useful when two dimensional? Vectors, ftw!

Looks cool, btw.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Dec 2007 20:53
I find that I rarely actually have to have 2D arrays, i.e. for things like vectors, I just make a type (which are not currently implemented yet).

The reason I didn't make 2D arrays, is purely because I didn't know how to It would also be a problem when pushing/popping elements.

If you really want a 2D array, just do this:

var grid[x*y];

and use like this:

something = grid[x*y];

n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 21:08
2D arrays are easy to make:



Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Dec 2007 21:38
They are easy enough to make in C++, but this is a scripting language I had to make from scratch. Having arrays is new enough to me

n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 21:43
I've heard many people say they've written an "engine" or "scripting language". What exactly do you mean? That example does not tell a lot to me...

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Dec 2007 21:47 Edited at: 15th Dec 2007 21:49
Well, that bit of code is my own language. As of about 10 minutes ago, it can now handle some simple DGDK commands, such as dbBox(), dbSync(), dbKeyState(), etc. I intend to keep adding commands to it till it becomes fully functional.

[edit]

Forgot to say: you can save it to a file outside the main code. Once the main exe has been created, these scripts will remain the same. They can be used to mod/patch things, and also, if you're code is really large and takes ages to compile, you can change things in scripts without having to re-compile.

n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 21:54
Oh, so the .exe reads and executes the commands.... Cool.

Still have no idea how that works, but OK.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Dec 2007 21:57
It's exactly like Lua, but looks different and this one calls DGDK commands.

Here is TGC's explanation of scripting: http://darkbasicpro.thegamecreators.com/?f=lua#whatis

n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 22:01
Ah, cool.

How did you make it?

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Dec 2007 22:04
Alot of work *shudders*

n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 22:05
I'd imagine... But what did you do? Not super-specifically... Just, in gnereal, how did you make it?

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Dec 2007 22:10
* Load file, preprocessor stuff, remove comments, etc
* Lexical analyser - split the code string into "words" (i.e. "a = 3 + 4" -> "a", "=", "3", "+", "4" )
* Parser/Error checking - compare tokens(words) against each other and check for syntax errors
* Compiler - Convers tokens into bytecodes; very simple commands with minimal parameters
* Virtual Machine - Loop through bytecodes and execute them


That's roughly how it's supposed to be done, from what I know, but I've never taken any classes in this, so this is the best I can make of it. It's pretty fast anyway, so it doesn't matter.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 16th Dec 2007 00:47
Added some features. I'll just copy & paste from the updates list:

Quote: "
- Project handler: Loads Jem project files (for scripting)
- Preprocessor: So far, ability to include files in the local dir, and the project's "root" dir, which is accessible from anywhere.
- Standard library: Simple functions as of yet.
"


Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 16th Dec 2007 23:03
Cool. What else needs to be done? When do you think you'll have a demo ready?


Cheers,

-naota

Madness never stops..... It takes a breather every once in a while, but then it grabs it's inhaler and chases you down the street with a cane.
Aex.Uni forums
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Dec 2007 19:48
Hey, might get a demo out soon.

I've decided to start working on structs (types to you dbp people), but I'm not making any promises

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 17th Dec 2007 21:35
I will! I promise Zotoaster will get structs working... >:}


Cheers,

-naota

Madness never stops..... It takes a breather every once in a while, but then it grabs it's inhaler and chases you down the street with a cane.
Aex.Uni forums
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 18th Dec 2007 18:57
Ugh, I give up on structs for now

Sorry!

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 19th Dec 2007 17:46
Hello again. I've started to add in most of the fundamental DGDK commands. Problem is that this doesn't support overloaded functions, so you get to only call the basic version of each function. If demand is high, I can make the overloaded functions with numbers at the end, i.e. dbSetObject2().

Here is a very, very basic drawing program written in JemScript:




Mr Z
17
Years of Service
User Offline
Joined: 27th Oct 2007
Location:
Posted: 19th Dec 2007 20:35
Very nice. I want to make my very own scripting language too... any tutorials you know of that might help?

Darkness, you haunt me. If I give in, I would be an monster beyond imagining. Light, you guide me. Thanks to you, I see past the nothingness. Life, I choose to live in the light.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 19th Dec 2007 20:40
This got me pretty far, though he does talk some right crap in it But the principles are all there.

http://www.flipcode.com/articles/scripting_issue01.shtml

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Dec 2007 00:29 Edited at: 25th Dec 2007 00:35
Hello again.

I am updating the scripting engine a bit. Rather than always having main() as the entry point, you can change it everytime you run it. This means that you can do some nice event-based scripting without having to make new scripts for different events.

It also, on a side note, removes much need for built in DGDK commands. Alot of the stuff now can be handled by the actual engine, but certain data can be used in scripting. For example:



I can call these events when I press the up and down arrow keys and retrieve the values. In C++, I can then do whatever I want with these.

You might ask now, why do you need a script when you can just make a simple file in the format "something = a value". Well, it's simple: in this case, it's very basic. You can take it further by encapsulating certain things, so for example, you dont always get the same results. Furthermore, instead of just using these to return data, you can make actual events, such as Crash(), or something

Your signature has been erased by a mod

Login to post a reply

Server time is: 2024-11-24 05:05:59
Your offset time is: 2024-11-24 05:05:59