iDevGames Forums
Creating enemies in a 2d game - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Creating enemies in a 2d game (/thread-7809.html)



Creating enemies in a 2d game - wadesworld - Apr 19, 2002 09:46 AM

You need to be a lot more specific about what you're trying to do.

In general, there will be some kind of data structure that will hold information about all the players in the game, whether friendly or enemy.

It could be something as simple as:

Code:
struct playerStruct
{
    int   class;
    int   type;
    int   hitpoints;
    int   strength;
    int   dexterity;
};
If you can give more specifics about what you're trying to accomplish, perhaps someone can help.

Wade


Creating enemies in a 2d game - gwihlidal - Apr 19, 2002 09:49 AM

Hey, I'll help you out a bit if you'd like. I don't have loads of time on my hands, but I'm always open to code anything Smile

Let me know if you want some extra help!

Thanks,

Graham Wihlidal
Software Engineer
Chronostorm Entertainment
gwihlidal@chronostorm.net
http://www.chronostorm.net


Creating enemies in a 2d game - DrKane - Apr 21, 2002 09:39 AM

Ok, I've got the graphics part of my 2D rpg engine finished. Now I'm trying to create a good system for dealing with enemies( a turn-based system, sort of like Exile or Avernum). Now I know that you're supposed to use structs but I havn't found a way to implement this yet. Does anyone know where I can get some good code to help me out with this?


Creating enemies in a 2d game - Jeff Binder - Apr 23, 2002 12:34 PM

What language are you using? In plain C, use a struct with all of the character's stats, their location, the ID or index of the graphic they use, and any other info.

In Obj-C or C++, you'll definitely want to use a class for characters, items, etc. Then, you keep an array of all the characters in the area class (or whatever you call it). You can loop through them and call their drawing method to draw them, and run their AI method every frame to update their AI. They can have methods for attacking other characters, taking damage, being given items, dropping items, dying and dropping all their items on the ground, etc.


I have a Cocoa based RPG engine that I've been working on for about six months (although recently I've been working on my flight sim instead). It's 3D, but the overall structure may be helpful. I'm probably going to start over with most of it, because there are a few major things I think I should have done differently (the structure of levels makes it too hard to create them, and many resources are only identified by a number instead of a name).

Anyway, since I'm not going to sell it, I probably will release it as open source so other people can get some ideas from it. I have a few things I need to clean up first, and there's no level editor yet (the files are human-readable), but I may be able to release a beta in a few weeks.