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 / the making of a radar

Author
Message
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 2nd Jul 2004 22:38
hello people,
can someone tell me how to make a radar (without using functions) for an FPS game. i'm not asking for code, i'm asking for some steps and algorithms. i'm using DBC.
thankx

Physics coder
20
Years of Service
User Offline
Joined: 25th May 2004
Location: United States
Posted: 3rd Jul 2004 04:45
you would need a circle, and in the circle a dot for the player
for other things, like having other things on the radar, you would need to get the position of the other thing - the position of the player, you would also need to decide the scale of the radar, like 20 pixels on the radar = 10 feet in the game world or something. and if the object is too far away then don't show it on the radar.

-----------------------------------
To delete the bug, delete the code.
Specs: Sony VAIO Laptop, Windows XP, P4 2.8Ghz, 512MB RAM, ATI Radeon 64MB video memory, DBP Upgrade 5.3.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jul 2004 05:24 Edited at: 3rd Jul 2004 05:25
1 - Calculate the distance between you and the enemy.

Simple pythagoras. If the enemy is too far away, don't bother going any further.

2 - Calculate the angle between where you are looking and where the enemy is.

Use the atanfull() function to locate the absolute angle from your current position to the enemy position, then subtract your viewing angle.

3 - Calculate the position on the radar.

Use the angle with sin and cos each multiplied by the distance to generate a set of radar positions, and then scale them to your radar size. Add in the screen coords of the centre of your radar and you can then use the dot command to draw it

I have example code that does this, but as it uses functions I guess you won't want to see it

But for everyone else, here it is:



The code is for DBPro, but should run with minimal changes in DBC

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Drew Cameron
20
Years of Service
User Offline
Joined: 30th Jan 2004
Location: Scotland
Posted: 3rd Jul 2004 05:35
That's pretty useful IanM, thankyou as well
Might have a good use for this code...

The Dumbo website is now running!

http://www.ddrw.dbspot.com/new
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 09:57
ya it seems pretty cool but when i load it up it doesnt track anyone it just has the circles.

thx anyway tho for this great code!!

mulletman47@aol.com
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jul 2004 10:42
Quote: "it doesnt track anyone"


It tracks every object that you tell it to track. Take a look at the FOR loop in the Radar function.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 12:59
do i change the "i"s into the object i want?

mulletman47@aol.com
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Jul 2004 19:34 Edited at: 3rd Jul 2004 19:38
for i=10000 to 10009

The loop will go through all object number from 10000 to 10009. Which is only 10 object total.

Another way to have a radar is to create a mini map. Say your world is 1000x1000 units. Just take the object's real world coordinates, and scale it down to a smaller map size of say 20x20.

map_object_x = (object_X * 20) / 1000 + offset_x
map_object_z = (object_Z * 20) / 1000 + offset_z


Where the offset variables are the location of the map. This is just one way to avoid using a distance function, slow sqrt().

"eureka" - Archimedes
D I G I T A L
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location: Dubai, UAE
Posted: 5th Jul 2004 02:51
but guys, y dont u read my question again. if u havnt noticed is says without using functions
i'll have to ask for some code if i use a function, i'm not good at it. thanks anyways.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Jul 2004 18:29
I suggest you learn to use functions. While its quite possible to create a game without them, its not a good idea. Functions can reduce code, make it cleaner and easier to read.

"eureka" - Archimedes
o0 Static 0o
21
Years of Service
User Offline
Joined: 27th Aug 2003
Location: Belgium
Posted: 6th Jul 2004 21:50
Here is the radar code for DBC users.
It is a bit messy but i think it is oké.
o0 Static 0o
21
Years of Service
User Offline
Joined: 27th Aug 2003
Location: Belgium
Posted: 6th Jul 2004 21:53 Edited at: 6th Jul 2004 21:56
Above code was rong. SORRY
This is the right one.

Login to post a reply

Server time is: 2024-09-22 16:39:43
Your offset time is: 2024-09-22 16:39:43