Skip to main content
gamedev.net
🔒 Locked

Using scripting to control sprite behaviour

Started by Derakon 0 replies 1k views
Original Post
Derakon
Derakon
Apologies if this isn't the right forum for this problem; the A.I. forum also seemed reasonable, but I suspect that'd be a higher-lever problem. I'm working on a 2D platforming game in a similar style to Metroid and Castlevania. I'm planning to have each "monster" have a generic data file, instead of having specific content-related information encoded into my C++ program. That is, I don't want to have "EvilKnight* joe = new EvilKnight", but instead "Monster* joe = new Monster(TYPE_EVIL_KNIGHT)". Obviously this means that I can't encode the A.I. of the monsters into the update function of the Monster class; I'd rather view the A.I. as just another component of the monster's specification, without limiting my game to a set of precoded A.I. types. I was thinking of trying to associate a simple script with each monster's data file. The trouble is that I've no real ideas on how to do this and what languages I should use (making my own homebrew is really unappealing). Is what I have in mind even workable? What kind of performance hit would I face by using uncompiled scripts that get run each update cycle for each monster? I'm planning to give each monster some basic information about their world, but they'll be pretty stupid on the whole. They'll know the player's current location and state (since the player has a variety of forms available), as well as their own health, location, et cetera. I don't really plan for them to know the local terrain, since that seems like it could get complicated quickly. Some monsters will completely ignore this data; e.g. monsters that just walk straight forward, Goomba-style. Ideally I'd like the behaviour scripts to be able to call my own spawnMissile(), die(), et cetera functions, which would be written in C++. Any advice is appreciated. This includes pointing me at resources that I've missed. Is this even a good idea? Edited to fix, of all things, a syntax error in my C++. That was really sad. [Edited by - Derakon on November 29, 2004 7:22:32 PM]
Jetblade: an open-source 2D platforming game in the style of Metroid and Castlevania, with procedurally-generated levels
RolandofGilead
RolandofGilead
http://www.lua.org
http://www.lua.org/pil/

I'd say code everything in a level as a script, run the script, and let your engine update the entities as specified by the level script. For such simple monsters, you should be able to put the entire AI system in script form.
--or like Tarzan says--
Script Specify, Engine Run.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.