Twilice

small Tower Defence in c++ (allegro)

10 posts in this topic

We are supposed to do a project for our programming course, and I have already started to think about it. It must involve at least a few things. (I am not sure what yet, but I am pretty sure linked list's and inheritance)

So it is not going to be super advanced (or well for me it could be :P) but here is the plan:

To make it more original the player chooses the amount of creeps he/she wants to send at a certain level, the minimum amount of creeps you can send will be increased over time. So if a player hesitates to send creeps he might get overrun in the end, but if he sends to many he will get overrun right from the beginning. The game will not be multiplayer that is far to advanced for me as it is now.

I want a basic tower which everyone of my other tower inherit and the towers I wanted is:

Single (target)

Splash (ground)

Linear (ground)

Bounce (target + slow)

*Slow is based around the speed of the creep (and if I got time and "skill" around which bounce of the tower), the reduction will be (0,95-0,15x) where x is the base speed of the creep.

The towers will probably just fire at the creep closest or lowest hp, if I got time I might try to give them different search functions like bouncing attacks the fastest, splash and linear the closest and single the lowest hp. (I will not keep track on which creep has moved the most, or actually that won't be so hard to program now when I think about it since they will travel the same path, the single tower could fire at the one traveling the longest)

The missiles that need it also have search functions, splash in a circular, linear in a well... linear :P and bounce will bounce of the closest.

Creeps will walk around a simple map.

Since I don't know how to make it work like a standalone program you have to have visual c++ and the allegro library "installed". But I haven't even started yet, I might have taken water way over my head. But it will definitely be interesting to work with.

Share this post


Link to post
Share on other sites

So I started picking on it a bit, mostly the thinking part and some variables.

But I couldn't really figure out a way to "lock" a certian object to another object.

I wanted my class basicTower to have a pointer that pointed to class normalCreep so it looked like this:

normalCreep *target;

Even if I included normalCreep into basicTower it didn't work, and if I inherit normalCreep it will only inerhit the variables and functions and that wont help me. Since I will need this for the missiles as well it's a pretty large step.

Share this post


Link to post
Share on other sites

You don't want to use inheritance for that. Tower and Creep should be two separate things. Perhaps the order of declarations is improper? You definitely can make it so basicTower has a pointer of type normalCreep. Otherwise, try a typedef for normalCreep ahead of where basicTower is defined. Can't really help beyond that without seeing code.

Share this post


Link to post
Share on other sites

Jupp, apparently there was a bug. So after restarting the computer and compiler it worked. But it will be far from the class of other tower defences :P

Share this post


Link to post
Share on other sites
Jupp, apparently there was a bug. So after restarting the computer and compiler it worked. But it will be far from the class of other tower defences :P

check out unity3d if you really wanna make it look good.

plus unity is fairly easy to write scripts for

Share this post


Link to post
Share on other sites

And what does it do? I am unshure this is something I could find usefull.

Share this post


Link to post
Share on other sites

Yeah but it's supposed to be a schoolwork for my programming course. And we program in c++.

I think the most important about the projects is that we use the basics that we have learned through the course and now is the time to show it off.

Share this post


Link to post
Share on other sites

The towers now search for an object called normalCreep (and all other creeps will probably inherit this object)

When the creep has died (taken more damage then hp) it will enter a "sleep" (a creep also sleeps a few seconds after it is spawned to prevent clumping - This is not the final solution unless I run out of time.) Later I will either make it simple and just add gold, give a kill and then delete the object.

The towers will start to search for new objects if the creep is "sleeping" or is out of range.

Missile are not so advanced, the will simply move x amount pixels closer to the object they are following each cycle. (so no cool "force" movement, might add this since I like physics and maths, I've already started to think about giving a constant acceleration instead that alters the speed, but time is short once again)

Remember this isn't really a big school project, I think I made it bigger then it was supposed to be. So there will be a lot of unpolished things.

*Everything updates dynamically you can add objects and they will all automatically update via pointers and a linked list. (but you can't place anything "in game" right now, that is whats next)

Share this post


Link to post
Share on other sites

I accidentally my latest version T.T

Oh well, at least I still have the working non-artistic and bad game design version.

So anyways I've taken my first step towards (maybe) becoming a real game programmer. I haven't started any of such courses yet though since it's not typed into stone. It's a very wide education, I am not sure but I think it corresponds to masters degree in computer science and computer engineering (it's actually really hard to find the correct translation I've heard it once but forgot).

Share this post


Link to post
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