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.

DarkBASIC Professional Discussion / bullet problems..

Author
Message
Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 25th Jun 2003 00:13
ive looked at every post about bullets and every tutorial i can find online about the subject, but none of them work.Its easy enough to move one bullet, but the best i can do so far is shoot a bullet.. and then shoot another.. but the 1st one stops moving or dissapears, depending on my methods. The best example i found was on here using the search engine, but the author coded it kind of funny.. instead of a do & loop, he said "disable escapekey, if escapekey = 0 then shootcode (which was listed) and then endwhile" trying to translate this to my code which i used a do&loop, it constaltly gave me errors.. most common was after from to statements, it would say that the variable didnt exist, or wouldnt let me use a variable in a simple position object command..
for example i would say
for i = 1 to 20
position object i, blahx,blahy,blahz

when compiling it gives me an error saying that my command is invalid because it doesnt follow the format object number, x,y,z
yet, in the example i was given, it didnt have this problem..the only difference was the do/loop and while/endwhile

ive been working on this bullet thing for several days now and im at wits end! please help!
Vulcan Omega
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United Kingdom
Posted: 25th Jun 2003 00:19
Hi there, try this for bullets:
This may not be a perfect method, but it works for me.







I hope this helps ya.

Vulcan Omega is closer than you think !
http://www.vulcan-omega.co.uk/
Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 25th Jun 2003 10:09
can i put this in a do,sync,loop?..
when i put it in with my code, i put it before my movement commands and put a sync,loop after my movment controls, but when it runs and i click mouse1 the game performs an illegal opperation.

heres an overview of what i have
loadmatrix
loadobjects
do
bulletcode
movement code
sync
loop

i noticed a do at the beginning of your code, but no loop... i suppose the CASE things take that over, but i have no idea how those work.

Vulcan Omega
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United Kingdom
Posted: 25th Jun 2003 12:31
The above code "should" work in a DO, SYNC, LOOP

I didn't place it because it was meant to be an example of how do bullets. You will have to modify it to suit your own needs. I'm assuming that you get an error because you are using a MATRIX not a BSP. This example comes straight out of my game (which uses a BSP) and I assure you that it works.

The layout you have should work, but always remember to read and understand what code you have in your program before using it.

You can always post some of your code here, so I can take a look and perhaps help ya out.

Vulcan Omega is closer than you think !
http://www.vulcan-omega.co.uk/
Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 25th Jun 2003 14:06
alright, i think i got it straitened out, i didnt notice the bsp and colision stuff. I rem'd it out for now. I eventually intendo to use bsps instead of matrix's also

i've tried to understand the code, and it halfway makes since, i understand whats going on but i still couldnt do it myself. I can do matrix and coordinate and moving and all that stuff easy, but computer-logic and the necessecary order still confuses me.

the gun stops shooting after the 100 bullets are out tho, i guess i need to add something to reset their numbers. possibly a reload key.

thanks tons for the help, ive been going nuts over this stuff for the last few days. i wanted to get bullets going before my trial ran out!.. because i have to wait until i have money to buy the full package!..

Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 25th Jun 2003 15:42
it seems that reloading would be fairly simple.. just resetting the ammo when it reaches zero, and bringing the object number back down to 99, but that causes an error.. i figured it would simply posistion the same object back to the camera and start moving again, but i guess since the command that keeps it moving is in effect, it trys to do 2 things at once. Then i thought i could ad a timer to how long the bullet if alive and kill it once it reaches a certain number, but id have to make an array for that, except DBpro doesnt allow you to inc and dec arrays! agh..
does hiding an object stop it from performing actions, or just make it invisable?.. i noticed the bullet his hidden if it contacts a bsp.. but i rem'd that out bcuz i have no bsps.. if i make an object hide if it crosses my matrix, will i be able to fire it again if i reset the bulletcount to 99 if it reaches 199?

Vulcan Omega
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United Kingdom
Posted: 25th Jun 2003 16:20
Yes if you hide an object it doesn't appear on screen.
If you reset the number back to the orginal and show the object when you fire it should work.
Just remember to use the same numbers when you made the bullets or you will have to remake the bullets again, which will cause problems. I hope that helps ya.

Vulcan Omega is closer than you think !
http://www.vulcan-omega.co.uk/
Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 25th Jun 2003 23:47
wooo.. ok i got it all in working order now, i even added a reload key, and a bit of bulletspread.. its nifty! its not a problem right now, but when i hit esc it performs an illegal opperation and shuts down... kinda weird..
anywayz im going to post my code in its entirety incase someone else can benefit or learn from it. It took me almost my 30 day trial 2 get this all done. (more like 15 day trial because the thing gyped me!)

MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 26th Jun 2003 04:05 Edited at: 26th Jun 2003 04:05
Hmmm...Vulcan, have you gotten your bullets to actually collide with objects in the world? I'm using a similar routine to yours (mine is sloppy, but then again it works) but I can't get the bullets to ever register collision. I'd tried using intersect object to test for possible collision, but for some reason I can't get that command to work. I can't just say

if object collision(bullet,hit)=1 then kill(hit)

because that doesn't work. If you want, I will post the gun code.

My friends' and my website for DBPro Programming:
http://unseenstudios.netfirms.com
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 26th Jun 2003 11:53

That won't remove/kill what you've just hit but it should prevent it from travelling through it.

I hear and I forget. I see and I remember. I do and I understand.
Vulcan Omega
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United Kingdom
Posted: 26th Jun 2003 14:29
Hi again,

Remember in your code you have put:



Now if you want detect for object collisions throughout your world you will have to do something like: ( For your objects in your world or your own object collision etc. )



Now in your DO, SYNC, LOOP do something like this:



Note that I haven't tried this code, but in theory it "should work". Get back to me if you have problems etc.

I hope that helps.

Vulcan Omega is closer than you think !
http://www.vulcan-omega.co.uk/

Login to post a reply

Server time is: 2026-07-17 03:59:41
Your offset time is: 2026-07-17 03:59:41