tinytim 03-13-2002, 10:05 AM ok this is what i have obja is a picture box objb is a line
how do i tell the computer not to let obja pass (please use sample code and post what library was used)
Private Sub ObjA_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then
ObjA.Top = ObjA.Top - 80
End If
If KeyCode = vbKeyEscape Then
End
End If
If KeyCode = vbKeyDown Then
ObjA.Top = ObjA.Top + 80
End If
If KeyCode = vbKeyLeft Then
ObjA.Left = ObjA.Left - 80
End If
If KeyCode = vbKeyRight Then
ObjA.Left = ObjA.Left + 80
End If
End Sub
Teric 03-13-2002, 11:33 AM Are you using the Visual Basic line control which has X1, Y1, X2, and Y2? Or are you drawing a line programmatically?
tinytim 03-15-2002, 02:02 AM i dont know i am new at this
Pookie 03-15-2002, 03:41 AM Sorry, I don't understand your question.
'how do i tell the computer not to let obja pass'
Your moving a picturebox around, and you want to test a line for something, your code doesn't even show any objb???
Please try to explain in more detail what you are trying to achieve.
Iceplug 03-15-2002, 06:54 AM If you are using a line control, you could check like this:
If KeyCode = vbKeyUp And ObjA.Top <= ObjB.Y1 + 80 Then
Then the object will go up only if it's not 80 from the line.
Hopefully, it's a line parallel with the sides. If the line is diagonal, this will require more coding.:)
tinytim 03-19-2002, 09:29 AM its a line and if i use that code what would i put after the then statement
to halt obja and objb is a line if you read the first post
Iceplug 03-19-2002, 01:51 PM After this statement to halt obja, you would do whatever it is that you use to stop movement.
In this case, you are using KeyUp.
If KeyCode = vbKeyUp Then
If ObjA.Top <= ObjB.Y1 + 80
'ObjA hit the line, so ObjA does nothing. This would be a good place to add a 'OOF' sound effect
Else
ObjA.Top=ObjA.Top - 80
End If
'You would do coding similar to this for the other directions.
Hope this helps :)
tinytim 03-22-2002, 09:53 AM that didn't work may be if i post what ive done so far as an attache ment you could help me don't scold my stupid and retarded program k
tinytim 03-22-2002, 09:58 AM oops don't have win zip just a sec
tinytim 03-22-2002, 10:13 AM sry last time
tinytim 04-05-2002, 09:21 AM im pretty sure this thread has had it
Iceplug 04-05-2002, 05:15 PM Is there any difference between this thread and "ok lets talk pacman" ?
Pookie 04-05-2002, 07:03 PM Originally posted by Iceplug
Is there any difference between this thread and "ok lets talk pacman" ?
Yeah, One big difference. They both have different titles. :D
andreww 04-06-2002, 06:06 PM what i changed isnt the best way for collision detection but it works... but it gets complicated if u want to make it a bit fancy
u should try using tiles
as with tiles u can also make a level editor, easily enough
Pookie 04-08-2002, 03:38 AM ' From your program Andreww. :)
If KeyUp = True Then MoveY = -4
If KeyDown = True Then MoveY = 4
If KeyLeft = True Then MoveX = -4
If KeyRight = True Then MoveX = 4
If KeyUp = False And KeyDown = False Then MoveY = 0
If KeyRight = False And KeyLeft = False Then MoveX = 0
You could just put this before the keychecks:
MoveX=0
MoveY=0
If KeyUp = True Then MoveY = -4
...
Only thing wrong with the collision detection routine is that it only tests the man going from right to left. :)
andreww 04-08-2002, 04:03 AM yea i sorta realised that :)
thats why i mentioned tiles
tiles i reakon are a very good idea, for the kind of game u are making
i mean u dont have to have the player moving per tile either
Pookie 04-08-2002, 04:48 AM Actually I don't even know what sort of game TinyTim is making here???
I thought this may have been part of the pacman one at first but now think he might be writing the start of a new game here....
So maybe tiles will be good for this... or maybe not. :D
Guess we'll have to wait and see.....
tinytim 04-08-2002, 09:30 AM well i first talked about it on the lets talk pacman but they got off subject and i started this thread then it died and then it arose hmm sound biblical
Pookie 04-08-2002, 07:21 PM Well that still sounds a bit confusing to me...
So does that mean this thread is still about your pacman game then? :confused:
Iceplug 04-09-2002, 07:05 AM It has the same codes so it must be. It's still on the basics, though.
The thread descended to the dead thread section. On the third day, the thread arose. :cool:
tinytim 04-09-2002, 09:19 AM yeah this must be the thread of god
(god don't strike me down)
kennethj 04-12-2002, 02:49 AM Collision detection with walls.
This is a routing from my paddle game. When ball reaches bottom its dead, so i havent cased mball.y > scaleheight.
Sub CheckIfBallHitsWall()
Select Case mball.X
Case Is < 0
mball.X = 0
mball.xway = -mball.xway
PlaySound WallHit, True, False
Case Is > ScaleWidth
mball.X = ScaleWidth
mball.xway = -mball.xway
PlaySound WallHit, True, False
End Select
If mball.Y < 0 Then
mball.Y = 0
mball.yway = -mball.yway
PlaySound WallHit, True, False
End If
End Sub
|