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 Professional Discussion / circular damage indicator ??

Author
Message
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 13th Apr 2011 01:58
Did anyone knows a way how to do this? My idea was to paste image on a appropriate point on a circle that has center in the center of the screen and move and rotate that image around on the circle when player looks around. But there is a problem with this like how to move and rotate image on the circle.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Apr 2011 07:30
Can you draw a picture of what you mean?

The Internet: Where men are men, women are men, and children are federal agents
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 13th Apr 2011 11:47
With sin() you can move an object on a circle, even on an ellipse.

Also you could use the newxvalue(centerx/y/z coordinate, angle, distance from center) command for X position along with the newzvalue(,,) command for Y position, it is much more straight forward.
HowDo
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 13th Apr 2011 16:55
try this, it might do what you want.

link
http://forum.thegamecreators.com/?m=forum_view&t=161884&b=6

Dark Physics makes any hot drink go cold.
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 13th Apr 2011 17:47
@Phaelax
What i to make is a damage indicator that rotates around the crosshair in any modern fps game

@Quel
I tried to use newxvalue and newyvalue commands but i don't know how to place the origin of the plane to its center and how to update position of the object with this commands, here is my test code


@HowDo
It isn't what i'm looking for but it helped

is there a way to use newxvalue and newyvalue commands on the images?
Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 13th Apr 2011 18:10
You mean an indicator in the middle of the screen that indicates which direction damage is coming from?

Use an image that has a lot of deadspace at the bottom, like this:

Set the offset of this sprite to be where the asterisk is at the bottom, then rotate the sprite by the angle from which the damage is coming. Then draw the sprite to the centre of the screen. The more deadspace is at the bottom of the image you're using, the further away from the centre of the screen the damage indicator will be.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Apr 2011 18:41
If you are trying to show which direction the damage came from you could try something like this:


Darth Kiwi
21
Years of Service
User Offline
Joined: 7th Jan 2005
Location: On the brink of insanity.
Posted: 13th Apr 2011 19:17
I was going to suggest what Agent suggested. Draw an image and then make a sprite out of it, and place the sprite in the middle of the screen. Offset the sprite so that it's positioned with relation to the spot you want it to rotate around. Then, simply rotate the sprite as needed; this will allow you to rotate the sprite with relation to where you got hit from, too.

Also, if you want the image the blur at the edges you could use a program like GIMP to draw it and then save it as a .png file.

Secretary of Unknowable Knowledge for the Rock/Dink administration '08
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Apr 2011 19:31
Quote: "I was going to suggest what Agent suggested. Draw an image and then make a sprite out of it, and place the sprite in the middle of the screen. Offset the sprite so that it's positioned with relation to the spot you want it to rotate around. Then, simply rotate the sprite as needed; this will allow you to rotate the sprite with relation to where you got hit from, too."

The problem with rotating sprites is they tend to get distorted by DBP. An image on a plane looks much 'crisper'...

Anyway you can use the code I posted to get the angle and do whatever you want with the variable

Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 13th Apr 2011 19:38
DBPro handles sprites as textures on a plane. The end result of both our techniques is identical. There's no distortion whatsoever in a rotated sprite.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 13th Apr 2011 21:36
Quote: "It isn't what i'm looking for but it helped"

how is that not what you're looking for? Could you draw a picture? I see of no reason you couldn't use that code snippet to make a circular anything on your screen.


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Apr 2011 22:41
Quote: "DBPro handles sprites as textures on a plane. The end result of both our techniques is identical. There's no distortion whatsoever in a rotated sprite."

Oh... has that been changed then cause I remember using rotated sprites a while ago and being very disapointed with the result? Unless I screwed it up some other way (which is far from impossible)

nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 13th Apr 2011 23:49
ok i menaged to get things working almost the way i want, but there is a problem when sprite is facing left and right correctly then up and down are incorrect and vice versa. run the code below but replace "DamageIndicator.tga" with anything code should work with any image.

@baxlash

can you explain to me how these two functions work?

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Apr 2011 11:14
Quote: "can you explain to me how these two functions work?"

Sure, they basically take two points in the X and Z plane and convert them into an angle. "atanfull" is a simple way of getting this angle and my code just tells it which points to use.

To get the angle between where the camera is pointing and where the damage is coming from I'm using the position of the camera for the 'origin', a point in the camera direction for the 'second point' and the position of the object causing the damage for the 'third point'. Then I just get the difference between the two bearings (from the origin).

Hope that makes sense?

As for the image not pointing the right way vertically just add 180 degrees to the angle and reverse the direction (-direction#)

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 14th Apr 2011 11:25
awww... you mean the little red stuff that pops up whenever you get hit (theoretically pointing at the direction it came from) !

Yeah it's very modern. And never helped me in trouble, but very modern.

-InDev: A unique heavy story based shoot'em ~5%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Apr 2011 11:27
Quote: "Yeah it's very modern. And never helped me in trouble, but very modern."

I found it usefull on a few games but mainly when someone was sniping me from a long distance away!

Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 14th Apr 2011 11:54
Quote: "Oh... has that been changed then cause I remember using rotated sprites a while ago and being very disapointed with the result?"

Yeah, it's been that way for as long as I can remember. Executing any of the sprite commands fires the internal 3D engine immediately (blue fog etc), which is required to create the plane upon which the sprite lives. I use this all the time, and I've never noticed any degradation in quality.

Quote: "Unless I screwed it up some other way (which is far from impossible)"

Lol

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 14th Apr 2011 16:15
Well i admit it kinda helps when it is a fullscreen stuff, i mean a 'big' flash along the edge of the screen. But not long ago a played one which has this effect around the crosshair... it was pathetic.

It is also a sensitive area for one to determine mathematically the angle of this flashy red thing according to the enemy's 3D position, and for two, how YOU as the player, determine the enemy's position from this. I mostly found myself just not caring at all and turning like an idiot until i saw the enemy.

-InDev: A unique heavy story based shoot'em ~5%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 14th Apr 2011 16:25
remember that a circle has the equation (x-x0)^2 +(y-y0)^2=r^2.
or:
x=r*sin(angle#)+x0
y=r*cos(angle#)+y0

so, as the sprite turns, get its angle then apply it in the image position.
Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 15th Apr 2011 02:56 Edited at: 15th Apr 2011 03:07
Quote: "It is also a sensitive area for one to determine mathematically the angle of this flashy red thing according to the enemy's 3D position"

Wouldn't it be as simple as finding the angle between two points on a two dimensional plane as determined by each object's X and Z coordinates? Baxslash is doing this with the example he's given to nruser. I reckon you could include a Y coordinate in a 2D damage indicator if you could think of a good way to represent relative altitude in the image (or otherwise), but whether or not a player could quickly interpret the extra information is another matter.

EDIT: How about the 'Gravidar' used in the Freespace space-sim games? It looks like an ordinary 2D radar, but the blips appearing towards the top of the display are above you, left of the display means they're to your left, blips closer to the centre of the display are ahead of you, around the edges means they're behind you, and actual range/distance is represented by the intensity of the blip - big, bright blips are close, small, faded blips are distant. It's an effective and quickly-interpreted indicator for relative position in a 3D environment; I found it a very clever solution!

Quote: "and for two, how YOU as the player, determine the enemy's position from this. I mostly found myself just not caring at all and turning like an idiot until i saw the enemy."

Perhaps not everyone can quickly interpret 2D information either I suppose it's a question of style - if he wants a reticle-based damage indicator, this is the way its done in most present-day FPS games.

You can position a sprite on a circle using the formula that basjak raised (I didn't even think of using the equation of a circle for this...) and then rotate that sprite by the same angle (if that's appropriate); this would achieve the same effect as my deadspace-at-the-bottom technique, but it'll be using a smaller image which will result in an increase in speed (slight, but nonzero).

There's another way, too, but it's less efficient and mention it for learning purposes and not because I actually recommend it. You could place the indicator smack in the middle of the screen as a sprite, rotate it by the appropriate angle and then MOVE SPRITE it by a short distance so that it sits just outside the reticle. This isn't as efficient, but again achieves the same effect as the first two solutions.

There's always a thousand ways to skin any given cat without killing it

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Apr 2011 23:14
Quote: "What i to make is a damage indicator that rotates around the crosshair in any modern fps game"

Never seen a damage indicator around the crosshair before

The Internet: Where men are men, women are men, and children are federal agents
Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 16th Apr 2011 23:55
All of the Call of Duty's since the original do it. Halflife, Halflife 2 and just about every mod I've ever seen for either of them does it.

Anyway, even if they don't it's irrelevant; it's what he wants to do. I'd like to hear about the method he ended up using, and if it worked well enough for him?

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Apr 2011 00:02
I play CoD and never seen that before. And the way he explained it was different than the solution ppl have come up with. Damage indicators yes, but it doesn't sit around the crosshair like it was originally implied.

The Internet: Where men are men, women are men, and children are federal agents
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 18th Apr 2011 02:26 Edited at: 18th Apr 2011 02:27
Here's a nice example:


Login to post a reply

Server time is: 2026-07-18 14:27:02
Your offset time is: 2026-07-18 14:27:02