1 Replies - 683 Views - Last Post: 22 January 2017 - 10:55 AM Rate Topic: -----

#1 Ayman Haque   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-January 17

Character movement in visual basics 2008

Posted 22 January 2017 - 10:48 AM

[Public Class Form1


    Dim nom As String

    Dim point As Integer

    Dim level As Integer
    Dim gtime As Integer
    Dim gtime2 As Integer
    Dim gtime3 As Integer
    Dim gtime4 As Integer
    Dim gtime5 As Integer
    Dim gtime6 As Integer
    Dim gtime7 As Integer
    Dim gtime8 As Integer
    Dim gtime9 As Integer
    Dim gtime10 As Integer

    

    Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        Select Case e.KeyChar ' *PROBLEM*

            Case "w"

                player.Top = player.Top - 5
            Case "d"

                player.Left = player.Left + 5

            Case "a"

                player.Left = player.Left - 5
            Case "s"
                player.Top = player.Top + 5
        End Select

       

    End Sub


   

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.KeyPreview = True
        
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      
        nom = InputBox("What Is Your Name?")
        MsgBox("Collect all the stars as quick as possible after all stars are collected you will automaticly be taken tot eh next level. Hit the GO to start timer. Good luck  w" + nom + "  Tip: some times dying to reset spawn might help")
        level = 1
        Timer1.Enabled = True
        Button1.Visible = False
        Do Until level = 2

            If s1.Visible = False And s2.Visible = False And s3.Visible = False Then

                o1.Visible = True
                o2.Visible = True
                o3.Visible = True
                o4.Visible = True
                o5.Visible = True
                o7.Visible = True
                level = level + 1


            End If

        Loop
        Timer1.Enabled = False
        s1.Visible = True
        s2.Visible = True
        s3.Visible = True
        Timer2.Enabled = True
        Do Until level = 3

            If s1.Visible = False And s2.Visible = False And s3.Visible = False Then

                o1.Visible = False
                o2.Visible = True
                o3.Visible = True
                o4.Visible = False
                o5.Visible = False
                o7.Visible = True
                o6.Visible = True
                ppp1.Visible = False
                pppp1.Visible = False
                pp3.Visible = True
                p3.Visible = True
                ppp3.Visible = True
                pppp3.Visible = True
                ppppp1.Visible = True
                pppppp3.Visible = True
                b3.Visible = True
                bb3.Visible = True
                bbb3.Visible = True
                bbbb3.Visible = True
                bbbbb3.Visible = True
                level = level + 1
            End If
        Loop
        Timer2.Enabled = False
        s1.Visible = True
        s4.Visible = True
        s5.Visible = True
        Timer3.Enabled = True
        Do Until level = 4

            If s5.Visible = False And s1.Visible = False And s4.Visible = False Then

                o1.Visible = False
                o2.Visible = True
                o3.Visible = False
                o4.Visible = True
                o5.Visible = True
                o7.Visible = True
                o6.Visible = False
                o8.Visible = True
                pp1.Visible = True
                pp3.Visible = True
                p3.Visible = True
                ppp3.Visible = True
                ppppp3.Visible = True
                pppp3.Visible = True
                ppppp1.Visible = True
                pppppp3.Visible = True
                b3.Visible = True
                bb3.Visible = True
                bbb3.Visible = True
                bbbb3.Visible = True
                bbbbb3.Visible = True
                level = level + 1
            End If
        Loop
        Timer3.Enabled = False
        s2.Visible = True
        s3.Visible = True
        s4.Visible = True

        Timer4.Enabled = True
        Do Until level = 5

            If s2.Visible = False And s3.Visible = False And s4.Visible = False Then

                o1.Visible = False
                o2.Visible = True
                o3.Visible = True
                o4.Visible = False
                o5.Visible = False
                o7.Visible = True
                o6.Visible = True
                o8.Visible = True
                pp1.Visible = True
                pp3.Visible = True
                p3.Visible = True
                ppp3.Visible = True
                ppppp3.Visible = True
                pppp3.Visible = True
                ppppp1.Visible = True
                pppppp3.Visible = True
                b3.Visible = True
                bb3.Visible = True
                bbb3.Visible = True
                bbbb3.Visible = True
                bbbbb3.Visible = True
                p5.Visible = True
                pp5.Visible = True
                ppp5.Visible = True
                level = level + 1
            End If
        Loop
        Timer4.Enabled = False
        s1.Visible = True
        s5.Visible = True
        s4.Visible = True
        s6.Visible = True
        Timer5.Enabled = True
        Do Until level = 6
            If s1.Visible = False And s5.Visible = False And s4.Visible = False And s6.Visible = False Then

                o1.Visible = False
                o2.Visible = False
                o3.Visible = False
                o4.Visible = False
                o5.Visible = False
                o7.Visible = False
                o6.Visible = False
                o8.Visible = False
                pp1.Visible = True
                pp3.Visible = False
                p3.Visible = False
                ppp3.Visible = False
                ppppp3.Visible = False
                pppp3.Visible = False
                ppppp1.Visible = False
                pppppp3.Visible = False
                b3.Visible = False
                bb3.Visible = False
                bbb3.Visible = False
                bbbb3.Visible = False
                bbbbb3.Visible = False
                p5.Visible = True
                pp5.Visible = True
                ppp5.Visible = True
                p6.Visible = True
                pp6.Visible = True
                ppp6.Visible = True
                pppp1.Visible = True
                sw1.Visible = True
                sw2.Visible = True
                sw3.Visible = True
                sw4.Visible = True
                sw5.Visible = True
                level = level + 1
            End If
        Loop
        Timer5.Enabled = False
        s7.Visible = True
        s8.Visible = True
        s6.Visible = True
        Timer6.Enabled = True
        Do Until level = 7
            If s7.Visible = False And s8.Visible = False And s6.Visible = False Then

                o1.Visible = False
                o2.Visible = False
                o3.Visible = False
                o4.Visible = False
                o5.Visible = False
                o7.Visible = False
                o6.Visible = False
                o8.Visible = False
                pp1.Visible = True
                pp3.Visible = False
                p3.Visible = False
                ppp3.Visible = False
                ppppp3.Visible = False
                pppp3.Visible = False
                ppppp1.Visible = False
                pppppp3.Visible = False
                b3.Visible = False
                bb3.Visible = False
                bbb3.Visible = False
                bbbb3.Visible = False
                bbbbb3.Visible = False
                p5.Visible = True
                pp5.Visible = True
                ppp5.Visible = True
                p6.Visible = True
                pp6.Visible = True
                ppp6.Visible = True
                pppp1.Visible = True
                sw1.Visible = True
                sw2.Visible = True
                sw3.Visible = True
                sw4.Visible = True
                sw5.Visible = True
                level = level + 1
            End If
        Loop

        Timer6.Enabled = False
        s7.Visible = True
        s8.Visible = True
        s6.Visible = True
        Timer7.Enabled = True

        Do Until level = 8



            If s6.Visible = False And s8.Visible = False And s7.Visible = False Then
                o1.Visible = False
                o2.Visible = False
                o3.Visible = False
                o4.Visible = False
                o5.Visible = False
                o7.Visible = False
                o6.Visible = False
                o8.Visible = False
                o9.Visible = True
                pp1.Visible = True
                pp3.Visible = True
                p3.Visible = True
                ppp3.Visible = True
                ppppp3.Visible = False
                pppp3.Visible = False
                ppppp1.Visible = True
                pppppp3.Visible = False
                b3.Visible = False
                bb3.Visible = False
                bbb3.Visible = False
                bbbb3.Visible = False
                bbbbb3.Visible = False
                p5.Visible = True
                pp5.Visible = True
                ppp5.Visible = True
                p6.Visible = False
                pp6.Visible = True
                ppp6.Visible = True
                pppp1.Visible = False
                sw1.Visible = True
                sw2.Visible = True
                sw3.Visible = True
                sw4.Visible = True
                sw5.Visible = True
                pppp6.Visible = True
                ppppp1.Visible = True
                level = level + 1

            End If
        Loop
        Timer7.Enabled = False

        s7.Visible = True
        s8.Visible = True
        s6.Visible = True
        s1.Visible = True
        Timer8.Enabled = True
        Do Until level = 9
            If s6.Visible = False And s8.Visible = False And s7.Visible = False And s1.Visible = False Then
                o1.Visible = False
                o2.Visible = False
                o3.Visible = False
                o4.Visible = False
                o5.Visible = False
                o7.Visible = False
                o6.Visible = False
                o8.Visible = False
                o9.Visible = True
                pp1.Visible = True
                pp3.Visible = True
                p3.Visible = True
                ppp3.Visible = True
                ppppp3.Visible = False
                pppp3.Visible = False
                ppppp1.Visible = True
                pppppp3.Visible = False
                b3.Visible = False
                bb3.Visible = False
                bbb3.Visible = False
                bbbb3.Visible = False
                bbbbb3.Visible = False
                p5.Visible = True
                pp5.Visible = True
                ppp5.Visible = True
                p6.Visible = False
                pp6.Visible = True
                ppp6.Visible = True
                pppp1.Visible = False
                sw1.Visible = True
                sw2.Visible = True
                sw3.Visible = True
                sw4.Visible = True
                sw5.Visible = True
                pppp6.Visible = True
                ppppp1.Visible = True
                level = level + 1

            End If
        Loop
        Timer8.Enabled = False
        s7.Visible = True
        s6.Visible = True
        s8.Visible = True
        s1.Visible = True
        Timer9.Enabled = True
        Do Until level = 10
            If s6.Visible = False And s8.Visible = False And s7.Visible = False And s1.Visible = False Then
                o1.Visible = True
                o2.Visible = False
                o3.Visible = True
                o4.Visible = False
                o5.Visible = False
                o7.Visible = False
                o6.Visible = True
                o8.Visible = True
                o9.Visible = True
                pp1.Visible = True
                pp3.Visible = True
                p3.Visible = True
                ppp3.Visible = True
                ppppp3.Visible = True
                pppp3.Visible = True
                ppppp1.Visible = True
                pppppp3.Visible = True
                b3.Visible = True
                bb3.Visible = True
                bbb3.Visible = True
                bbbb3.Visible = True
                bbbbb3.Visible = True
                p5.Visible = False
                pp5.Visible = False
                ppp5.Visible = False
                p6.Visible = True
                pp6.Visible = True
                ppp6.Visible = True
                pppp1.Visible = False
                sw1.Visible = True
                sw2.Visible = True
                sw3.Visible = True
                sw4.Visible = False
                sw5.Visible = False
                pppp6.Visible = True
                ppppp1.Visible = False
                m1.Visible = True
                m2.Visible = True
                m3.Visible = True
                level = level + 1

            End If
        Loop
        Timer10.Enabled = True
        If s1.Visible = False And s10.Visible = False And s4.Visible = False And s7.Visible = False And s9.Visible = False And s5.Visible = False Then
            e1.Visible = True
            e2.Visible = True
            e3.Visible = True


        End If
        Timer10.Enabled = False
        MsgBox("You Finished the game" + nom)
        Label5.Text = "Your time was " + gtime + gtime2 + gtime3 + gtime4 + gtime5 + gtime6 + gtime7 + gtime8 + gtime9 + gtime10
        
    End Sub


    Private Sub go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        If level = 1 Then
            gtime = gtime + 1

            Label4.Text = gtime

        End If
        Label4.Text = ""
    End Sub


    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        If level = 2 Then
            gtime2 = gtime2 + 1

            Label4.Text = gtime2
        End If
        Label4.Text = ""
    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        If level = 3 Then
            gtime3 = gtime3 + 1

            Label4.Text = gtime3
        End If
        Label4.Text = ""
    End Sub

    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
        If level = 4 Then
            gtime4 = gtime4 + 1

            Label4.Text = gtime4
        End If
        Label4.Text = ""
    End Sub

    Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
        If level = 5 Then
            gtime5 = gtime5 + 1

            Label4.Text = gtime5
        End If
        Label4.Text = ""
    End Sub

    Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
        If level = 6 Then
            gtime6 = gtime6 + 1

            Label4.Text = gtime6
        End If
        Label4.Text = ""
    End Sub

    Private Sub Timer7_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer7.Tick
        If level = 7 Then
            gtime7 = gtime7 + 1

            Label4.Text = gtime7
        End If
        Label4.Text = ""
    End Sub

    Private Sub Timer8_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer8.Tick
        If level = 8 Then
            gtime8 = gtime8 + 1

            Label4.Text = gtime8
        End If
        Label4.Text = ""
    End Sub

    Private Sub Timer9_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer9.Tick
        If level = 9 Then
            gtime9 = gtime9 + 1

            Label4.Text = gtime9
        End If
        Label4.Text = ""
    End Sub

    Private Sub Timer10_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer10.Tick
        If level = 10 Then
            gtime10 = gtime10 + 1

            Label4.Text = gtime10
        End If
        Label4.Text = ""
    End Sub

    Private Sub player_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles player.Click

    End Sub


    Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    
End Class]




:code:

I am having a problem where when i move my character in the start it works fine but when i click the button to start the game the character the won't move. i have tied putting the loop code for my levels under the form and under the key press but it won't work. i could really use some help asp this is due on Monday. thnak you

This post has been edited by modi123_1: 22 January 2017 - 10:52 AM
Reason for edit:: Please use the [code] button in the editor in the future


Is This A Good Question/Topic? 0
  • +

Replies To: Character movement in visual basics 2008

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14174
  • View blog
  • Posts: 56,780
  • Joined: 12-June 08

Re: Character movement in visual basics 2008

Posted 22 January 2017 - 10:55 AM

First, let me say, your variable names are horrible. p3, ppp3, pppp3, ppppp1, etc?! Really? That has zero readability for anyone else. Use.. actual.. words. to describe their usage and intent.

Second - Visual Basic 2008 is VB.NET.

For the rest - I really don't understand what is going on. Is this an attempted game? If so then you only need ONE timer to be your stand-in game engine.

This kewl guy wrote a tutorial on the basic concepts.
http://www.dreaminco...-basics-part-1/
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1