views:

135

answers:

2

I want to build a strategy game using C and Lua. C++ is also an option.

I would like to create an environment where a player can move around. In the same environment, other actors (programmed in Lua) should be able to move around. Their Lua code should control how they move.

It sounds simple enough, but I wonder what would be a good design approach for this project.

As a simple example you can imagine a matrix that is the playing field. How do I write my code so that a player and several other (scripted) actors can move through it simultaneously?

The Lua code of the actors should be able to get information from the playing field. For example: an actor could be programmed to follow a fixed path, looking around along the way. Then if the actor detects an other player, it could change its behavior to follow the other player.

I imagine this problem has been solved many times, but I can't seem to find a simple example.

Any links to other designs and original ideas are much appreciated.

A: 

There are many good books on game programming. I recommend going to your local Barnes & Nobel, or surfing Amazon.com.

abelenky
+2  A: 

The question is very broad so let me suggest that the best way to start is to break up your problem/question into smaller pieces.

You mentioned that you are trying to create a strategy game which will use a matrix as a playing field and contain movable actors. So you will have to decide:

What kind of data structure should I use for representing a matrix in which various actor objects can move from one node to another? How should the actor objects be represented? initialized? stored?

I am assuming that you want some video in your game so you will have to decide:

What platforms should I target? What rendering technology should I use? Are there graphics packages which meet the needs of this kind of project?

You will also have a lot of fun game design questions: Can actors occupy the same node in the matrix? Does the game occur in real time? in turns? a combination of the two? What are the variables which make different actors different? speed? durability?

When you have some hard coded actors in you c/c++ source code you are then going to need to decide: Is Lua a good fit for this project? If so, how do I want to expose my game logic to Lua? Will I use Lua as a "config file" for objects or push everything in the main loop out to Lua?

These are the kinds of questions which receive much better responses on SO.

Nick