|
-
Game structure question: Entity interaction
I'm working on the core engine for a new top-down 2d game. The basic structure is this:
This is not a question about hit testing, but rather how to handle the questions "Can object X interact with object Y" and "What happens?"
Some solutions I've thought of:
1. Object X uses a switch or if statements based on a property of Object Y to determine what methods if any to call.
2. Object X uses a switch or if statements based on Object Y's interfaces to determine what methods if any to call.
3. Object X uses an integer bit mask on Object Y's integer bit mask, which determines what interactions occur using a look up table. E.g., 10001101 and 10100001 interact on bits 1 and 8.
4. A single, static "Interactor" class handles the interaction.
Concerns and goals are:
1.) Extensible. If I think of a new type of interaction later on, how easy will it be to add? Will it be possible to define a new interaction without changing the code at all?
2.) Performance. If two entities don't interact at all, how can I quickly figure that out?
Just looking for ideas or solutions I haven't thought of.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|