-
Dec 5th, 2017, 07:20 PM
#1
Thread Starter
New Member
advice on a long range shooting game
I usually don't do any games, but I thought it might be fun to first see if I could make just a rifle scope reticle looking down range from a shooters perspective. But I am at a loss on how to actually do it. First I was thinking a transparent image but I don't have photo editing tools at this time. Can I just draw it in VB?
Thanks for any advice on how to go about this.
-
Dec 6th, 2017, 09:01 AM
#2
Re: advice on a long range shooting game
Yes, you can draw it, and use clipping regions to give you a circle view.
I posted an example of drawing an avionics type instrument, which uses a clipping region to limit drawing to an area of the face of the instrument. In this case the area was circular, but flat on the left and right edges, so was a combination of a circle and rectangle. Just doing a circle would be that much easier. The example has a "step" mode, where you can step through the drawing sequence and it shows you the commands being done at that step and you can see the results. The instrument is still interactive, i.e. you can rotate and pitch the display while in the step mode, so you can further see how the drawing is effected by the steps that have been executed up to that point. It is attached to Post #3 here.
-
Dec 6th, 2017, 04:14 PM
#3
Re: advice on a long range shooting game
Here's an example of how to do it purely by drawing primitives as shown in the image above:-
vbnet Code:
Public Class Form1 Private _scopeRadius As Integer = 50 Private _scopeCentre As Point Private Sub Form1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove _scopeCentre = e.Location Me.Refresh() End Sub Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim scopeRect As RectangleF = CreateCircleRect(_scopeCentre, _scopeRadius) Dim lineLen As Single = _scopeRadius Dim pt1 As PointF Dim pt2 As PointF Using p As New Pen(Brushes.Black, 2) e.Graphics.DrawEllipse(p, scopeRect) pt1.X = scopeRect.X + scopeRect.Width / 2 pt1.Y = scopeRect.Y - lineLen / 2 pt2.X = scopeRect.X + scopeRect.Width / 2 pt2.Y = scopeRect.Y + lineLen / 2 e.Graphics.DrawLine(p, pt1, pt2) pt1.X = scopeRect.X + scopeRect.Width / 2 pt1.Y = scopeRect.Bottom - lineLen / 2 pt2.X = scopeRect.X + scopeRect.Width / 2 pt2.Y = scopeRect.Bottom + lineLen / 2 e.Graphics.DrawLine(p, pt1, pt2) pt1.X = scopeRect.X - lineLen / 2 pt1.Y = scopeRect.Y + scopeRect.Height / 2 pt2.X = scopeRect.X + lineLen / 2 pt2.Y = scopeRect.Y + scopeRect.Height / 2 e.Graphics.DrawLine(p, pt1, pt2) pt1.X = scopeRect.Right - lineLen / 2 pt1.Y = scopeRect.Y + scopeRect.Height / 2 pt2.X = scopeRect.Right + lineLen / 2 pt2.Y = scopeRect.Y + scopeRect.Height / 2 e.Graphics.DrawLine(p, pt1, pt2) End Using End Sub Private Function CreateCircleRect(ByVal circleCentre As Point, ByVal radius As Single) As RectangleF Return New RectangleF(circleCentre.X - radius, circleCentre.Y - radius, radius * 2, radius * 2) End Function End Class
You can move the mouse around the form to simulate aiming.
-
Dec 6th, 2017, 08:08 PM
#4
Fanatic Member
Re: advice on a long range shooting game
Not sure what kind of simulation your attempting but if its 3D then some other tips regarding implementing a 3d world to show in your window look into RayCasting which is actually very easy to do and doesnt require that much work, or go one better and look into using DirectX which is also pretty simple after a little practice...
studying some simple newton physics is also recommended if you want to implement gravity etc to your bullets.
3D engine in 250 lines (this is almost exactly how i created my first one)
DirectX.Com
Physics , this will help, but this doesnt show the position/at time but thats easy to find
Yes!!!
Working from home is so much better than working in an office...
Nothing can beat the combined stress of getting your work done on time whilst
1. one toddler keeps pressing your AVR's power button
2. one baby keeps crying for milk
3. one child keeps running in and out of the house screaming and shouting
4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
5. working at 1 O'clock in the morning because nobody is awake at that time
6. being grossly underpaid for all your hard work
-
Dec 7th, 2017, 06:19 AM
#5
Re: advice on a long range shooting game
Good posts...we aim to please here
Please remember next time...elections matter!
-
Dec 9th, 2017, 12:06 AM
#6
Thread Starter
New Member
Re: advice on a long range shooting game
OK guys I am back and thank you all for those great posts! I been spending some time researching this and reading all the comments and suggestions and testing out the code posted by Niya above, (very cool by the way!) one question though is there a way to shut off the windows mouse pointer on your code?
-
Dec 9th, 2017, 07:14 AM
#7
Re: advice on a long range shooting game
You can hide the mouse cursor by using:
...and to show it again:
Make sure you don't run either of those more often than you wanted, because they "add up" (eg: calling .Hide twice then .Show once will mean that it is hidden, because there is one more .Hide)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|