Results 1 to 6 of 6

Thread: What's wrong with this code?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90

    Unhappy What's wrong with this code?

    Hi all of you!

    I'm doing a small game using DDraw, it's called CrossBall.
    A ball is moving along the horizontal part of a cross. The user has to try and stop it in the middle of the cross. If he succeeds in doing so, another ball will start moving on the vertical part, so he has to stop aver the first one.
    The problem is, that when the first ball stops in the middle, the second one appears on the vertical part but doesn't move.

    This is the code in general:
    Code:
    'First, the BallType
    BallType
        XPosition 'Sets the X-coordinate
        Yposition 'Sets the Y-coordinate
        Xspeed 'A constant added to the X-coordinate simulating the ball's speed in the x direction
        yspeed 'A constant added to the Y-coordinate simulating the ball's speed in the y direction
    End Type
    
    CrossBall function()
        setHorizontalBall
        Do
        DoEvents
            MoveHorizontalBall
            If vbKeySpace Then
                'if Ball is in the middle
                    ball.Xspeed = 0
                    SetVerticalBall
                    Do
                    DoEvents
                        MoveVerticalBall
                        if vbKeySpace
                            'if bal is over the other one
                                ball.yspeed = 0
                                Exit Do
                        End If
                    Loop
            End If
        Loop
    End Function
    SetVertical and SetHorizontal are sub's that set the balls in theie places and sets their speeds.
    MoveHorizontal: ball.Xposition=Ball.Xposition+Ball.Speed
    MoveVertical: ball.yposition=ball.yposition+ball.speed

    I think that's it.

    Thank you all for your help.
    Last edited by sandra; May 24th, 2001 at 04:08 PM.

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