Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a VB Expert!

Join 244,287 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 970 people online right now. Registration is fast and FREE... Join Now!




VB 2d Side scroller

 
Reply to this topicStart new topic

VB 2d Side scroller, jumping issues

selmoelmo
28 Nov, 2008 - 02:00 PM
Post #1

New D.I.C Head
*

Joined: 7 Nov, 2008
Posts: 13



Thanked: 1 times
My Contributions
ok im making a small game in vb for a prject for school. i have it so i press "a" to move left, "d" to move right, and "w" to jump. but so far i have no idea how to make my picbox move up and down. i can get it to go straight up and then back down but i want to be able to move either left or right while in the air. heres my code so far if it helps.
CODE

Private Sub txtMove_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMove.TextChanged

        If txtMove.Text = "d" Or txtMove.Text = "a" Or txtMove.Text = "w" Then 'Checks if a movement button is pressed

            If txtMove.Text = "d" Then                                         'if the letter "d" is pressed it will cause the player to move right

                CharRight = True                                               'Shows the Right char pic

                If CharRight Then                                              'Checks if charright is true
                    picChar.Image = picCharRight.Image                         'changes images
                    CharRight = Not CharRight                                  'switchs charright off
                End If

                picChar.Left = picChar.Left + 10
                txtMove.Text = ""

            ElseIf txtMove.Text = "a" Then

                CharLeft = True

                If CharLeft Then
                    picChar.Image = picCharLeft.Image
                    CharLeft = Not CharLeft
                End If

                picChar.Left = picChar.Left - 10
                txtMove.Text = ""

            ElseIf txtMove.Text = "w" Then

                tmrJump.Enabled = Not (tmrJump.Enabled)
                txtMove.Text = ""

            End If

        Else
            txtMove.Text = ""
        End If

    End Sub





Private Sub tmrJump_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrJump.Tick

        Do Until picChar.Location.Y = 170
            picChar.Top = picChar.Location.Y - 1
        Loop

        Do Until picChar.Location.Y = gravity
            picChar.Top = picChar.Location.Y + 1

        Loop

        tmrJump.Enabled = Not (tmrJump.Enabled)

    End Sub


User is offlineProfile CardPM
+Quote Post


VB Crash
RE: VB 2d Side Scroller
28 Nov, 2008 - 03:08 PM
Post #2

D.I.C Head
**

Joined: 28 Nov, 2008
Posts: 130



Thanked: 7 times
My Contributions
CODE

Private Sub Down_Click()
Object1.Top = Object1.Top + 30

End Sub

Private Sub Form_Load()

End Sub

Private Sub Left_Click()
Object1.Left = Object1.Left - 30

End Sub

Private Sub Right_Click()
Object1.Left = Object1.Left + 30

End Sub

Private Sub Up_Click()
Object1.Top = Object1.Top - 30
End Sub


Vace
User is offlineProfile CardPM
+Quote Post

selmoelmo
RE: VB 2d Side Scroller
28 Nov, 2008 - 03:29 PM
Post #3

New D.I.C Head
*

Joined: 7 Nov, 2008
Posts: 13



Thanked: 1 times
My Contributions
i have no idea what to do with that could you explain it a bit?
User is offlineProfile CardPM
+Quote Post

VB Crash
RE: VB 2d Side Scroller
28 Nov, 2008 - 03:47 PM
Post #4

D.I.C Head
**

Joined: 28 Nov, 2008
Posts: 130



Thanked: 7 times
My Contributions
Private Sub Down_Click()
'this is for DOWN
Picture1.Top = Object1.Top + 30

End Sub


Private Sub Left_Click()
'This is for LEFT
Picture1.Left = Object1.Left - 30

End Sub

Private Sub Right_Click()
'This is for RIGHT
Picture1.Left = Object1.Left + 30
End Sub

Private Sub Up_Click()
'This is for UP
Picture1.Top = Object1.Top - 30
End Sub

You understand now ...?

Vace
User is offlineProfile CardPM
+Quote Post

selmoelmo
RE: VB 2d Side Scroller
28 Nov, 2008 - 04:11 PM
Post #5

New D.I.C Head
*

Joined: 7 Nov, 2008
Posts: 13



Thanked: 1 times
My Contributions
This will not make my character Jump
it is a side scroller
i want the character to go up and then back down
but while going up and down to be able to move left or right
User is offlineProfile CardPM
+Quote Post

VB Crash
RE: VB 2d Side Scroller
28 Nov, 2008 - 04:38 PM
Post #6

D.I.C Head
**

Joined: 28 Nov, 2008
Posts: 130



Thanked: 7 times
My Contributions
Well I don't have time to do that but when you know the basic command you can use

CODE

for i=1 to 100

picture1.top=picture1.top -10

Next



CODE


for i=1 to 100

picture1.top=picture1.top+10

next


You can use this in timer or somethig else ... and make the project. If you need some other help to build the project
add my MSN so we can talking more about this

Vace
User is offlineProfile CardPM
+Quote Post

selmoelmo
RE: VB 2d Side Scroller
28 Nov, 2008 - 05:33 PM
Post #7

New D.I.C Head
*

Joined: 7 Nov, 2008
Posts: 13



Thanked: 1 times
My Contributions
ok i added you onto msn. mine is mattanselmo@hotmail.com
User is offlineProfile CardPM
+Quote Post

VB Crash
RE: VB 2d Side Scroller
28 Nov, 2008 - 06:01 PM
Post #8

D.I.C Head
**

Joined: 28 Nov, 2008
Posts: 130



Thanked: 7 times
My Contributions
You are offline...I'm waitng you
User is offlineProfile CardPM
+Quote Post

anand_the_great
RE: VB 2d Side Scroller
15 Dec, 2008 - 11:12 PM
Post #9

New D.I.C Head
*

Joined: 15 Apr, 2008
Posts: 47



Thanked: 1 times
My Contributions
Hello Friend, your of question is "Bouncing" so that it goes up and down and in between to move left and right. You can should also try a timer.
Thank You.
Anand
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 03:21PM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month