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 / Gun pointer / aim

Author
Message
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 14th Jul 2011 01:16
Hello everyone. I've been using DBPRO for a couple of weeks now. I made a simple square empty lvl to try everything out. It has 4 walls, ground, a gun with sound, a bullet with collision detection and 2 boxes to control a health DEC and INC. The thing I'm trying to find out now, is how I should make a gun "pointer".

A red circle with a dot in the middle that points where the bullet is going.

I tried making a plane with a transparency texture BMP format, rotated it, and sticked it a bit in front of the camera but I don't see it at all, and as far as I'm thinking this is not the way how it's to be done.

If anyone could point me in the right direction I'd appreciate it.

Here's a picture of how I'd like to have it
keep in mind there's a copyright on the gun pointer drawing i made in paint since it's so beautifull

Attachments

Login to view attachments
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Jul 2011 02:46 Edited at: 14th Jul 2011 02:48
Sorry but I'm not the best person to answer this; not familiar with creating shooter games.

Judging by your screenshot, the cursor is not in the middle of the screen, so that rules out using 2D commands or a sprite crosshair at half the screen's width and height.

However, what springs to my mind is 2D graphics positioned using the [Object Screen X] and [Object Screen Y] command at a point in 3D space where your player is pointing; IF there is no entity [enemy] intersection (collision along the line of fire); or, at the point of intersection if there is one. If not, then show the TargetObject, the actual crosshair itself, using a 'billboard' function so that it faces the camera; and a the [ghost object on] Command with a semi-transparent PNG file. Also, use [DISABLE OBJECT ZDEPTH] so that the crosshair is always visible over other objects without [DISABLE OBJECT ZDEPTH].

If TargetObject ( a hidden object ) is placed at the weapon, set in the same direction as the weapon, and moved at the firing range; then Object Screen X and Y will return the pixel co-ordinates at the end of your 'aiming vector' based on your weapon range.

But someone will probably have a better method than this...

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Jul 2011 03:25 Edited at: 14th Jul 2011 03:27
Hmm... This got me interested in the topic, so before I go to bed, I'll post a simple 2D crosshair function here and in the codebase.

It will follow the mouse position, however it could be changed to a different co-ordinate source such as an object's screen position.



Mychal B
14
Years of Service
User Offline
Joined: 21st Jul 2010
Location: Coos bay, rainville
Posted: 14th Jul 2011 10:21
I see no reason why you can't just change the cursor. Maybe I'm understanding wrong, but for my game I downloaded a crosshair cursor off the internet and loaded it into dbpro in the crosshair section. Worked great for me! There might be a command that you have to use to make it use that cursor though, can't remember.
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 14th Jul 2011 14:11 Edited at: 14th Jul 2011 14:14
i just use this for a simple crosshair.


you could always use a sprite in its place for a better crosshair, just position the sprite

(screen width()/2)-(spritesize/2),(screen height()/2)-(spritesize/2)

or the top left corner of the sprite will be in the center.

this should work well with pick screen commands.

hope this helps
kezzla

Sometimes I like to use words out of contents
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 14th Jul 2011 17:05
Hello Chris. That is exactly what I meant! I now have a crosshair in a "+" form in the middle of the screen.
My thoughts about making a crosshair were too complex


I've used Kezzla's method as a quick sollution wich also seems to work pretty good.

I will look into some sprite tutorials to see if I can make a crosshair that will "explode" the lines to each side of the screen when the gun is fired. Tips and ideas about this are welcome as I don't know much about this, I'm more into making 3d models wich you may have noticed in the screenshot.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 15th Jul 2011 00:05 Edited at: 15th Jul 2011 00:10
Ok, good. Just use Kezzla's example but swap [center text] with your [sprite] command; at the center of the screen.

You might be able to search and find source code for the crosshair 'explode' feature somewhere in the forum.

If you are good with 3D; you can animate the effect in your 3D program, join all the rendered frames into one PNG image, and use [create animated sprite] to play the sequence the way you need.

Or you could treat each part of the crosshair as seperate sprites and animate them with code. Play around with sprite positions, alpha and scale using the [sin], [cos] and [curvevalue] commands. If you are not sure what I mean by this then let us know. Remember that you can also animate the colour of sprites using the [set sprite diffuse] command.

Note that by using my function, you could set the x and y value to screen width() / 2, and screen height() / 2 respectively whilst animating the positons of the lines by changing the parameters over time during the loop. Note that you can also change the colour of the lines using the [ink] command; however, for a more polished look, sprites will be better.

Hope it goes well.


Later.

Login to post a reply

Server time is: 2024-11-27 21:48:14
Your offset time is: 2024-11-27 21:48:14