tower defense tower shooting help
Author |
Message |
evildaddy911
|
Posted: Mon Nov 14, 2011 2:49 pm Post subject: tower defense tower shooting help |
|
|
What is it you are trying to achieve?
tower defense game
What is the problem you are having?
I have no idea how to go about making each individual tower shoot
Describe what you have tried to solve this problem
I dont even know where to start
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Please specify what version of Turing you are using
4.1.1
Description: |
draws map, allows you to place turrets, checks if enemies(pacmen) are in range of the towers(pacmen ghosts) |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
drawmap+place tower.t |
Filesize: |
3.73 KB |
Downloaded: |
108 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Aange10
![](http://compsci.ca/v3/uploads/user_avatars/19166165534f400d42de502.png)
|
Posted: Mon Nov 14, 2011 3:05 pm Post subject: RE:tower defense tower shooting help |
|
|
you need to give us the pictures too(:
As for making it shoot here's how I'd go about it:
1) Have something telling the turrent if an enemy is in range.
2) If the enemy is in range, shoot a bullet in the direction of the turret. You don't need the bullet to follow the enemy (unless you had a homing missle of some kind)
3) The speed is a trait of each tower, so you can just scale that however you like. Allowing you to have you're turret fire in the direction of the -closest to exiting range- mob.
You could find that by calculating the distance from the endpoint.
Also, go look at baloon tower defense 4. Watch how, for instance the slow monkeys never hit the fast baloons. It's because the bullets are slow and they dont follow the baloon.
|
|
|
|
|
![](images/spacer.gif) |
vtrang
|
Posted: Tue May 15, 2012 7:24 am Post subject: Re: tower defense tower shooting help |
|
|
nc
|
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Tue May 15, 2012 1:07 pm Post subject: RE:tower defense tower shooting help |
|
|
I would have an array to keep track of each tile.
What I was considering(back when I was making an old tower defense) was making the tiles hold a string, and that string would tell the program what to put there.
0 = grass
1 = path
2 = tower
2+ = tower lvl 2
2++ = tower lvl 3
That way it's much easier to keep track of the board. That's the first step, if you're going to make this grid based.
Obviously thats my opinion, you can do it however you like. Butin the least you need an array to keep track of your tower and their information.
|
|
|
|
|
![](images/spacer.gif) |
Amarylis
|
Posted: Tue May 15, 2012 10:41 pm Post subject: RE:tower defense tower shooting help |
|
|
would something like a class to hold basic subprograms then an array of pointers to said class be easier?
|
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Wed May 16, 2012 9:07 am Post subject: RE:tower defense tower shooting help |
|
|
Yup. But I never suggest classes and stuff unless they know how to use them properly, it's just stupid to use them without any knowledge.
Then again, there's no better way to learn. However, for teaching, I'd start with something simpler, like making a button class or simething.
|
|
|
|
|
![](images/spacer.gif) |
Amarylis
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Thu May 17, 2012 1:30 pm Post subject: RE:tower defense tower shooting help |
|
|
Theres a really good walkthrough on compsci already, just so know.
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Amarylis
|
Posted: Thu May 17, 2012 2:26 pm Post subject: RE:tower defense tower shooting help |
|
|
Ah... I didn't know that
|
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Fri May 18, 2012 9:22 am Post subject: RE:tower defense tower shooting help |
|
|
The Turing Walkthrough
|
|
|
|
|
![](images/spacer.gif) |
mirhagk
|
Posted: Fri May 18, 2012 10:30 am Post subject: RE:tower defense tower shooting help |
|
|
As for the choosing which mob to shoot, sort the enemies by how far they have traveled, and the one that has traveled the most can be shot first, or the one traveled the least, or you can do the toughest or the weakest, just like bloons TD works. You can do that simply by keeping 2 arrays with (sorted by distance traveled, and by strength).
I can give you a whole bunch of tips for optimizing the process of figuring out which mob to shoot, but some of them are pretty complex, so I won't try to explain them unless you'd really like to know.
|
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Fri May 18, 2012 11:50 am Post subject: RE:tower defense tower shooting help |
|
|
Which ones are complex?
|
|
|
|
|
![](images/spacer.gif) |
mirhagk
|
Posted: Fri May 18, 2012 12:21 pm Post subject: RE:tower defense tower shooting help |
|
|
A discussion of which sorting algorithms to use, as well as which culling methods will be effective.
Basically the general rules of thumb for sorting algorithms are as follows:
1. If a sorting algorithm exists, use it. Unless you really know what your doing, and/or the sorting algorithm is terrible, or poorly suited to your application, just use the ones that exist, have been tested, and have (hopefully) been optimized.
2. If you don't know what quick sort, bubble sort, and insertion sort are, see point 1 (if you can't find a sorting algorithm search for one on the interwebs)
3. If your array is potentially already sorted, or just a little unsorted (as in the case of a tower defense game, where your array is how far people have gone, or their strength, that is unlikely to change greatly from frame to frame), use bubble sort, or a variation/optimization of bubble sort (such as sorting from both directions). Keep in mind your trying to keep the number of iterations as small as possible.
4. If consistency is not required, use heap sort (or quick sort which is sometimes easier to understand/code)
5. If consistency is required, use merge sort.
I know that these algorithms may not be the most optimal for specific situations, but these are the popular algorithms, so it'll be easier to get help when your algorithm fails.
|
|
|
|
|
![](images/spacer.gif) |
|
|