Jump to content

Making Games Thread


Sabre

Recommended Posts

Since there are a few people making games, mods ect. And rather then keep making threads I have decided one common thread might be usful maybe.

As you probley know, I'm making enemies for my game at the moment and I've ran into a bit of a problem with workflow.

Simply put, I have a master enemy class. This contains all the common elements (thinking speed, player finding, ect.) but since so many elements are going to differ, is it worth just duplicating code for each enemy?

For example, all enemies stop thinking when dead to save resources. All enemies think at a rate of a third of a second. All will know how to see the player. However, each has many unique elements. eg. Zombie just charge forward if they have line of sight. Crawlers however move in sharp bursts and will (hopfully) dodge bullets. (think of those green buggers from geometry wars)

So, if it worth trying to make a common movement code in the pairent, or just have each enemy have unique movement code even if 2 or 3 will share the same basic movement?

Link to comment
Share on other sites

  • 5 weeks later...

I love to program, but I'm still a novice at game programming. One big problem with your post is that you should state what language you use. Some are more powerful than others. Some are better suited for gaming than others. But, I'll assume that you are using C++ since I have no idea how to use flash. Now, I use "JustBASIC" a BASIC programming language and it's a good foundation for just about anything. I had an idea, but I have not implemented it yet. I assume that by class, you meant character type and not classes as in C++ structures. What you could do is use data statements. Just put them in the bottom of your program and have some system where the computer calls say, 5 numbers. The first will always be the health, the next the speed, the third the attack power and so on. This way, you just have to use some nifty subroutine to call upon each enemy depending on their characteristics. That's one idea and it does translate into writing code for each individual enemy, but just in a simpler way.

Idea two: you could keep that master class and just diminish the rate of each parameter of that master class by a given percent. What I mean is that if the boss class which will be the hardest will have 500 attack points, you could use the same variables, but just multiply those variables by fractions. Grunts have 10% of a boss's attack, so just use the variable [call it A] and just put a .1*A and make that become the grunt's attack power. So you could set variables for each fraction. T is the ten percent [T=.1] and A is the base attack, [A=500] so when a grunt appears, GruntAttack=T*A which would equate to 50. I don't have a play by play for how to do this, but I am trying to use these ideas myself. I believe that they could work. Just remember that order and flow are the keys to an efficient A.I algorithm.

As for behavior, you may have to make that quite general. The 'crawler' you described could have an erratic movement pattern which could be stored in either some subroutine or function. But note that it must be so general that it works for practically all parts of the game's map. Don't want any huge glitches. For other behavior, just do the same as stated before and log it into a subroutine.

You may need to make a function that randomizes the enemies. When it is picked, the function should be able to point the program into all of the proper spots to attain the behavior, stats and appearance frequency of the enemy. It sounds tough, but if you can do this, other games will become easier to debug, for you have a stable and organized way of creating and implementing your enemies.

Big note: always have a restrictions function. If your max screen output in the x direction is 500 pixels, then when the enemy gets there, have some kind of result that will stop them from going off screen. In my program which has the letter Q moving across the screen endlessly, when it reaches the end of the screen, I just set it back to the beginning with an if then statement.

I wish you much luck fellow programmer. I hope that I at least make some kind of sense. Feel free to ask any more questions, but I really wanna know what language you use. Thanks in advance. I felt sorry for you than no one replied to your thread, so I thought that I'd at least give a good college try to put you in some kind of direction.

Link to comment
Share on other sites

I don't post here much anymore unfortunatly. It was only popped in to check PMs.

As for what language, in my exp it doesn't really matter. The basics are all the same, sometimes terms change or things are done slightly differently, but I'd guess 99% of it is the same stuff. The same general ideas work in all languages.

For example. Half Life 2. A mod put a script support add on into the mod. Now all weapons were controled by a text file. On paper this sounds great, in practice instead of changing sk_max_ar2 you changed ar2_max_ammo which is pointless. The effect is the same, change the max ammo for ar2.

As for language, I mentioned in my SFO blog, and you likely hate me for this, at present I am using Game Maker. Yes, it get's a bad press as babies first programing or only capable of making crap, but to be honest, it's quicker and easier. In C# it took me almost 2 weeks to make an space invaders clone. In Game Maker, it took me hours.

Link to comment
Share on other sites

Personally I'd copy-paste the common code, unless you have 10+ kinds of enemies.

Ehh, it depends. If you use the common code many times, it's better to add it as a function, rather than copy and paste it over and over again. In fact, I use functions a lot more often than copy-paste. Actually, I created a vector library for use in Game Maker for representing 3D vectors as lists. It doesn't help that it's incompatible with matrices and quaternions, though. One day, I will make those conversion functions... one day. Oh, and a slerp function too.

Link to comment
Share on other sites

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
×
×
  • Create New...