|
-
Nov 5th, 2001, 02:16 AM
#1
Thread Starter
Member
-
Nov 5th, 2001, 03:50 AM
#2
Retired VBF Adm1nistrator
Well if you want the laser to come from your player's image, then just put its start co-ordinates there. Then have them incriment or decrement depending on the direction they're facing
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Nov 7th, 2001, 12:51 AM
#3
Thread Starter
Member
-
Nov 7th, 2001, 03:04 AM
#4
Retired VBF Adm1nistrator
Okay lets say that the player's picture is imgGod, and the laser picture is imgLsr.
To make the laser come from your player you'd start off like this :
VB Code:
With imgLsr
.Left = imgGod.Left
.Top = imgGod.Top
End With
So the laser is now at the player. Then you would find out what direction the player is facing. If its simply just a left/right shooter, then just left/right, or if there are more angles involved, then trigonometry could be required.
Lets assume that the player is facing straight up, so then to fire a laser straight up would mean you have to enable a timer, or something thats going to keep updating the position of the laser and do something like this :
(assuming PicDisplay is where you're showing all this, and ScaleMode = 3)
VB Code:
If (imgLsr.Top < PicDisplay.ScaleHeight) Then
imgLsr.Top = imgLsr.Top - speedOfLaser
End If
That will make it go up..
If you wanna see an example of this goto my website (www.coolground.com/plenderj), and grab Craft, which can be found if you scroll all the way to the right. That is a game in which you can shoot lasers.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Nov 8th, 2001, 06:19 PM
#5
Thread Starter
Member
What is the picdisplay
Hey, sorry for being stupid but im learning...... What is the pic desplay/display....... whatever you said..... is it the pic ........ or just what is it....???????????? thanks
-
Nov 9th, 2001, 03:31 AM
#6
Retired VBF Adm1nistrator
Its wherever you're displaying all this stuff. If you're displaying everything just on a form, then change it to the form name.... or if you're displaying everything in a picturebox, then change it to the name of the picturebox
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Nov 9th, 2001, 02:44 PM
#7
Thread Starter
Member
-
Nov 11th, 2001, 01:22 AM
#8
Thread Starter
Member
-
Nov 11th, 2001, 02:00 AM
#9
Fanatic Member
Code:
If (imgLaser.left + imgLaser.width >= imgTarget.left) and _
(imgLaser.left <= imgTarget.left + imgTarget.left) and _
(imgLaser.top + imgLaser.height >= imgTarget.top) and _
(imgLaser.top <= imgTarget.top + imgTarget.height) then
COLLISION DETECTED CODE
end if
The above code should do square collision dection. imgLaser is the projectile being fired (from what I read the laser), and imgTarget is the object being fired at (fromn what I read imgLord).
Last edited by Gaming_World; Nov 11th, 2001 at 02:05 AM.
-
Nov 11th, 2001, 02:05 AM
#10
Fanatic Member
The code I posted in my last post may not work if LaserSpeed >= imgTarget.height, as the laser could jump though the imgTarget.
It also wouldn't matter what part of the laser hits what part of the target, it should still detect it.
-
Nov 11th, 2001, 02:29 AM
#11
Thread Starter
Member
-
Nov 11th, 2001, 04:40 PM
#12
Thread Starter
Member
Thank you
Thank you guys soo much for all the help..... finally I can now learn from looking at the code.... Thanks
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
|