Jump to content
  • Advertisement
Sign in to follow this  
izua

A weird question

This topic is 4222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone! I've lost contact for a while with GD, and with openGl-C++ too, but I've learnt some new stuff, and a question has arised for some time. If this is the wrong forum, feel free to move it. I post it at the newbies forum, since I'm a newbie in this area, and somehow it's related to game programming. First, since i'm a hobby-electronist, I've learnt some PIC assembly language. It's nice, but it's hard work, so I want to make some higher level language, with a syntax similar to C or BASIC. It's really killer. I don't know what even I should look for. I've been pointed to formal language, but I still think I need more. I don't know what I should read/look for. Now, the real thing- the question that raised after this. This, I think, would require a similar solution to this one. I'm developing a browser-based game (PHP/MySQL/Apache). Like darkthrone, kings-of-chaos or a million out there, but it should be more mud-like. I have a bunch of rooms, and each rooms has objects (database entries). Now, each user has a set of variables, stored separately (not in session, or like that). I suppose these will be the variables where the objects and game-world would manifest their presence. Let me take an example. Let's say user 23 is in room 101 (:P) and there are two objects in the database that belong to this room. I want one of them to be visible and one invisible depending to a user variable. How should i do this? I believe there will be a call before listing objects, that will access each object's script, and that script will decide upon the properties of the respective object. Buuuut.. what should i do? Should i make a stand-alone language, to be interpreted in php, or should i make the script in php? I know this should be a far goal, not immediate, so please point me to what easier stuff i should do in the meantime, and what i should read, too (preferabbly online). I've asked a friend who's doing intense informatics in uni (not sure what profile, though - but she taught me 'bout advanced algos and design patterns, so i guess it is software engineering or something like that) and she told me that she can't explain me this now, because that's effectively designing the whole language and world. Is this making any sense? [smile] no? have you seen l2j (the emulator)? ever looked on the quest/event system? that's something i'm look for, or close to. -izua edit: oh, and please don't say that i'm asking too much. i've been told this so many times today. just let me know what should i look for, or your experiences with building a language for a game.

Share this post


Link to post
Share on other sites
Advertisement
Languages are relatively hard to build, and very hard to build well.

There are tools for building languages. Flex and Bison are two completely open source ones. It helps a lot to know the details and problems with parsing, so it helps to have formal languages training. An LR(1) grammer vs an LL(2) grammer, a regular language vs a context free language vs a context sensative language...

Generally, it is much easier to take an existing scripting language and just use it. The language will be better written, probably more optimized, and faster to hook up than anything you could write yourself.

...

Now, you don't need a full language for what you describe. You are writing both the engine and the data. The data could either contain a script in some language, or the name of some object/function in another language.

Ie, if I was doing something like this in C++, I might have the objects provide the name of their C++ handler class and some arguements for that class. My C++ program would then call a factory with the name of the class and get a handler class, then feed the handler class the arguements, then ask the handler class what the properties of the object are.

This is a mixture of the factory and featherweight design patterns. (well, the class/instance pattern implemented as a featherweight -- no need to have a copy of a handler for each object just sitting around, just grab the right type and feed it the arguements).

Fancy objects might have to have a custom C++ handler, but many objects would be pretty generic and would use a single global handler. Really complex objects could even end up having the handler load a scripting engine and running a script -- but I wouldn't have to make that decision when I designed the room handling code. An object that used a scripting engine would simply be an object that named a handler that happened to load the scripting engine.

I don't know if this will work with PHP/MySQL/Apache in a web centric environment. :) Once concern I'd have is -- does the PHP session persist at all between requests? Having to rebuild the factory every time someone does a GET request would suck. How does PHP handle "temporary" data structures and resources that you want to have to regenerate every GET request?


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!