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 / Can someone solve this?

Author
Message
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 30th May 2004 01:15
Hi guys!

well...some of you know that I'm making a tank game, but I need a solution to this: The problem is that I have problems aligning my bullet to the turret's orientation. The worst is, that the tank can be tilted down in his Z direction, but then the turret goes up (like real life). What I want is a correct align of the bullet with the turret's cannon.

I've uploaded the source and media files for you all to test and help me to solve this.

I don't have too much math so I can't use con or sin, if you know how to use them, put them if it works.

Someone help me with this, please

http://darkguy.redgaming.net/files/tm_source_and_media.zip

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
nuclear glory
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 30th May 2004 08:30
We recently created a tutorial about the sine/cosine.

It can be found with our other tuts at:
http://www.nuclearglory.com/tutorials.php

Lead Programmer/Director
Powerful Collision DLL for DBPro and DBC: http://www.nuclearglory.com
Lightwave Scene Exporter to .X also at: http://www.nuclearglory.com
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 30th May 2004 10:06
whoa, nice tutorials indeed, you've helped me to understand what's are sin and cosine and how to use them thanks

now, for getting the X and Z pos I know how to do it (it aligns correctly in the rotating part), but when my tank rotates in his Z direction, the bullet pos doesn't change or rotate like the tank does....try the code and you'll understand..c'mon, it's jusst 900 Kb

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 30th May 2004 14:23
You want the white sphere to stay at the tip of the gun barrel and at the same angles as it? That will depend on how you are going to make the barrel raise and lower. Are you going to raise and lower it with model animation (with barrel being part of the turret model),make the barrel its own model and use animation in the model or are you going to make the barrel be its own model and animate it with code? I don't see any code that raises and lowers the barrel.

In any case go here and have a look at Phaelax's post
http://darkbasicpro.thegamecreators.com/?m=forum_view&t=32358&b=7 it may help you.

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 30th May 2004 14:27 Edited at: 30th May 2004 15:39
I've tried your code and when I run it I keep getting either "specified angle must be 0 to 360 degrees" or all I can see is the bullet and no tank.
by the way the file size was about 300kb, am I missing something?
rob

was only getting those probs when running your code whilst still online, works when not online.will have a look at it.
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 31st May 2004 00:18 Edited at: 31st May 2004 00:20
@Lost in Thought: yeah, that's it. Well, that isn't implemented yet, but I'm gonna do it using the same system as the turret (glue object to limb). I tried phaelax's code and it just does the same that my own code does, just in a different way.

@bibz1st: strange very strange, I just downloaded it and tested it and it worked perfectly, take in note that it's DBC not DBP. Also..well, I messed up with the file size it was 300, not 900 xD sorry

I did a small "video" on gif format to show what's my real problem, in a "graphical" way



if the image doesn't show, use this link:
http://darkguy.nexuswebs.net/tankvideo1.gif

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 31st May 2004 01:21
I get a you are not authorized to view this page error when trying that link.

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
Balid
21
Years of Service
User Offline
Joined: 21st Nov 2003
Location: MI, USA
Posted: 31st May 2004 01:28
DARKGuy,

I've not looked at your code but what I do is:

Place the round at the end of the barrel and rotate the round the same direction as the barrel using the limb direction commands.

I found it to work nicely.

Your link does not seem to work

The jpg of your "Tank Master" game looks good.

Balid

Balid
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 31st May 2004 01:32 Edited at: 31st May 2004 01:37
oops sorry I forgot, that hosting doesn't let me to put the images in any other place ...ok ok, it's right now


if it doesn't show: http://darkguy.redgaming.net/tankvideo1.gif

BTW the turret isn't a limb, it's attached to the tank by GLUE OBJECT TO LIMB, so it's a separate object...

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 31st May 2004 05:30
:bump: hmmm anyone?

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 31st May 2004 06:53
This will fix your problem in your gif. You will have to modify it though when you get your barrel raising and lowering.


"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 31st May 2004 08:16 Edited at: 31st May 2004 08:19
Whoa Lost In Thought! very very close!!! thanks!, now it tilts somewhat correctly, but now this is happening (oh god )

(screenies resized)

it's good when it's like this:


but when I rotate the turret...:

This happens...any way to correct it?

sorry for bothering too much

/edit: fixed the urls

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 31st May 2004 08:22
I fixed one problem and caused another lol.

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 31st May 2004 08:26
lol well but comparing on how it was before, it changed in a awesome way, now there's only one problem, and it's the Y pos...hey, the horizontal tilting problem is solved

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 31st May 2004 12:16
I thought of an idea. Create a dummy object object. Add it to the tank as a limb and offset it accordingly to the end of the barrel. Then, by using the various limb commands to get its position, you can calculate the coordinates of the tip of the barrel.

"eureka" - Archimedes
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 31st May 2004 12:55
@Phaelax: you know phaelax, you're a genius! I did what you said and it worked perfectly!!!! wow, thanks man . Also...that's what Balid said and I just didn't heared him...sorry

Lost in Thought: sorry for bothering you, anyway, you all will be in the credits for helping me thanks guys . Now I have to correct some little tilting problems with the tank and I'm all set...I was just wondering...there's any lens flare graphics out there? or how are they painted? you know, I wanna add a camera effect when it looks to the sun and all that...also...there's a tutorial/code for doing it?

Thanks!!!!!!!!!

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 31st May 2004 22:15
Don't worry about it ... Helping you helps me too. As a matter of fact I just used the stuff I helped you with in my game to position a rocket infront of a rocket launcher. But yes Phaelax's way is much better for 3rd person stuff. Glad you got it working!

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 31st May 2004 23:08
heheh well, it benefit both of us then good luck for us both

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 2nd Jun 2004 18:33
Darkguy, I think you should look at the tank demo and see how it is made to tilt over a matrix, yours just doesnt do it correctly when facing certain directions, ie, when going downhill the tank faces up and visa versa. I have used your tank and made the turret into a limb and used a stripped down version of the tank demo code for tilting.I havent implemented any of your other code though.For this to work you will obviously have to turn the turret into a limb.
PS
the turret bobs up and down nicely too.
see code below and tell me what you think.
rob
Supremacy
21
Years of Service
User Offline
Joined: 30th Dec 2003
Location:
Posted: 2nd Jun 2004 19:06
i know how to do it with math cos and sin, but there is a much easyer way to do it, just make a joint in the end of you tanks turret, do you understand ? a bone or joint in your 3d editor,

then you just have to use the comand "glue object to limb" or somethign like that, its easy men !

I will make urban chaos 2, ive already concepted the story, its my dream, i wont to go to muky foot
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 3rd Jun 2004 02:34
@bibz1st: wow, very nice example thanks. I've tried to adapt it to my code but it doesn't work... know why?


@Mustra Joao: well, that's what I did, but using the limb commands and adding a limb

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
Balid
21
Years of Service
User Offline
Joined: 21st Nov 2003
Location: MI, USA
Posted: 3rd Jun 2004 06:59
DARKGuy,

Does your Turret object have any limbs? I see you have a for-next loop checking to see if any do exist and then your trying to add the 'end of barrel limb' as the last limb. If you do find that the Turret object has a barrel limb, add your 'end of barrel limb' as the last limb and link it to the barrel limb, and offset it so it is at the end of the barrel.

Now that I relook at your code, it looks like your already trying to this. Instead of the for-next look there is faster way (I think?)of getting the number of limbs an object has.

perform checklist for object limbs 1
a=checklist quantity()


Than add your limb at a+1.

Anyway, I don't know if any of this helps.

I'm working on a tank game too and need to update my old site with the new version. (If your interested I'll drop a line in the 'Program Announcements' section. You can see what I've done and if it looks good to you I'll share what I did to get the effect.)

Balid
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 3rd Jun 2004 08:00
lol I did know there was a way to do it but I didn't remembered that in the moment I coded it hehe thanks

by the way the firing thing is corrected now, now I have to correct that tilting problem...any help with my code?

BTW yeah, it will be a good idea , post there and I'll see

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Jun 2004 17:07
Here's some code from a game I never finished for the ski-compo. Plz excuse the sloppiness of the code. This should work in both classic and pro.


Think of the white block as a person, the blue block as a snowboard.
Board tilts to matrix, and also slides down hills.


"eureka" - Archimedes
zircher
22
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 3rd Jun 2004 19:32
As an alternate minimal math method:

1. position the bullet at the same position as the turret
2. rotate the bullet to match the turret's global rotation
3. use pitch up to match the barrel's angle
4. use move object to place the bullet at the end of the barrel

5. continue to use move object to fire the shell but apply gravity * time to the final position each loop so that it eventually arcs into the ground.
--
TAZ

History did not begin with PONG. -- Greg Costikyan

Game Beavers
Cyberflame
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location: Im not sure....
Posted: 3rd Jun 2004 20:09 Edited at: 3rd Jun 2004 20:11
[EDIT] dang i didn't realize someone had already solver the proble the exact same way... oh well. i included code!

dark guy! i have the solution. ok in my game this is how i did it.
1. position the sphere (hidden in the center of your turret.
2. set object to object oritentation sphere,turret
3. move object sphere, (length from middle of turret to end of turret (i just played around a bit to get this value))
4. show object

heres the code from my game +P


I tried all the fancy sin cos stuff too. this does it with half the maths

bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 4th Jun 2004 14:41
Darkguy, Glad its sorted now, btw I only just noticed in my code I didnt even put the bullet in there which was the point of the whole exercise, I got carried away with the tilt and rotate prob, oh well!
Also is there any particular reason why the turret is a separate object? just wondering why you didnt make it part of the tank
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 4th Jun 2004 22:59
@zircher and cyberflame: don't worry guys, thanks anyway, as the problem is sorted now

@bibz1st: lol!

BTW for not making another post...someone can help me with that tilting problem? I tried to adapt it and screws up very bad, and don't know why

here's the code, if you wanna test it, download the media at the start of this thread then replace the source code with this:


Thanks in advance
-DARKGuy

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::

http://darkguy.redgaming.net
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 5th Jun 2004 04:27
:bump: bumpity bump bump anyone here?

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::

http://darkguy.redgaming.net
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 5th Jun 2004 04:33
I may have time to look at it later tonight. But, Nuclear Glory would make that a piece of cake. I'll see what I can come up with.

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 5th Jun 2004 04:47
hehe alright, thanks! any help is appreciated

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::

http://darkguy.redgaming.net
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 5th Jun 2004 05:10 Edited at: 5th Jun 2004 05:21
Is all the source here i'm getting a object doesn't exist at line 157. Also could you make the terrain less flat for testing purposes it looks almost flat here.
[edit] nevemind just remembered I have to change some stuff for it to work with DBP May be a while before I can try it.

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 5th Jun 2004 06:11 Edited at: 5th Jun 2004 09:31
oh alright...about the terrain...whoops, yeah, I forgot to change his height , BTW I think I'm gonna use heightmaps or a free matrix editor...there's any out there?

/edit: oh well, after one hour of hard work at last I found the tilting problem and solved it, it costed a lot, but it's sorted now sorry for bothering all you guys . Now what I need is to add some enemies, radar, explosions, buildings, collisions, a menu and little details ....god a lot of work but I'l do it! .

Thanks for all your help guys!

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::

http://darkguy.redgaming.net
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 5th Jun 2004 16:53
Glad you got it working.

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 7th Jun 2004 09:21
just my two cents but why do you want lens flare?
i mean yeah they add it into some fps and the like to make it look more realistic but when was the last time u looked at the sun and saw lens flare? its only caused when u look at the sun through multiple ' lens's ' or windows or something. thus the name lens flare, not sun flare or eye flare or something
just my oppinion, i think it spoils some games when not used realistically
Trav


Team EOD :: Programmer :: All round Badass

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 7th Jun 2004 10:20
this might sound stupid but ... wouldn't it make life easier to use a tag system?

create a polygon just inside the turret end; make it a different group, then child link it to the turret... name it something like tag_bullet and export;

then simply do a check for that limb name - save the limb number, then call on it whenever you need the XYZ & Rotation XYZ; it'll automatically adjust to whatever the turret is already because it's a child limb.

save time and headaches really; i mean you'd of already had to do this with the turret itself in order to allow it to freely move.

DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 7th Jun 2004 10:48
@Travis: well, the game will be in a cockpit view and in a chase camera, and because it will add a nice effect in the sun

@Raven: that's what I did, and now it works perfectly, thanks Raven

:: Pentium 300 Mhz, 8Mb video card, 64Mb RAM, 5 gb & 1.6 gb HD's, W98SE, Sound Blaster AWE 32 ::

http://darkguy.redgaming.net
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 9th Jun 2004 22:00
How did you solve your tilting problem?
I have been playing around with the tank thing and have come up with the code below.The tank now has a limb(hidden) for positioning the camera, a limb(hidden) for placing the bullet at the base of the barrel and I have offset the FLASH limb to the end of the barrel and hidden it (only show it when bullet is fired.Now when bullet is fired it is pointed at the FLASH limb to get the bullets aim angle ( so it 'almost' really travels along the barrel length), decided to ditch the barrel bobbing.
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 10th Jun 2004 01:31
I think I can solve it, just give me some time because I have to go, I'll return in 1-2 hours and I'll give it a try

DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 10th Jun 2004 06:27
Well, what you have to do is, instead of pointing the object to the limb's direction, rotate it in his direction, so it will get the angle. Also, limb angles are local, they don't take in account the angle of their parent object, so you must do something like this:

rotate objecrçt Bullet, object position x(obj) + object angle x(obj,limb)....

and so on. I solved your code though, and it works correctly

I hope to have helped you





bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 11th Jun 2004 20:51
The code I was using called for a different model( with the extra limbs, tank3.3ds ) so didnt need solving cos it worked for me.I would upload the model if I knew how so you could see for yourself,
I should have changed the curve values from 50.0 to 10.0 or something though, oops!

anyway thanx for taking the time to look in the first place
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 12th Jun 2004 10:12
lol so now your problem is fixed right?

hehe no prob

Login to post a reply

Server time is: 2025-05-25 03:58:32
Your offset time is: 2025-05-25 03:58:32