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.

Newcomers DBPro Corner / Back Again: Need Assistance With Essential FPS Components

Author
Message
Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 15th Aug 2011 15:40 Edited at: 16th Aug 2011 11:27
Hey guys

I made a thread earlier this year for assistance on my first DBPro project, I was very happy to discover that there is a lot of helpful

people in the darkbasic community. And a special thanks to LBFN for his immense help.I've done a bit more on the game (I've been

spending my other lesiure time 3d modeling) and I've entirely redone the map, added basic water (tranparent blue plane) and

added my own weapon with reloading and sprinting (at least the animations).


Of course many of the glitches that existed before still exist now. Here's a list on what I'm yet to achieve, and hopefully with your

help I can:


Being able to walk over other objects (instead of just terrain) (note: I am using a .x mesh for my terrain)


Finding out how to use fuctions for mouse and key release (so I can zoom in and out of ironsights and change gun animations after

sprinting)

Getting some kind of collision with objects other than terrain


Getting my skysphere to move with the player


Getting lighting and shaders to work


There is of course other things but I'll cross those bridges when I come to them


So as you can see, I am an idiot who thinks he can waltz through programming. But any help will be credited. Thanks in advance

Here is the games code


and here's a screenshot


and here's the dl
http://www.mediafire.com/?lv0269s2kidhd27

Poloflece

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Aug 2011 01:53
Downloaded it and unpacked it and tried to launch it, but it doesn't do anything. It will be difficult to help without having access to the media (I realize why it is packed).

wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 16th Aug 2011 04:17
Quote: "Getting my skysphere to move with the player"

Easy, in every loop do this:


this will position the skysphere to the player

Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 16th Aug 2011 06:06
@LBFN

For me the screen stays black for a few seconds then starts playing, thanks for the help anyway

@wickedly kick it

Thanks




Poloflece

Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 16th Aug 2011 11:32
I figured this would be the simplest

The game is based on a piece of code from the codebase, which allows you to walk over a .x terrain mesh. But I want to also be able to walk over other .x objects. I am currently only able to walk over 1 (it can either be the terrain or the rocks below)



this is the main bit of code for walking on it



If anyone could help me with it I will condider you as a developer of the game (aswell as LBFN and wickedly kick it and I may give you some models if necessary) and will add you in the readme.



Poloflece

Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 16th Aug 2011 14:02
You are using metod: camera with gun, is that right ? I have a better metod for you. It´s pretty simple, you make an object sphere and you position your camera into the sphere.
Here is an example. (without collision)



That sphere will have (for now) sticky collision with all objects and (move object down and if object collision, move object up) when someone shot to you bullet will have collision with the sphere. With only camera+gun it´s pretty hard to do this.

the leader of Mouseking studio

Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 16th Aug 2011 15:41 Edited at: 16th Aug 2011 15:48
Thanks, unfortunately this causes my player to not be able to move more than an inch, as the terrain itself is an object.


edit: I can move, but there is no collision with objects (I can't walk on anything other than terrain) what do I need to do now?

Poloflece

Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 16th Aug 2011 16:49 Edited at: 16th Aug 2011 16:50
Ok here is the second step. You must setup collision of the other objects. You can use set object collision to boxes obj_num or you can use command set object collision to spheres obj_num
In the Dark Basic is command to setup complex collision, too, but I forgot it You can find that command in Dark Basic Help (in editor Help -> DarkBasic Professional Help -> there you find usefull information (and that complex collision too). If you want better collision system, download Sparky´s collision system (it´s very good I´m using it). When you setup a collision of that sphere and object what you want (tree etc.), you must write what does it do If object collision(obj_num1, obj_num2) then position object 1 (your sphere) object position x(1)-1, object position y(1), object position z(1) (pasition it one pixel backward)

If is it too slow, just increase -1 to -2 or bigger.
Object collision is one of the hardest things on development of games.

the leader of Mouseking studio

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Aug 2011 16:56 Edited at: 16th Aug 2011 18:32
The way you have written the collision check, you would have to perform the intersect object check for all possible objects.

The number 20 represents your terrain object in this


line. You would have to plug in all possible object numbers that you could collide with in it's place. You would have to check the distance to all of them and see which one is the closest, and set the camera position based upon that.

If you wanted to continue using that method, might I suggest using a function to generate object numbers that are consecutive. Something like this:



Of course, you would have to define CurrentObject as global and give it an initial value. You call this by using


This way, you could create all of the objects that you can collide with in the world in consecutive order, so they can be checked relatively easily using a loop.

EDIT:
Have you thought at all about using a terrain? From my experience, they are faster and are easier to work with than an .x model.

POST EDIT:
Found a terrain example that was posted by Spooky years ago (attached). Camera moves around the terrain flawlessly.

Attachments

Login to view attachments
Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 16th Aug 2011 17:16 Edited at: 16th Aug 2011 17:21
For ironsights I am using this ON/OFF system (it´s coded by me ):


its simple: when player press right button of mouse the ironsight mod (float crosshair) is 1 (activated), gun is in the new position until is rightkey pressed again then crosshair = 0. Float gunpos# is for the moving with the gun to the ironsight mod, floats waita and crossable are for the delay (until animation is played) like this, if rightclick crossable is 1 (can´t be pressed) and waita is decreased, if waita < 1 the crossable = 0 (player is able to cancel the ironsight mode) if player cancel the ironsight mode, floats are restored to values from begining.

the leader of Mouseking studio

thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 16th Aug 2011 23:29
I'm pretty sure if you use 0 as the object number when using intersect object, it will return the object number if there is a collision. You'd have to test it, I haven't used dbpro's native collision for a while.

Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 17th Aug 2011 10:12
@Poloflece
I would like to establish cooperation with you. Share models, source codes and collaborate on some projects.
Do you want to work with me ?

the leader of Mouseking studio

Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 17th Aug 2011 10:56
Yes Yes I would

Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 17th Aug 2011 11:12 Edited at: 17th Aug 2011 17:40
Ok, here is my email, plese contact me: [EDIT]email adress deleted (i want to send you my fps with models and source codes)

the leader of Mouseking studio

Login to post a reply

Server time is: 2024-11-24 02:27:24
Your offset time is: 2024-11-24 02:27:24