[VB6] - colide with wall and stop
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop
[VB6] - colide with wall and stop [VB6] - colide with wall and stop
[VB6] - colide with wall and stop
Go Back  Xtreme Visual Basic Talk > > > [VB6] - colide with wall and stop


Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2010, 08:03 AM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default [VB6] - colide with wall and stop


i'm making a code that when the player colide with wall, the player go back(for don't continue colide with the wall) and if you continue with same direction, the player don't move.
but my code isn't 100%
heres the code:
Code:
Private Sub sprPlayer_Collision(ObjectName As String, ObjectIndex As String, PlayerDirection As pjtSprite.Direction)
    If (ObjectName = "sprWall" And ObjectIndex <> -1 And pdPlayer = PlayerDirectionUp) Then
        If blnCollisionUp <> True Then
            sprPlayer.Top = sprWall(ObjectIndex).Top + sprWall(ObjectIndex).Height + lngCollisionPrecision
        Else
            sprPlayer.Top = sprWall(ObjectIndex).Top - sprWall(ObjectIndex).Height
        End If
        blnCollisionUp = True
    ElseIf (ObjectName = "sprWall" And ObjectIndex <> -1 And pdPlayer = PlayerDirectionDown) Then
        If blnCollisionDown <> True Then
            sprPlayer.Top = sprWall(ObjectIndex).Top - sprPlayer.Height - lngCollisionPrecision
        Else
            sprPlayer.Top = sprWall(ObjectIndex).Top + sprPlayer.Height
        End If
        blnCollisionDown = True
    ElseIf (ObjectName = "sprWall" And ObjectIndex <> -1 And pdPlayer = PlayerDirectionLeft) Then
        If blnCollisionLeft <> True Then
            sprPlayer.Left = sprWall(ObjectIndex).Left + sprWall(ObjectIndex).Width + lngCollisionPrecision
        Else
            sprPlayer.Left = sprWall(ObjectIndex).Left - sprWall(ObjectIndex).Width
        End If
        blnCollisionLeft = True
    ElseIf (ObjectName = "sprWall" And ObjectIndex <> -1 And pdPlayer = PlayerDirectionRight) Then
        If blnCollisionRight <> True Then
            sprPlayer.Left = sprWall(ObjectIndex).Left - sprPlayer.Width - lngCollisionPrecision
        Else
            sprPlayer.Left = sprWall(ObjectIndex).Left + sprPlayer.Width
        End If
        blnCollisionRight = True
    End If
    If (ObjectName = "sprPoints" And ObjectIndex <> -1) Then
        If sprPoints(ObjectIndex).Visible = True Then
            sprPoints(ObjectIndex).Visible = False
            lngPoints = lngPoints + 10
            txtPoints.Text = "Points: " & Format(lngPoints, "0000")
        End If
    End If
End Sub
these movement has some problems
can anyone advice me?
thanks
(heres the entire code in text file)
Attached Files
File Type: txt my movement way.txt (8.1 KB, 2 views)
Reply With Quote
  #2  
Old 01-17-2010, 08:47 PM
Iceplug's Avatar
Iceplug[VB6] - colide with wall and stop Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Could you point out a specific case where:
something happened when you run the program that you didn't want and
what you wanted to happen?

What are the "problems" that you mentioned?

What is the value of lngPrecision?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 01-18-2010, 11:41 AM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

Quote:
Originally Posted by Iceplug View Post
Could you point out a specific case where:
something happened when you run the program that you didn't want and
what you wanted to happen?

What are the "problems" that you mentioned?

What is the value of lngPrecision?
now i reduce my code:
Code:
Const lngSpeed = 60

Private Sub sprPlayer_Collision(ObjectName As String, ObjectIndex As String, PlayerDirection As pjtSprite.Direction)
    If (ObjectName = "sprWall" And ObjectIndex <> -1 And pdPlayer = PlayerDirectionUp) Then
        If blnCollisionUp <> True Then
            sprPlayer.Top = sprWall(ObjectIndex).Top + sprWall(ObjectIndex).Height + lngSpeed
        End If
        blnCollisionUp = True
    ElseIf (ObjectName = "sprWall" And ObjectIndex <> -1 And pdPlayer = PlayerDirectionDown) Then
        If blnCollisionDown <> True Then
            sprPlayer.Top = sprWall(ObjectIndex).Top - sprPlayer.Height - lngSpeed
        End If
        blnCollisionDown = True
    ElseIf (ObjectName = "sprWall" And ObjectIndex <> -1 And pdPlayer = PlayerDirectionLeft) Then
        If blnCollisionLeft <> True Then
            sprPlayer.Left = sprWall(ObjectIndex).Left + sprWall(ObjectIndex).Width + lngSpeed
        End If
        blnCollisionLeft = True
    ElseIf (ObjectName = "sprWall" And ObjectIndex <> -1 And pdPlayer = PlayerDirectionRight) Then
        If blnCollisionRight <> True Then
            sprPlayer.Left = sprWall(ObjectIndex).Left - sprPlayer.Width - lngSpeed
        End If
        blnCollisionRight = True
    End If
    If (ObjectName = "sprPoints") Then
        If sprPoints(ObjectIndex).Visible = True Then
            sprPoints(ObjectIndex).Visible = False
            lngPoints = lngPoints + 10
            txtPoints.Text = "Points: " & Format(lngPoints, "0000")
            Points = Points + 1
            If Points = Diamonds Then
                txtPoints.Text = "Muitos Parabéns - Points: " & Format(lngPoints, "0000")
                txtPoints.Width = 3900
            End If
        End If
    End If
End Sub
my problem is that, sometimes, the player don't go back and can move by(i don't know write the right word) wall
lngSpeed is the number of pixels that must move(the scalemode is in Twips.
thanks(if you need more information or the project(must be came with my sprite control(*.ocx file)) just ask)
Reply With Quote
  #4  
Old 01-18-2010, 01:08 PM
Iceplug's Avatar
Iceplug[VB6] - colide with wall and stop Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Based on what I see here, it looks like if you collide while moving left:

The player is moved to be 'against' the right side of the sprWall.
blnCollisionLeft is set to True
However, if the player continues toward the left, the collision resolution code is not run despite continuously setting blnCollisionLeft to True.
I would just omit the blnCollisionLeft, blnCollisionUp, etc. because I don't see what purpose it is serving... including the If blnCollision__ Then and associated End If.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #5  
Old 01-18-2010, 02:08 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

Quote:
Originally Posted by Iceplug View Post
Based on what I see here, it looks like if you collide while moving left:

The player is moved to be 'against' the right side of the sprWall.
blnCollisionLeft is set to True
However, if the player continues toward the left, the collision resolution code is not run despite continuously setting blnCollisionLeft to True.
I would just omit the blnCollisionLeft, blnCollisionUp, etc. because I don't see what purpose it is serving... including the If blnCollision__ Then and associated End If.
i belive that i know why:
1 - maybe 1 have 2 colisions in same direction(maybe down and left, for example);
2 - when the image is changed, my sprite size is changed too.
i will try see 1 thing now.
Reply With Quote
  #6  
Old 01-18-2010, 02:26 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

i belive that i can resolve the problem
when the image is changed, the sprite control size is changed too.
is why that my code don't works 100%.
for resolve these problem i must change\update the sprite control code
then, i belive, that these code works fine
tell me if i'm not right.
thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop [VB6] - colide with wall and stop
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop [VB6] - colide with wall and stop
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop
 
[VB6] - colide with wall and stop
[VB6] - colide with wall and stop
 
-->