Archived

This topic is now archived and is closed to further replies.

yodaman

designing an engine around...

Recommended Posts

Ok, So i have all of these plans for my engine, and infact have around 2000 lines of code already done along with a stack of papers about 6 inches tall. Anyway, I have came to the point where I can no longer procrastinate on data respresentation and such. Recently I asked about using scripts in your engine, after reading many articles and such I am left a point where im a bit boggled by how things should fit together and what should come first. Im probably going to write my own scripting system, i have it all planned and in an simple solution that I may explain if it works. Anyway though, I was wondering, what should come first, the (ex) script or the entity/world classes? Im thinking that it would not be hard to incorperate the script later on. Also, this may sound a bit dumb but, what exactly are scripts used for, well I know what there used for, but what do they normaly do? would you use the script to set properties and trigger special events or would you use them to make new AI types (and events), or would you use them for both? I know that I will have to have hard coded routines for everything, but where should the hardcoded routines come to a end? If you just kept on adding more and more, there wouldnt be a need for scripts, but if you didnt have enough, there wouldnt be much need for an engine because the designer would be writing scripts for everything. Should there be a master "AI" class with derived classes such as "CRedMonster","CBlueMonster","CFlyer" or should there just be an AI class but only with functions for handling scripted entitys? One more thing, are scripts normaly used for physics and rendering at all, as well, or is that stuff usualy hardcoded? Thanx alot to everyone in advance! ~mr yodaman

Share this post


Link to post
Share on other sites
I think that if you don't really know what you want to use your script for, then you probably don't need one ! Until you hard-code some things in, you wont have any idea what you want to do.
eg, say you do:

if (player.x>10 && player.y>10) play_sound("spooky_music");

Do this five times in your code and then think "Recompiling this is giving me the shivvering fits, I think I'll do a script". But until you get a feel for what you want, don't try to be too general.

Also, as far as your AI goes, you probably dont want to have a CRedMonster and a CGreenMonster, but just a CMonster(colour=red, speed=100, height = 50) - read these specs from an ASCII file and you are much closer to having a data-drivern program than if you had used scripts. This may be what you really want - not "scripting" but "datafiles" saying what things go where.

Start small and hard-wired and then add generalities as you go - you may need to re-write everything but at least you get something to show for it along the way, and you know exactly where you are going. Use an iterative approach - no one can design software perfectly on paper the first time.

[edited by - chookmaster on May 1, 2003 11:32:58 PM]

Share this post


Link to post
Share on other sites

Ok, Im going to try an re word what I said...
Its hard to explain what exactly it is I want to ask because
Im not sure what exactly to ask. The thing is, I want to have a basic system that alows me to handle events in each level that is not hardcoded, so of course the solution is some type of scritping. What im thinking of doing is having a list of flags that can be set that would alow for a simulated script when put together.

When I said CRedMonster CBlueMonster, what I ment was that im not sure if I should handle or have the ability for new entity
types to be made thru script or if I should just go about making things flexable by having a 1000 flags that can be set.

Particular things in games, like the part in half life where your going down the pakage lift and the face huggers are jumping out at you.. well Im sure that wasn''t hardcoded. Or how about games where theres platforms moving about, lasers going about the world... you know, things that make a level different then the next, this stuff is all scripted.

I quess what im really asking is how to go about adding scripts to your game and what functionality or even responceability should they play?

Thanx

~yodaman

Share this post


Link to post
Share on other sites
In Visual Pinball (and I''m doing the same for Jumpman-Uc) we used Visual Basic Scripting to control the flow of the game.. basically every object was its own COM which allowed access to the MS scripting engine (if you make your own script then it''s just a case of the parsar working out which object the script is trying to reference)..

the way we did it was that the game engine would handle all the physics and rendering and the script will be called on events.. It ball hit wall, ball hit spinner (pinball stuff here). The script could then modifiy any of the games objects properties (that where allowed) such as making a wall drop or turning on a graphic element (light).

the end effect was that the actual game played by the player was totally script driven.. all we had to do is bounce the ball around.. the flow of the game was upto the person making the table..

in jumpman I am using the same idea except it will only call the script when bombs are collect (or a trigger is run over) which will allow for the levels to change (ie make this girder appear or make that monster move there.. etc..)

Share this post


Link to post
Share on other sites
Ok, thats what I ws thinking.
The physics and rendering are all part of the engine and a basic AI class such as a "NPCobject" would be binded with the scripting engine.

Luckaly for me, I have been coding my engine's base code alone
along with menu systems etc, so I havent yet started the entity system yet, so there for I can learn how to use scripts engines and bind them to my classes.

Im going with a scripting engine that already exists so all i will have to do is make a wrapper for it so I can start making
al;l the stuff that uses it.

Thanx alot...

yodaman

[edited by - yodaman on May 2, 2003 5:59:12 PM]

Share this post


Link to post
Share on other sites