Jump to content
  • Advertisement

Archived

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

griffenjam

AI Newbie ISO help

This topic is 6299 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

I''m a game programming newbie, I''ve written a 2-d space shooter game, but now I''m working on a simple RPG. I don''t want to hard code the actions of all the monstors, I''d like to write a simple scripting language for them that would be loaded from a file at game startup/when I enter an area with those monsters. I have looked on gamedev.net and in some newsgroups but can''t find help with a couple things First. how do I represent the scrpit internally? like, lets say I have a MONSTER class or struct, would the script be loaded into a big char array? would I use a linked list? Is there an option I''m not seeing? I know I COULD do it either way, but I don''t want to spend time working on it and then find out there is some common way that everyone uses. Second (non AI releated) question. I just want to know if there is a way (aside from using threads) to load resources (script, images, whatever) while the player is playing but NOT make the game loop wait for the resource to load. If so, how? If not, do you use threads?IF you don''t knwo what I mean, the idea I''m thinking of is setting area boundrys in whice cetain monsters will be, when you are a certain distance from that area it will imitalize the mosters and load their art and scripts, if I put that in the game loop the game will hang untill it gets done loading everything, that would suck. Do I have to use threads? Jason Mickela ICQ : 873518 E-Mail: jmickela@pacbell.net ------------------------------ "Evil attacks from all sides but the greatest evil attacks from within." Me ------------------------------

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by griffenjam
Second (non AI releated) question. I just want to know if there is a way (aside from using threads) to load resources (script, images, whatever) while the player is playing but NOT make the game loop wait for the resource to load. If so, how?
If not, do you use threads?IF you don''t knwo what I mean, the idea I''m thinking of is setting area boundrys in whice cetain monsters will be, when you are a certain distance from that area it will imitalize the mosters and load their art and scripts, if I put that in the game loop the game will hang untill it gets done loading everything, that would suck. Do I have to use threads?



Couldn''t you just load them when the game starts then if you need to change any scripts during the game you can change them at runtime?





Need help? Well, go FAQ yourself.
What a plight we who try to make a story-based game have...writers of conventional media have words, we have but binary numbers

Share this post


Link to post
Share on other sites
I just want to save on memory useage.
I thought that loading creatures that would not be in use during that run of the game would be a waste.

Share this post


Link to post
Share on other sites
Personally, if you are developing for windows, and you aren''t having problems with your game taking up too much memory, don''t worry about it for now. One of the things I constantly see is this: Get a program working, and then go back in later and optimize, not the other way around. You are doing it backwards. Make your script work, so you know you have it right, and then go in and change it so that it works faster, but still works. You don''t want a program that is difficult to maintain and/or understand because it was optimized before it was even thought of...
farmersckn

Share this post


Link to post
Share on other sites
If you''re develoing on C++ you should use string and vector.
They are part of C++''s new Standard Template library. Every STL class is in namespace std so put in the line "using namespace std;" if you don''t want to write std::string myString;.

example:

#include
#include

using namespace std;

//...

typedef vector StringArray;

StringArray script;
string newline;

string = "attack player";
script.push_back(newline);

// get a line:
string line;
line = script.at(1);



You even can parse strings and search for characters, substrings, etc. using find_first_of(..) etc.

You might look for some information about STL there are really usefuel classes for many common programming tasks.

Share this post


Link to post
Share on other sites
I wouldn''t go for the STL book (if there is such a thing, I think most new C++ books have sections on it).

You can easily make your own classes to do the same thing. Its not too hard, and you''ll learn alot.

A vector is just a safe array class (bound checks). Put the data as a private member, and overload the [] operator so you can say

CVector myVector;

myVector.resize(12);
myVector[8] = 5;

Notice the use of templates==> very important for a vector class.
Then, notice how a string class is just a vector of chars. So, you derive a CString class, and add some functions to search for substring, etc. There are standard function calls that will do this for you.

I have been doing just that myself. It is definately worth you''re time. If you don''t know about classes, overloading operators, derived classes, templates, etc. this is a great way to start.

Feel free to e-mail me if you have some questions on how to implement these classes (I don''t have a string class yet, I do have a CVector class, though).

Ben
ben@ageofzeppelin.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!