Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / [dbpro] making/using bullets

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 24th Oct 2005 07:11
this code is not showing the bullets, and i am not sure how i could delay the decrease in the ammo.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 24th Oct 2005 22:29
Create a delay variable.

Every time you shoot and delay = 0, you reset the variable to for example 100. In the loop, you keep decreasing it until it reaches zero again.

Some pseudo-code:


It should work

Immunity and Annihalation makes Immunihalation...
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 28th Oct 2005 04:05
your 'shooting code' part is what i'm having the problem with. It won't show the bullets that I am shooting.
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 28th Oct 2005 04:31
this is my basic set up:

1. a limb is created and hidden which is the gun's range; different one for each gun.

2. when the mouse is clicked, and 'r' is not being pressed, a bullet is fired/created and moved at a certain rate and a certain speed

3. the bullet is moves toward the position of the limb when it was fired until it reaches it's range or it hits the enemy.

4. if the bullet hits the enemy, his hp is decreased by a certain number and the bullet is deleted.

5. this goes on until the ammo reached zero

I had a code but i erased it on accident. It didn't work anyways. How would you go about doing it. This is my source right now:

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 28th Oct 2005 18:16
You forgot the positioning part...

It may also be a good idea to make a number of bullets before the shooting itself and hide them. (And ofcourse, show them when fired). Make as much bullets as one clip for example, and everytime you reload, you can use all these bullets again.

Immunity and Annihalation makes Immunihalation...
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 30th Oct 2005 10:57
mind forking over some code??? please!!??!?!? you don't know how frustrated i have been trying to do this task that sounds so simple.
Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 30th Oct 2005 11:12 Edited at: 30th Oct 2005 11:13
Quote: "mind forking over some code??? please!!??!?!? you don't know how frustrated i have been trying to do this task that sounds so simple. "

this hides shows and positions objects



Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 31st Oct 2005 04:22
i have the bullets made, i guess, but i'm not sure what is the best way to shoot them. i tried one way, but it was all f*ed up.

Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 31st Oct 2005 23:13
all i wanna do now is when i click the mouse, show the bullets, move them forward until they either hit the enemy or its position is the same as the limb's
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 1st Nov 2005 11:56
Alright then...



If there is anything you don't understand, just ask.

I don't get the "position is the same as the limb's" part. What do you mean? What limb?

Immunity and Annihalation makes Immunihalation...
Lv Ghost
18
Years of Service
User Offline
Joined: 1st Nov 2005
Location:
Posted: 2nd Nov 2005 19:11
you roooooool sven B

Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 3rd Nov 2005 00:22
thanks alot sven B
Quote: "you roooooool"


Quote: "I don't get the "position is the same as the limb's" part. What do you mean? What limb?"
i removed that part on accident. Each gun had a different Case number and each of them offseted a limb a certain distance for shooting detection which is useless now that I am using bullets for detection.
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 3rd Nov 2005 01:07
however, i don't quite understand:



What exactly is 101 - ammo and 201 - ammo?
and then:



What exactly is 100 + b?
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Nov 2005 08:34
well, i made 100 bullets, starting from 101. (100 + from i=1 to 100)
and i set the ammo to 100.

When shooting, I chose to use the lowest available number of the bullets, wich is 101. How do I get there? well 201 - ammo: if ammo decreases, the current bullet number will increase.
Maybe you'll say "but bullet 201 doesn't exist right?". Well, it doesn't have to, if you're ammo is 0, you cannot shoot anyway.

This is the same with the 101 - ammo. But here I had to get a number ranging from 1 to 100.

And eventually, the 100 + b.
As you see, there is a for-next loop in the main loop for controlling each bullet separately. This for next goes from 1 to 100. But this means, that if I want to use the object number of the bullet (wich ranges from 101 - 200) I have to increment it with 100.

Tell me if you don't understand, cause I know my english isn't great.

Sven

Immunity and Annihalation makes Immunihalation...
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 4th Nov 2005 23:27
Quote: "Tell me if you don't understand, cause I know my english isn't great."


You know what, I hadn't really realized you weren't English until I just looked at your location. You're very fluent. Thanks for the help. I'll try it out now.
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 5th Nov 2005 01:36 Edited at: 5th Nov 2005 02:15
ok, i got it working now, but now i have a quarrel on the part of the code that prevents shooting at high speed, one of my guns (tommygun) shoots at a high rate and the bullets move at a high speed. another (rocket launcher) shoots at a low rate but a high bullet speed. and the last (rifle) will shoot at a moderate rate and the bullets will move at a moderate speed. please explain what will i need to accomplish this?

another question is the one about the


explain in detail what bulletlife(b) is. I know it's referring to the bulletlife array declared at the beginning of program, but that's it. Earlier in the code, there were 100 variable slots called bulletlife. Later on in the code, bulletlife was set at 1000. On this part of the code, if the variable (1000) is greater than 0 then decrease it by 1. But, this is inside a for/next loop and it will only do it 100 times. So shouldn't bulletlife = 900? Is the part that says
Quote: "bulletlife(b) = bulletlife(b) - 1"
telling the code to decrease the variable within the bulletlife slot once by one each time it goes through the for/next loop , or constantly to the point where it reaches 0 before it gets to the end of the for/next loop?!?!?!?!? i hope you understand what i'm saying.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 5th Nov 2005 10:05
No, bulletlife will be decreased by one. The b changes from 1 to 100. So each array that is greater than 0, has to be moved.
When writing this down in full you get this:

if bulletlife(1) > 0
...
bulletlife(1) = bulletlife(1) - 1
endif
if bulletlife(2) > 0
...
bulletlife(2) = bulletlife(2) - 1
endif
if bulletlife(3) > 0
...
bulletlife(3) = bulletlife(3) - 1
endif
etc..

So not 1 decreasing by 100. But 100 decreasing each by 1.

Immunity and Annihalation makes Immunihalation...
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 6th Nov 2005 08:13 Edited at: 6th Nov 2005 08:44
well then
wouldn't this

do the same thing as this?
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 6th Nov 2005 13:57
I reread your previous post.

Here's what bulletlife() does:

I created 100 bullets. And I had to figure out a way to have data for all created bullets. However, it's pretty difficult when using bulletlife1, bulletlife2, etc. if you have 100 bullets so I created an array. Wich means that
bulletlife(1) is the data of bullet 1
bulletlife(2) is the data of bullet 2
etc.

(I think this is what you already knew)

The reason i chose the name bulletlife was this:
When you shoot (mouseclick), the program will take the lowest bulletnr that is available (that's what the ammo is for) and set his life to 1000.

In a for next loop, I check for each bullet if his life is > 0. (when 0, the bullet is not active, >0 means that the bullet is flying in the air)
So when the bullet is flying, it has to move, until it hits something, because then it stops and hides itself again(bulletlife = 0). To prevent from flying around the whole game, i decrease the bulletlife until it reaches 0.

I hope you understand

BTW: the previous post was about this:
Quote: "On this part of the code, if the variable (1000) is greater than 0 then decrease it by 1. But, this is inside a for/next loop and it will only do it 100 times. So shouldn't bulletlife = 900?"


Cheers

Sven

Immunity and Annihalation makes Immunihalation...
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 7th Nov 2005 03:29 Edited at: 7th Nov 2005 03:34
ok, but this question stands:


wouldn't this



do the same thing as this?

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Nov 2005 17:54
Yes, except that the first will not work in DBC.

Immunity and Annihalation makes Immunihalation...
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 9th Nov 2005 21:55
thas cool cuz i'm workin' wit' pro
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 9th Nov 2005 23:22 Edited at: 9th Nov 2005 23:24
why isn't this code running? I know it has something to do with my shooting code, but i do not know what

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Nov 2005 19:24
You forgot "return" after the shooting sub.

Immunity and Annihalation makes Immunihalation...
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 11th Nov 2005 03:47
oh, duh... lol

Login to post a reply

Server time is: 2024-09-24 07:22:12
Your offset time is: 2024-09-24 07:22:12