Results 1 to 3 of 3

Thread: a small easy game

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Location
    Ca
    Posts
    93

    Cool

    Ok, Say you wanted to make a small confusing game. I want to make a tiny program that has no background no x no nothing, just a button that says "click here," and when you put your cursor over the button it jumps arround the screen. I put my cursor on it it jumps ayay. I do it again it jumps away. Confusing? Well if someone can help me out can you tel me what the code is?
    Timbudtwo
    I have no life, only one with computers.

    VB 6.0 Enterprise Edition
    [hr]

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    Would something like this work:
    Code:
    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim Done As Boolean
        Dim rndLeft As Long
        Dim rndTop As Long
        
        Randomize
        
        Do While Not Done
            rndLeft = Int((Me.Width * Rnd) + 1)
            If (rndLeft + Command1.Width > Me.Width) Or (rndLeft < 0) Then
                Done = False
            Else
                Done = True
            End If
        Loop
        
        Done = False
        
        Do While Not Done
            rndTop = Int((Me.Height * Rnd) + 1)
            If (rndTop + Command1.Height > Me.Height) Or (rndTop < 0) Then
                Done = False
            Else
                Done = True
            End If
        Loop
        
        Command1.Left = rndLeft
        Command1.Top = rndTop
    End Sub
    It's very poorly written, but it's 5:15 in the morning and I didn't get my sleep yet. Take it as an idea.
    HTH

  3. #3
    Guest
    make sure you don't set the button's default property to true, because all the user would have to do to press it is hit the enter key!

    also, you will have to stop it appearing in the CTRL-ALT-DEL list.

    You must be one of those subversive types!

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