-
[RESOLVED] ??? Please help: Missile Positon alongside the Turret Position in the game ???
Hello, I am writing a Tank Battle game, that requires the Missile to be positoned alongside the Turret (Cannon) of the Tank. Also I am looking to have the Missile to cut into the Shape, and then make a bomb blast, where and only where the Missile, had been blown up...
Also: The older version of the Project Files, have been removed by me the: OP. Please look further into the Thread, for the newly updated ones, that have been posted, by me the: OP...
!! Thanks in advance !!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Haven't downloaded your zip. But I think you might get more replies if you include a snapshot or two of exactly what you mean. It's hard to visualize exactly what you mean when you say "have the Missile to cut into the Shape, and then make a bomb blast, where and only where the Missile, had been blown up" and "the Missile to be positoned alongside the Turret"
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Leave that to me LaVolpe. I'll take a crack at his project. As you already know, I'm the game expert here in the forums. ;)
-
1 Attachment(s)
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Before I looked into your code I noticed a number of things wrong. For a gun turret, you don't want to use 3 lines for 3 stationary angles. The best thing for this would be to have it dynamically rotate from an origin which would be the tank. Try this as a test example and use the left & right arrow keys to rotate the turret:
vb Code:
Option Explicit
Private Type Vertex2D
X As Single
Y As Single
End Type
Private Const Pi As Single = 3.141592654
Private Vertex(1) As Vertex2D
Private Transformed_Vertex As Vertex2D
Private Tank_Position As Vertex2D
Private Angle As Single
Private Running As Boolean
Private Function Rotate(ByRef Origin As Vertex2D, ByRef Vertex As Vertex2D, ByVal Angle As Single) As Vertex2D
Angle = Angle Mod 360 'Keeps it within 360 degrees
'Had to use -Angle so counter clockwise is positive.
Rotate.X = Origin.X + ((Vertex.X * (Cos(-Angle * (Pi / 180))) - (Vertex.Y * Sin(-Angle * (Pi / 180)))))
Rotate.Y = Origin.Y + ((Vertex.X * (Sin(-Angle * (Pi / 180))) + (Vertex.Y * Cos(-Angle * (Pi / 180)))))
End Function
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Then
Angle = Angle + 1
End If
If KeyCode = vbKeyRight Then
Angle = Angle - 1
End If
End Sub
Private Sub Form_Load()
With Me
.Show
.ScaleMode = vbPixels
.AutoRedraw = True
.BackColor = RGB(0, 0, 0)
End With
Vertex(0).X = 0: Vertex(0).Y = 0
Vertex(1).X = 0 + 50: Vertex(1).Y = 0
Tank_Position.X = Me.ScaleWidth / 2
Tank_Position.Y = Me.ScaleHeight / 2
Running = True
Do While Running = True
Me.Cls
'For turret purposes.
If Angle <= 0 Then Angle = 0
If Angle >= 180 Then Angle = 180
Transformed_Vertex = Rotate(Tank_Position, Vertex(1), Angle)
Me.Line (Tank_Position.X, Tank_Position.Y)-(Transformed_Vertex.X, Transformed_Vertex.Y), RGB(0, 255, 0)
Me.Caption = Angle
DoEvents
Loop
End Sub
Another thing is that after running your program and entered the main game, the bullet just sits there and then explodes. Weird. Why not have projectile motion? It takes a good understanding of physics:
v0 * sin(theta)*t + (1/2) * -g * t ^ 2
but nothing you can't handle
Code:
X = (Initial_Velocity.X * Cos(Pi * Angle / 180) * Projectile_Time)
Y = (Initial_Velocity.Y * Sin(Pi * Angle / 180) * Projectile_Time + 0.5 * -Gravity * Projectile_Time ^ 2)
Located below this post is an attachment of a sample project on projectile motion using real time physics.
As for your question on how to position the shape on the turret, you need to know the X and Y position of one of your Line tips, whether its X1, Y1 or X2, Y2. And I do suggest you use one line for a turret you can dynamically rotate.
-
1 Attachment(s)
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Refer to the above post if ya missed it.
I spliced both projects together so you have a moveable gun turret and a fire button. It was fun :bigyello:
Personally I'd be doing it in DirectX but for beginner purposes, this is for you. Use A / Z keys to change the angle of the turret. Arrow keys position the tank. And the fire button is the command button.
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
!! Thanks for the Input$ !!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
@Jacob Roman, I really need your help, in this matter at hand...
Problem #1: How do you position the Turret, for both of the Tank Players??? (The Tank is something like a shape that I drew using the Shape's Tool in VB6...)
Problem #2: How do you control the colour of the Turret and the Trace Path of the orderance, as well???
!! Thanks in advance !!
PS: Jacob, you are a God sent individual that is able to help me finish one of my projects, that has been bugging me for a very long time in deed!!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Problem #1
I already demonstrated this in post #5 in the project using the arrow keys. Keys A & Z rotates the turret. For the tank body you'll need to do the same thing and add the same values to the body using Position.X and Position.Y over in the keydown event. I can even improve the controls for ya if you like so you don't get that noticable pause whenever you hold down the key :bigyello:
Problem #2
The color of the line on the turret? You use Line1.Bordercolor = RGB(red, green, blue) only red green blue being values between 0 to 255.
Again over in Post #5 I already traced the path. If you don't wanna see the path traced change this line over in Game_Loop from If Fire = False Then Cls To just Cls. If you wanna gather data for the missle as its moving, use an array. Just don't forget to reset the values to 0 when its done.
vb Code:
Private Sub Render_Projectile_Motion()
Static Missle_Data() As Vertex2D
Static I As Long
If Fire = True Then
Me.Line (Position.X, Position.Y)-(Transformed_Vertex.X, Transformed_Vertex.Y), RGB(0, 0, 255)
Projectile_Time = (Get_Elapsed_Time - Projectile_Milliseconds)
ReDim Preserve Missle_Data(I) As Vertex2D
X = (Initial_Velocity.X * Cos(Pi * Angle / 180) * Projectile_Time)
Y = (Initial_Velocity.Y * Sin(Pi * Angle / 180) * Projectile_Time + 0.5 * -Gravity * Projectile_Time ^ 2)
If Y >= 0 Then
Projectile_Height = Initial_Velocity.Y * Sin(Pi * Angle / 180) * (Projectile_Time / 2) + 0.5 * -Gravity * (Projectile_Time / 2) ^ 2
End If
If Y <= (Transformed_Vertex.Y - Position.Y) Then
Y = (Transformed_Vertex.Y - Position.Y)
End If
'Here, Y is negative because I needed +Y to be up and -Y to
'be down. By default it's the opposite.
Projectile_Screen_Position.X = Transformed_Vertex.X + X
Projectile_Screen_Position.Y = Transformed_Vertex.Y - Y
Me.PSet (Projectile_Screen_Position.X, Projectile_Screen_Position.Y), RGB(0, 255, 0)
Missle_Data(I).X = Projectile_Screen_Position.X
Missle_Data(I).Y = Projectile_Screen_Position.Y
If Projectile_Time > 0 And Y <> Original_Y And Y <= (Transformed_Vertex.Y - Position.Y) Then
Fire = False
cmdfire.Enabled = True
MsgBox "Projectile Motion Time: " & Projectile_Time & " Height: " & Projectile_Height, vbInformation
End If
I = I + 1
End If
End Sub
Also note if you ever get tired of using crappy VB objects to make games and wanna jump into some real fun, I got a massive directX8 tutorial in my sig, as well as other game and physics examples. I'm also working on a website www.massivedirectxtutorial.com (still under construction) thats gonna be dedicated to directx tutorials for VB6, VB.Net 2008, VB.Net 2010, C# 2008, C# 2010, C++ 6.0, C++ 2008, & C++ 2010, and have tutorials on DirectX7 to DirectX11 as well as XNA tutorials.
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
-- So sorry, about not getting back to you in time. But then it worked, and then I was testing the project, for the whole afternoon...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Problem, at hand := I am trying to rewrite the Render Handler of the Form that you posted on my Thread. There is something very wrong with this kind of line of command. If you could look at it for me, then that would be very nice for me, in deed...
Code:
Public Sub Render_Turret()
If Fire = False Then
Transformed_Vertex = Rotate(Position, Vertex(1), Angle)
Me.Line (frmBattle.RedTank.Left + 20, frmBattle.RedTank.Top)-(Transformed_Vertex.X, Transformed_Vertex.Y), frmBattle.Line1.BorderColor = RGB(255, 0, 0)
End If
End Sub
!! Thanks in advance !!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Well the Me.Line thing was just an example. If you wanna use Line objects instead use Line1 or whatever you named the Lines for turrets and replace all the positions and transformations I laid out within its X1, Y1, X2 and Y2 coordinates in your code.
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Problem: I don't exactly know what you mean. I know about the Line positions. But then I have done that much with it. But as you must know that I wrote a Vector Shape ActiveX Control, using only four Line Shapes, and nothing more than that. But I require more help, in this matter at hand...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Could you upload your project with the new code?
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
-- Here is the newly updated Project Files, for you to have a good look at!! Could you please help me, in my problem at hand???
!! Thanks in advance !!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Im gonna need to completely dismantle your project and start from scratch cause there are too many problems. Its taking too long to debug cause of the unneeded splashscreen that takes a whole minute to go through. Also I made a number of improvements but for some unknown reason even after removing cls and the frame using a picturebox instead, it flickers and covers your command buttons with a black box. Thats even after I added autoredraw and stuff. So I'm gonna do your program from scratch and improve it more so. It's gonna take time cause I just got a new job so be patient and keep coming back to this thread to check up on it.
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Thanks, for the time you're putting into my project!!
!! Thanks in advance !! (Even more so...)
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
-- I really would like to ask, you this...
Is there any progress that you have made with the flicking screen. I am looking at writing a DirectX Graphics Engine for it. Which right now I am sourcing code for another project that I am doing. Really not getting paid for anything that I do. And then cannot pay for anything, in return...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
The Sentry Gun is an unmanned weapon capable of autonomously acquiring and firing upon enemy targets by using thermal detection.
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
If you want, take a look at my massive DirectX tutorial located in my sig ;)
I'm also making it even more massive and revamped due to the fact there are problems. First off all I was using Form_Activate in them when I should have been using Form_Load. I also shouldn't have been using End, and I should have had DoEvents in the end of the loops and not the beginning. The massive directx tutorial I am making will be in VB6, VB.Net 2008, VB.Net 2010, C++ 6.0, C++ 2008, C++ 2010, C# 2008, and C# 2010 in DirectX 7 - DirectX11, whichever languages support the DX versions. I am also including XNA. Each language I plan on having over 200 tutorials each per DX version in 2D, 3D, and DirectDraw. It will cover every aspect of DirectX and be the greatest DX tutorial the net has to offer and be simlified in one code window rather than multiple modules, and wont have too much overhead like the DX SDK's microsoft had.
As for your game, I havent been working on it that much due to the fact I got a new job now but I'll try to work on it little by little.
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
-- Thank-you: Jacob Roman, for all of the help you are giving me on the matter at hand!!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
This post is for: @Jacob Roman, only...
In your Source Code, that you had posted to me, just recently. You didn't comment, what was the position of the Turret for each of the Tanks. Then when I find that I am then able to be able to set the .Left and the .Top for each of the Turrets, respectively to, which colour they are...
I am also working on sourcing code for tunnelling and also using the Line Shape Tool, to be using nodes to bend into place some sort of peaks, hills and also valleys that only extend on the single screen, or even the single Form, at that...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Look over at Main() in frmBattle
vb Code:
Player(1).Position.X = RedTank.Left + RedTank.Width
Player(1).Position.Y = RedTank.Top
Transform_Turret() shows it as well:
vb Code:
Public Sub Transform_Turret()
If Fire = False Then
Player(1).Transformed_Vertex = Rotate(Player(1).Position, Player(1).Vertex(1), Player(1).Projectile.Angle)
Redturret.X1 = Player(1).Position.X
Redturret.Y1 = Player(1).Position.Y
Redturret.X2 = Player(1).Transformed_Vertex.X
Redturret.Y2 = Player(1).Transformed_Vertex.Y
End If
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
-- I have made some changes to the Project Files, can you please have a good look at the Project. I've also added in CommandButton support to changing the Angle and also the Power. Can we get the Power variable to only be the one TextBox, that would seem alot easier to program when using velocity and angle variables. Don't you think???
Problem #1: There is still that over lay of black bold lines over the Screen...
Problem #2: Also there is something very wrong when you call the process of Player(1). I'm not sure and nor is the machine, sure on which control you are calling...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
!! Here is my Project Files, so far !!
PS: Could you (Jacob), look over the Project, from the Files, that I am writing. If they are any good, then please comment. Also not a lot of work has gone into it, right about now. Just working on the DirectX process, that I am working to write into it. However that could be able to cure the block blotch on the screen???
!! Thanks in advance !!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
I have been able to research and produce a DirectX Support Engine. It is in no reason to be a DirectX Engine, itself. However it just accompanies the DirectX as a Support program, and then there isn't any infringement of copyright, because I checked that this was totally legal and then I set to work on the project...
Here is the Project Files, if you want them. They might be able to get rid of the black blotch on the screen. Because we are using DirectX to support the Form's graphically instead of the normal screen graphics...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Have you had a look at the DirectX Support Console, that I wrote in the previous post, in this Thread???
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
I been pretty busy at my new job recently and spending time with my gf but I'll try to find time to
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
-- So sorry, about the upset that this Project of mine is causing you...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Wouldn't it work better to have a Tank as a UserControl, instead of having all of the Source Code being laid down beside the Game Motor, etc. I think that we could do that, because then we just have to setup properties of the velocity, angle, tank colour, etc then that would be better, don't you think??? I have been jotting down what we need, as UserControl properties, then that was what I was doing all of this time and working on the many other Projects, that I have. Also doing things with the family, etc. As anyone would do, in a week's normal days...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
It wouldnt be a better idea to treat the tank as a usercontrol cause games arent necessarely coded like that. Since its a sprite, use a user defined type instead. Its how all games are coded
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Really!!
I have been working on a Capcom Megaman game, that has all enemies and the player, as UserControls. That was the only way that I could be able to think about working out the whole thing. But you have opened up my eyes, and then that means alot, to me...
!! Thanks for the Input$ !!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Here is the Project so far. I am working on the Project, trying to get the Form to stop overlaying the black line. Still no headway in this matter at hand. I checked with the Source Code and the Drivers of the PCI Express Card, that I have. And they seem to work okay, when working in 2D and also work really well when insided 3D, and then so on. However I still think that they cannot no more display a signal that is dumber than 50hz for the monitor, don't you agree??? Becuase there was in actual fact that there was problems with Prince of Persia working on high rated video cards, of that age gone far behind. But then there was also trouble trying to microswitch the video card, in those days to the higher rate. Because of the fact that they were inferiour to the designs of the new age of computing. What I am trying to say is that maybe the process, that we are using to display the graphics on the screen. Is somewhat uisng the older VB3 for Windows v3.11, type of displaying graphics on the screen. That had many flickers when working with Bitmaps, that were 32-Bit (Win32 Session)...
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Lost the Project, going to the backup. But most of the changes aren't there, from what I have made so far. Going to strip it down and then go and remember the Source Code and then work from there. Could you also send me a copy of the Project, that you have so far???
!! Thanks in advance !!
-
Re: ??? Please help: Missile Positon alongside the Turret Position in the game ???
Also I have been able to make some kind of adjustments to the Source Code, that I had found on my Backup Drive. Then instead of rotating a Line Control. I guess that I am going to draw about the Line as a Bitmap, and then be able to rotate it inside PhotoShop. Followed by mapping the Missile to be .Left and then .Top properties, in the Source Code. It seems a bit messy, but in deed it will be able to pay off, in the right way. I guess???