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 anyone see anything wrong whith my code for an fps

Author
Message
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 2nd Feb 2004 13:11
can u see anything wrong whith my code for my first person shooter because it just dosent work well actually its not for the whole fps just to get the gun up on the scren and make the camera move

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 2nd Feb 2004 13:32
well i remmed out the texturing matrix lines and changes the load object command to 'make object cube 1,2' and it worked fine... so im thinking its a problem with ur 3d model its self, i dont use em much and nor do i have a copy of the object so i cant help further, either try a diff. model or try to fix the one u alrdy r using
FROGGIE!
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 2nd Feb 2004 15:07
the code looks fine although its not the way i would do it, try these:

1) if you made the model in milkshape make sure its all selected before you export it

2) make sure the model isnt exactly or partialy in the same position as the camera

3) i dont like using the lock object command so try repositioning the object in each loop eg POSITION OBJECT 1,X#+5,Y#-5,Z#+3

hope it works

():x:x::::::::::::
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 2nd Feb 2004 15:59
thanks for your help but i figured it out it was the scale object commands the object was so small i couldent see it so i made them bigger now i need to find out how to shoot a bullet from it

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Feb 2004 16:06
A good way to fire bullets from guns is to position the objects pivot point at the gun barrel where the bullet will exit - then you simply nab the coordinates of limb 0.


Van-B


The nature of Monkey was irrepressible!.
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 2nd Feb 2004 16:15
could you dum it down a bit for me van b

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Feb 2004 17:16
Well....(better put the kettle on!)

An object has a pivot point already, which is at 0,0,0 - usually shown on your modelling package, it's really the centre point, when you rotate your object in DB, it rotates around this. Each seperate mesh or limb in your object also has it's own pivot point - the main centre point is based on the meshes position, it's always 0,0,0 - but a mesh pivot point can be anywhere. Luckily you can use both at the same time because the pivot points are derived from the LIMB POSITION commands, you can get the angles too.

Something you will have to consider is weapons, there's a certain way to glue a weapon onto someones hand, you can't just glue the object right onto the limb, because that usually results in a horrible hand/gun emalgamation. I like to load the weapon and character model into a modeller, then centre the model on the pivot point at which I'm gonna glue. So, I'd load in a character, and delete everything except the hand, then I'd position the hand so that it's pivot point was at 0,0,0 in the world. Now when you position your gun to suit the hand it'll be in an ideal position. Now you'd put the guns pivot point at the end of the barrel.

Don't panic if your modeller won't let you adjust the pivots (most wont), you can guess the gun positioning, then use a little bit of messing around to find that bullet exit position.

For instance:
Make a cube, then make it into a mesh.
Add the cube to your gun object as a new limb.
Offset the cube to the bullet eject position (make a little editor that displays the coordinates while letting you adjust it).
Now the cube limb holds all the bullet info you need, the angles, and the start position of your bullet.

If your planning on adding a bullet flash effect onto the gun - treat the bullet flash object as a gun itself, it should be glued onto the same limb as the gun, and is best modelled around the gun too. You can't glue an object onto an already glued object, but gluing multiple objects to limbs is no biggie.

When you come to fire a bullet, I suggest using object velocity methods instead of angles etc. It's more physics orientated, but it's also easier to handly - you simply need the bullet speed. I use a dummy object (like your cube from before) and position it at the bullet exit, then rotate it to match the limb, then move that object forward depending on the bullet speed. Once you'd done that you can easily ascertain the start position, and X, Y, Z speeds of the bullet - then you need to move your bullets every loop and check for collisions. It's not really necessary to make your bullet a proper object, for speed sakes I'd recommend that if you need to see the bullets, just use a plain with a bullet trail texture and point it towards it's destination. You'll need at least 50 for a reasonably paced FPS, so make sure that collision system is tight - I'd strongly advise sticking to interpolation (like matrices) or array (like lego) collision. An optimised collision system will ensure a decent frame rate - don't rely on DBC's built in poly collision.


Van-B


The nature of Monkey was irrepressible!.
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 2nd Feb 2004 18:33
do you know how to make it shoot loads of bullets at at time not right at the same time just one after the other really quick like a machine gun thanks in advance

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 3rd Feb 2004 09:42
if u search through the forums there loads of threads about this jt put out a good example, u should be able to work somthing off that
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 3rd Feb 2004 10:49
You would have to decide on the maximum number of bullets in your engine, say 50 - which I find is a good number for most things. You'd make 50 bullet objects, or make arrays with 50 elements for the bullets, then using a counter, you keep track of the current bullet.

If your bullet counter goes above 50, set it back to 0 - but really a new bullet will use the oldest bullet. Simply using this counter will maintain your bullets for you, no real need for fancy handling code.
That's all I did for the particles and bullets in OIE - except in OIE sniper bullets get a sorta priority, it would'nt overwrite a sniper bullet if it found one, it would go onto the next bullet. This was because the sniper bullets can travel further, and are more accurate - so they had to keep going. That was pretty simple though, I made it so that a bullet is created using a function - and it checks the bullet type after increasing the bullet number until it finds a non-sniper bullet.

To create a machine gun you should have a little delay, the last thing you want is a constant stream of bullets making your game too easy - I find that once every 4 or 5 loops is enough to fire. I use a delay variable:

In psuedo code - something like:
If fire a gun and delay<=0
set the delay to 4
fire bullet
else
decrease delay by 1
endif


Van-B


The nature of Monkey was irrepressible!.
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 3rd Feb 2004 23:45
ime posting my code if u could take a look could you tell me how to make a delay in bullets you know like you said on on my code that would be gratefull and do u know how to make your gun wobble when u shoot your probably gonna say you have to have a animater or somthing but i havent got one i load all my things off of dark basic and dark matter

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 4th Feb 2004 02:01
look , seriously irish fool everytime u post u ask someone how to do something then after they tell u how u ask them to do it for you... thats not gunna help u learn anything, if u just wanna play a pre-made fps just go download doom and if u acually wanna make ur own game then make it urself, if u are finding it too hard then start of with something simpler untill u learn the programing principles and can acually work some problems out urself. then if u get stuck u can ask someone how to do it but go code it ur self
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 5th Feb 2004 12:08
irish fool, You need to be a bit more conciderate aswell... Van B took the time out to write up those lengthy responses and you basically ignored what he has writen and just asked him to do it for you.

That's not right...
It's like Travis said, you need to do some stuff for yourself, or else you'll never learn.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 6th Feb 2004 23:01
yea ime sorry i just cant understand people all the time because i dont know much about it and i ask them to do it for me so they dont think ime dum but yea i should try to work it out myself sorry all


*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 7th Feb 2004 12:13
thats why we say you should start with a simpler game, so u can work thro the problems instead of having ones that are above your level to solve

Login to post a reply

Server time is: 2025-05-22 11:26:32
Your offset time is: 2025-05-22 11:26:32