Java Adventure Interpreter--> To extend scripting or not?

Programming, for all ages and all languages.
Post Reply
Andrew_Baker

Java Adventure Interpreter--> To extend scripting or not?

Post by Andrew_Baker »

My next project will involve using J2ME to create an "adventure" genre game similar to AGI/SCI, but with modern graphic and sound formats.

Anyway, the real deal is that I'm wondering if I'll have to extend the scripting to parse/lex room logic scripts or if it would be possible to define a group of static variables in a room class, and inherit those classes into further room class objects, each with their events and scripting of interaction hard-coded into them (To avoid run-time overhead on mobile devices by using precompiled code).

Would hard-coding the logics be possible, or am I going to have to create an interpreter in Java on top of the Java VM?
ark

Re:Java Adventure Interpreter--> To extend scripting or n

Post by ark »

I'm sure it's possible to hard-code the behavior of each logic. The only questions are ease and extensibility.
grey wolf

Re:Java Adventure Interpreter--> To extend scripting or n

Post by grey wolf »

you could write a script engine similar to those used in most current PC games. the script is loaded, interpreted, compiled, then executed that way.

eventually, you end up writing something not unlike your own machine language, but with effective use of enumerations and parse tables, it's a lot simpler than it sounds. i'd do that just for kicks.

but for an embedded environment? just create an API and allow external classes to interface with it. that's much easier to implement and will probably end up being a lot smaller than your own script engine.
Andrew_Baker

Re:Java Adventure Interpreter--> To extend scripting or n

Post by Andrew_Baker »

Yeah, basically, I want to make a class library with my different game objects: room, object/sprite, inventory item.

Then, I would put the sprite's behavior script (probably event capture) into an object that inherits my Sprite class.

Also, I would have multiple rooms inherited from Room with event capture triggered behavior (i.e., if ego is on a certain box on screen, if a certain command is activated, etc.).

Something similar for inventory items.

Then, I'd refer to these objects through the main application, probably in the same way AGI refers to them, by placing a number in their name, so (pseudo: run.room.logic("Room"+room_no+".class")).

In the Java book I'm using for reference and learning, one of the projects is creating a VM, but I think that the Java VM should already be able to handle all of my needs, and I'm not sure if I can afford the run-time overhead.
grey wolf

Re:Java Adventure Interpreter--> To extend scripting or n

Post by grey wolf »

you can't afford that kind of waste on an embedded platform. the java VM is already a lot of overhead as it is, as you probably well know.

stick with the API method. it's about your only option as far as this goes.
Andrew_Baker

Re:Java Adventure Interpreter--> To extend scripting or n

Post by Andrew_Baker »

I've been doing some reading into Java. It seems that I'm going to go with an abstract room class and a group of final room classes linked with pointers.
Andrew_Baker

Re:Java Adventure Interpreter--> To extend scripting or n

Post by Andrew_Baker »

Does anyone know of any good references for programming graphics in Java? My text book is fairly weak inasmuchas sprite graphics. For instance, it doesn't provide a means to designate transparent colors for my sprites.

Any help is appreciated.
Post Reply