Jump to content
  • Advertisement
  • entries
  • comments
  • views

Hyrda Pt Something

Sign in to follow this  


Well, something weird occured to me the other day whilst I was working on Hydra. The way I'm coding it is pretty much using my 'engine api' straight and then adding some hardcoded entity types. An entity type is basically a bunch of data added to a user pointer in the entity_t struct; entities also have custom 'think' functions (a la Quake) in which they do all of their thinking (state changing, movement, AI, whatever). It's all pretty simple and straight forward - being in C-style C++ everything is done via functions and not member functions of classes; this setup is pretty trivial to wire up to a scripting API so I broke out a recent build of GameMonkey Script and got to work. In a couple of hours I'd stripped out almost all of my game logic, including sprite and texture setup - it's all now done using script!

It's actually pretty neat as I managed to pretty much emulate my internal API using scripted functions; so to load a texture it's as simple as calling: tex_load_texture( [filename] ); and you get back a TextureId. This can then be fed into sprite creation - spr_create( [textureId], [width], [height] ); and finally the sprites can be assigned to entities - ent = ent_create( [ent_type_id], [sprite_id], [position] );.

So what I've got now is a program that launches, loads up a script and jumps straight into the scripted 'main' function as a thread. This scripted function then calls the various load textures and sprite setup functions and finally creates some entities based on the sprites. It's all working very nicely and things are displaying as they should. I can even reposition them and change their sprites all from script - not bad, eh?

What I need to do now is to add the 'think' functions to the entities; where previously they were C function pointers they now have to be GMScript functions. I'll keep the current setup but add in a 'script think' method that calls a user specified scripted function - this lets me export specific 'set' think actions from C (fly straight, etc) instead of having to script such basic motions. Another task is to figure out how to allow for entity specific data - I'm thinking of setting up a 'properties' method on the scripted object that lets me assign anything to it - this pretty much allows me to use entities as I was before :)

So where's all this going? Well for one I have a very quick system for throwing out 2d sprite-based games. It's a prototype right now and I'm still going to need to wire up all the collision stuff, perhaps using a similar system to the one I used before. Entity types are currently user-specified by a single int, but I'm contemplating making it so they need to be registered with the engine, meaning you can refer to them by name - this would allow me to then start firing out the class-based event handling I did before.

I've got a big idea based on this prototype; it's tied in with the idea from my previous entry - but I'm not going to talk about it until I've done a little more on the prototype. Suffice to say, Hydra is going to be scripted :)
Sign in to follow this  


Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!