FPS Making-Major problems Sounds, Shooting, Crosshair

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

FPS Making-Major problems Sounds, Shooting, Crosshair

Post by dawasw »

Welcome all, i am a bit newbie, but this is a such mess on forum (especially on searching) so i decided to write for help on advnced type forum, i am making a little amateur project, it will be an fps in Doom world. (as i am a fan of Doom ;] from Id)

Now the story is not important, maps also the AI, these are things what i will do at the end (if i would even make 20% of this what i want to recive).

Now the source code has physics, movement, q3 loading maps and all these basics, teached from tutorials.

Please read this, i know this are konwn problems, but we could make a mega tutorial for fps designers in this topic!!

1.Now the problem is, or ARE:

Shooting - I tried many ways, and i still dont know how to make player shooting. I tried to make it from the techdemo, but when i "take" the code from there , use this what is needs it tells me that -> : "shoot- this function is illegal", i work in Visual c++ 6.0.
It would be great if someone give , or release (pliz!!) some kind of shooting code, i know he wouldn't like to relase his own part of code wich defines shooting, but please, i can't make shooting here!! I need somehow do this shooting. Also i saw all the topics on the whole forum, and those code examples, wich you all have showed, or they dont work, or i don't understand how they works. So if you could also explain a little of this shooting code would be great.


Sorry for my "low" english (Poland), but i think u understand me ;]

2. The second problem: crosshair

So i got the code for crosshair:

driver->draw2DRectangle( irr::video::SColor(100,255,100,100), irr::core::rect<s32>(300,299,500,301) );

driver->draw2DRectangle( irr::video::SColor(100,255,100,100), irr::core::rect<s32>(399,200,401,400) );

As i thought why it didn't work in 640x480, i noticed it must be for higher resolution of course, but turning "game" to 800 or to 1024 resolution have done nothing. My crosshair is invisible , but why?? (maybe it is a paranormal crosshair :twisted: )


3. The third: Sounds


OK, i have downloaded the audiere.h, and added to include wich my visual have in include paths, also a libray went there to (to librarys), and i took the whole code from techdemo, and this also didn't worked out, like in shooting, i tried everything, also i tried to add a header CDemo.h to include files, it have done nothing. :cry: So a little help would be good here. Especially a code describes how to use a sound playing all the time when in game.(some kind of a in game music).

Thak you for your cooperation.
Good luck for all developers.
May the force be with you :wink: .
[/b]
NovaCoder
Posts: 28
Joined: Wed May 26, 2004 11:36 am
Contact:

Post by NovaCoder »

2. The second problem: crosshair
Wouldn't it be easier to just stick the crosshair where the mouse is? You will have to do some conversion between mouse points and the screen coordinates and you'll also need to get client area only points when running in windowed mode. Once you've got the mapping right it would work for any resolution.
- Nova
brc-not-logged

Post by brc-not-logged »

For sound, try OpenAL. It's much better IMHO.
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

I have resolved the problem of sound, i use this audiere type, and it works properly now (i didnt noticed tutorial doc with it ;]), ok i will try to make this crosshair.

But now the worst is shooting, i have no idea how to make it .
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

I also have some problems with GUI,

Code: Select all

IGUIImage* img = env->addImage(rect<int>(10,10,94,31)); //loads an image

	img->setImage(driver->getTexture("base/gui/irrlichtlogoaligned.jpg")); //wybieranie skad ma byc wgrany obrazek
And in 640 image didnt appear. It compiles and links ok, everything is ok, it loads it ok, (in dos console it shows that it loaded it), maybe the position is wrong?? (10,10,94,31) <- what means these numbers ??[/code]
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

Shooting, hmm? This took me a while to get right, especially the matrix part. Here we go

1) get the absolute transformationmatrix of the gun. We'll call this mat.
2)

Code: Select all

    
    matrix4 targetmat;
    targetmat.setTranslation(vector3df(range,0,0));
    targetmat= mat * targetmat;
range is the maximum number of units the gun can fire. Note that I assume the x axis of the gun node is the one along which it should be firing. It will depend on your model and z is actually probablly more common, I just prefer x for the front of my models

3)

Code: Select all

line3d<f32> ray(mat.getTranslation(), targetmat.getTranslation()); /*set one point to the position of the weapon, the other to the X axis
    note that the line is the maximum length that the weapon can shoot*/
We have just created a line including all points that the gun can hit (assuming projectile width is negligable)

4) now we need to do a raycast. Simply feed the ray from step 3 into CSceneCollisionManager::getSceneNodeFromRayBB and the closest scenenode hit by the ray is returned

5) to determine the point that was hit, you will have needed to have created a triangle selector for each node. Test the ray from step 3 against the triangle selector of the node returned from step 4. You now have the point of the collision

6) There's some limited stuff you can do to make non-instantaneos bullets, but I won't go into it now unless you can't figure it out.

7)I think that's all. Feel free to ask if I didn't explain anything
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

dawasw wrote:I also have some problems with GUI,

Code: Select all

IGUIImage* img = env->addImage(rect<int>(10,10,94,31)); //loads an image

	img->setImage(driver->getTexture("base/gui/irrlichtlogoaligned.jpg")); //wybieranie skad ma byc wgrany obrazek
And in 640 image didnt appear. It compiles and links ok, everything is ok, it loads it ok, (in dos console it shows that it loaded it), maybe the position is wrong?? (10,10,94,31) <- what means these numbers ??[/code]
The numbers are the pixel locations that you want.

Why not use relative positioning instead of absolute? It will make your crosshair resolution independant.
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

Electron i have sent u source code for an email, if you could insert there a simple shooting function i would love you for that, i know this is noob like, but i really don't understand it too much about this matrix, and how to define it to work in 100%.

Also could u include a keyMap to shoot function?... (what a shame :oops: )

Tyn how do u mean relative?? What i should change??
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

dawasw wrote:Electron i have sent u source code for an email, if you could insert there a simple shooting function i would love you for that, i know this is noob like, but i really don't understand it too much about this matrix, and how to define it to work in 100%.

Also could u include a keyMap to shoot function?... (what a shame :oops: )
I have to go out rigth now, but I'll do my best with and email you back sometime today. I doubt I'll do a keyymap though, sorry but I've never used them. My input system in my own game is very temporary as I'm using irrlicht's input but plan to switch to DirectInput.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

:D :D :D :D :D I am so thankful to you Electron, that u couldn't imagine, shooting works superb, & it's cool, Shells marks on wall and everything works properly and as i espect. U are a master of programming in Irrlicht ;] THANKK YOU!! Also for taking the time to write this. Now i call you: My master !! :twisted:
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

Thanks, but I'm not really a great programmer, it's just that I had to implement shooting for my own fps a few weeks ago :D
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

dawasw wrote:Tyn how do u mean relative?? What i should change??
Instead of using the cursor controls getPosition() function, use getRelativePosition(). The position will now be a float between 0.0f and 1.0f. So if you wanted dead centre, 0.5f would be the same no matter what the resolution.
M!

Post by M! »

Electron: Can you explain little bit more and give an example? Thanks in advence.
Post Reply