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 Discussion / How do I shoot lasers from the left and right sides of my ship?

Author
Message
Aramil
21
Years of Service
User Offline
Joined: 27th Oct 2003
Location: Wherever my feet take me
Posted: 24th May 2004 22:16
Okay, I've been programming for just under a year in DarkBASIC, but I've spent hours trying to get this to work for my 3D Space game. I need lasers to appear from both the right and left sides of my ship, and shoot forward simultaneously. The lasers and graphics I have no problem with. I just need to know how to shoot them from the sides of my ship.
sarin
21
Years of Service
User Offline
Joined: 20th Mar 2004
Location: nowhere
Posted: 28th May 2004 11:20
okay, i dont match up to your experience with db, but i think you should use fps rules. mainly, you want the laser to shoot in one direction (im assuming, and by this i mean im assuming that you have no auto targeting that would make the guns point in a different direction than the ship, though this would work anyways). you should have the lasers hidden and use the align object to object orientation with the lasers to guns(also assuming that the laser is a solid object that is just hidden, and that the guns are objects not limbs) and position the lasers at the ship position as long as a value like posanglaser#=1(maybe simpler). Next, if the fire button is pressed and posanglaser#=1, have posanglaser#=0, have them unhide, reangle to stop any bugs, change value exist# or similiar to 1, and move forward lets say 20. next, so long as the value exist#=1, have the laser be deleted. finally, if the laser is out of range or collides with another ship or object, have it hide, position and reangle to the ship, change posanglaser# back to 1, and change exist# back to 0.
there. that should work. have this thing for each laser, and assign each laser to a different gun.
ouch, cramp!

Sarin
sarin
21
Years of Service
User Offline
Joined: 20th Mar 2004
Location: nowhere
Posted: 28th May 2004 11:23
woops. do not delete the laser when the value exist=1. and have that thing with the exist outside of the if fire thing, have it in the main loop.

Sarin
Guitarman
21
Years of Service
User Offline
Joined: 31st Jan 2004
Location:
Posted: 28th May 2004 17:31
Try this:
1) use newxvalue(Shipx#,shipangle#+90,1) to get the start positions of the lasers
2) use yrotate object laser#,wrapvalue(shipangle#+90) to set it to pointing to the right.
Then, just continue as if it were firing out of the front of the ship. I dont know, it just seems like it would work.
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 29th May 2004 08:53
hmm and it can be something like this:

position object Laser,ShipX#,ShipY#,ShipZ#
set object to object orientation Laser,Ship
turn object right Laser,90 `90 degrees
move object Laser,5 `Distance from the center of the ship to the cannons
turn object left Laser,90 `we reset his orientation

Now if you want it to the left cannon, you can put 270

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
sarin
21
Years of Service
User Offline
Joined: 20th Mar 2004
Location: nowhere
Posted: 30th May 2004 06:38
here, ill make it easier to understand more codelike with object ship=1, object gun=2, object other gun=3, object laser=4, and object other laser=5

load all objects here:1,2,3,4, and 5
hide object 4 and 5

exist#=0

do

pos2and3x-z#'s=object position x-z(2 and 3)
ang2and3x-z#'s=objecct angle x-z(2 and 3)

if mouseclick() and exist#=0
rotate object 4 and 5,ang2and3x-z#'s
position object 4 and 5,pos2and3x-z#'s
show object 4 and 5
exist#=1
endif

if exist#=1
move object 4 and 5,20
if (collides with other ship or goes to far)
hide object 4 and 5
exist#=0
endif
endif
loop

Sarin
Aramil
21
Years of Service
User Offline
Joined: 27th Oct 2003
Location: Wherever my feet take me
Posted: 15th Aug 2004 05:30
Thanks. Actually, I came up with a way to use limbs. Here it is

Login to post a reply

Server time is: 2025-05-25 09:52:35
Your offset time is: 2025-05-25 09:52:35