Results 1 to 36 of 36

Thread: VB: Form

Hybrid View

  1. #1
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VB: Form

    Alright, but I'm warning you though, this is pretty advanced. I'm going to do this by memory since I don't have VB in front of me right now. So there might be a mistake or two.

    1) First of all, you will need to create a user defined data type called Sprite_Type:

    Code:
    Private Type Sprite_Type
    
         X As Long
         Y As Long
         Visible As Boolean
         Active As Boolean
    
         'This obviously needs more but for beginner's purposes, this is fine
         'for now.
    
    End Type
    2) Use the code I have above to serve as a base. Only this time I put the Sprite_Type in there.

    Code:
    Option Explicit 'This makes sure all variables have been declared.
    
    Private Type Sprite_Type
    
         X As Long
         Y As Long
         Visible As Boolean
         Active As Boolean
    
         'This obviously needs more but for beginner's purposes, this is fine
         'for now.
    
    End Type
    
    
    Private Declare Sub Sleep Lib "kernel32" (ByVal Milliseconds As Long) 'Needed for pausing between loops. This will be your first API you ever used.
    
    Dim Sprite As Sprite Type 'Make this an array if you want more sprites.
    
    Private Sub Form_Activate()
    
        Dim Game_Active As Boolean 'Boolean is either always true or false.
        
        ScaleMode = 3 'Makes the form's coordinate system based on
                      'pixels rather than twips.
        
        Picture1.ScaleMode = 3 'Makes the picturebox's coordinate system based on
                               'pixels rather than twips.
    
        Sprite.X = 0
        Sprite.Y = 0
        
        Sprite.Active = True
        Sprite.Visible = True
    
        Game_Active = True
    
        While Game_Active = True
        
            DoEvents 'So the program doesn't lock up and allow events to happen.
            
            Sleep 15 'Keep it around 60 FPS. 1000 / 15 = 66.66
    
            If Sprite.Active = True And Sprite.Visible = True Then
         
                 Picture1.Visible = True
      
            End If
            
            Sprite.X = Sprite.X + 1
    
            If (Sprite.X) >= 250 Then 'If it collides at 250
    
                Sprite.X = 250 'Stay at 250
            
                Game_Active = False 'Exits the while loop.
            
            End If
    
            Picture1.Left = Sprite.X 'For every frame, move the picturebox
                                               '1 unit to the right.
            
            Picture1.Top = Sprite.Y
    
            
        Wend
        
    End Sub

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    21

    Re: VB: Form

    how do i make a user defined data thingy

  3. #3
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VB: Form

    Look at 1)

    Plus I already included it in 2) so don't worry bout 1)

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    21

    Re: VB: Form

    so i just paste that on the form?
    I'm kinda stupid to this right now, so i might as well ask the second question. how will this put my mecha icon on it

  5. #5
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VB: Form

    And definitely learn how to program first like we've been telling you. Read some books on VB (not VB.NET) at any bookstore. The internet has plenty of tutorials that will teach you how to program in VB6. And it's very easy to pick it up and learn how right away. Once you learn basic concepts of programming, continue to learn more as you progress.

    Now after that, you can now learn how to make games. There are numerous sites that will teach you the correct way to make video games in VB. We can't write the code for you. But we can lead you in the right direction and correct any problems you have. That's what these forums are for.

    You would want to be the author of your own program, not us. I mean think about it, if you were writing a book and had no idea on how to write it, you wouldn't want smarter people to fill in the blank pages for you would ya?

  6. #6
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VB: Form

    Quote Originally Posted by Zenomori
    so i just paste that on the form?
    I'm kinda stupid to this right now, so i might as well ask the second question. how will this put my mecha icon on it

    Open up the properties window to the form. Goto Icon and click on the [...] button. It'll open up a dialog box. Find where your icon is and press the Ok button.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    21

    Re: VB: Form

    yea, but i cant move that icon, and i want multiple icons on a map

  8. #8
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409

    Re: VB: Form

    Im not sure if youve been listing to what theve been telling you

    YOU NEED TO LEARN SIMPLE STUFF FIRST

    so go get your sefl a book on VB or VB.NET (i suggest vb.net but we wont go into that argument) And read it. Then we can help you with the hard stuff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width