shooting help
| Author |
Message |
Raknarg

|
Posted: Thu Apr 14, 2011 1:22 pm Post subject: RE:shooting help |
|
|
Ok, thanks. So have you tried anything yet to get your enemies working?
Wow, I just realized this is almost the exact same thing I started with XD
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
mnorman
|
Posted: Mon Apr 18, 2011 10:29 am Post subject: Re: shooting help |
|
|
No but i want the enemies to spawn like this, also how do you upload a whole folder
| Description: |
|
| Filesize: |
8.42 KB |
| Viewed: |
4462 Time(s) |

|
| Description: |
|
| Filesize: |
7.14 KB |
| Viewed: |
4462 Time(s) |

|
| Description: |
|
| Filesize: |
17.04 KB |
| Viewed: |
150 Time(s) |

|
| Description: |
|
 Download |
| Filename: |
enemy intro.t |
| Filesize: |
11.03 KB |
| Downloaded: |
178 Time(s) |
|
|
|
|
|
 |
Raknarg

|
Posted: Mon Apr 18, 2011 5:39 pm Post subject: RE:shooting help |
|
|
| Hmm... So, do you want to give the player the ability to shoot while this stuff is happening?
|
|
|
|
|
 |
mnorman
|
Posted: Tue Apr 19, 2011 11:15 am Post subject: RE:shooting help |
|
|
| yes if that is possible
|
|
|
|
|
 |
Raknarg

|
Posted: Tue Apr 19, 2011 3:43 pm Post subject: RE:shooting help |
|
|
Indeed. Well, if you wanted that, I beleive you would have use arrays instead of separate placements, like this:
Instead of:
| Turing: |
for i : 1 .. 100
Draw.FillOval (100 + i, 200 - i, 30, 30, 7)
end for
|
you would have something like:
| Turing: |
for j : 1 .. 100
for i : 1 .. 10
x (i ) := x + 1
y (i ) := y - 1
Draw.FillOval (x (i ), y (i ), 30, 30, 7)
end for
end for
|
The reason for this is because you need to check every x and y position of your enemies compared to your bullets.
@apython
Any other ideas?
|
|
|
|
|
 |
mnorman
|
Posted: Wed Apr 20, 2011 10:17 am Post subject: RE:shooting help |
|
|
| ok thanks ill give that a try
|
|
|
|
|
 |
apython1992

|
Posted: Wed Apr 20, 2011 4:14 pm Post subject: RE:shooting help |
|
|
| That looks good to me. As long as you have the bullets placed and directed properly with respect to whoever is firing, everything should take care of itself.
|
|
|
|
|
 |
mnorman
|
Posted: Wed May 04, 2011 10:37 am Post subject: Re: shooting help |
|
|
so this is what i cam up with and it mostly works, but i dont know what to do next. How do i get them to attack?
| Description: |
|
 Download |
| Filename: |
game.zip |
| Filesize: |
1.93 MB |
| Downloaded: |
150 Time(s) |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Raknarg

|
Posted: Wed May 04, 2011 3:54 pm Post subject: RE:shooting help |
|
|
The same way you set up your bullets. The only difference would be is that you set enemubulletx and enemybullety as 2D flexible arrays.
Ex. If you had 12 enemies:
| Turing: |
var enemybulletx, enemybullety : flexible array 1 .. 12, 1 .. 0 of int
var enemydeadbullet : flexible array 1 .. 12, 1 .. 0 of boolean
|
Also, to use new in a flexible array, you do more or less the same thing as a 1D array.
Ex. if you had an array 1 .. 0, 1 .. 0 and you wanted to change the second set of elements to 3:
|
|
|
|
|
 |
mnorman
|
Posted: Thu May 05, 2011 10:32 am Post subject: Re: shooting help |
|
|
| the way i have the bullets set up is that when the bullet "dies" its y value is just set to 10,000. So the bullet isn't removed from the array. So if the game goes on for a long time couldn't this slow down the computer because it has to track thousands of bullets?
|
|
|
|
|
 |
Raknarg

|
Posted: Thu May 05, 2011 8:37 pm Post subject: RE:shooting help |
|
|
Yes, I encountered the same problem when I started my game. What I did was just use an array. You don't actually need a flexible array, as I found out. You see, you porbably thought that "Oh, I don't know how many bullets are going to be on the screen, so I'll use a flexible array."
No, you don't know how many there will be. But you know haw many there WON'T be. Using this, you can just use a simple array.
When I set mine up, I had a bulletcounter that basically did this:
| Turing: |
if (shoot bullet conditions) = true then
bulletcounter += 1
(bulletsettings)
end if
|
So when I did this, I could set the element at that counter number to whatever I needed. When the bullet dies, you can set the y to 10000 if you want. Then you have the bullets moving, draw statements, hit statements, etc. in opne for loop.
See, the thing is that by the time it's the bullets turn again, it will most certainly already have died.
Did you get all taht? Needs any clearing up?
|
|
|
|
|
 |
mnorman
|
Posted: Fri May 06, 2011 10:16 am Post subject: RE:shooting help |
|
|
| ya sorry i do, i dont quite get the code
|
|
|
|
|
 |
Raknarg

|
Posted: Fri May 06, 2011 3:34 pm Post subject: RE:shooting help |
|
|
Ok. So first of all, you have an array. Now what I'm assuming you're doing right now is just checking to see if the gun timer meets the rate of fire number, then shooting. You'll do the same thing with a regular array, but there's going to be one more thing: You'll use a counter to keep track of the bullet number.
So here's what I did.
First off, set all bullets in the array to dead (lets assume there's 20 elements). Then, when the conditions of the shooting are all true (probably just gun timer > Rate of Fire number), we add one to the counter and set the conditions of the elements using that counter. I'll give you a snippet:
| Turing: |
if guntimer > RoF then
bulletcounter := bulletcounter + 1
bulletdead (bulletcounter) := false
bulletx (bulletcounter) := x
bullety (bulletcounter) := y
end if
|
This way you can access the elements one by one and only when you need them.
|
|
|
|
|
 |
mnorman
|
Posted: Mon May 09, 2011 11:26 am Post subject: Re: shooting help |
|
|
i came up with something slightly different but it has a slight glitch
| Description: |
|
 Download |
| Filename: |
game.zip |
| Filesize: |
1.93 MB |
| Downloaded: |
148 Time(s) |
|
|
|
|
|
 |
Raknarg

|
Posted: Mon May 09, 2011 4:46 pm Post subject: RE:shooting help |
|
|
First of all:
| Turing: |
for i : 1 .. 50 by 1
|
Utterly useless. The only reason you need by is for jumping numbers. You don't need that here, so for i : 1 .. 50 is fine.
|
|
|
|
|
 |
|
|