Results 1 to 3 of 3

Thread: Pong Game Won't Work

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Post

    I am trying to make a pong type game to test my skills, and this won't work. It is screwed up in the part where it hits the paddle.

    'Bounces Puck Around Screen
    Image1.Move Image1.Left + DeltaX, Image1.Top + DeltaY
    If Image1.Left < ScaleLeft Then DeltaX = 100
    If Image1.Left + Image1.Width > ScaleWidth + ScaleWidth Then
    DeltaX = -100
    End If
    If Image1.Top < ScaleTop Then DeltaY = 100
    If Image1.Top + Image1.Height > ScaleHeight + ScaleTop Then
    DeltaY = -100
    End If

    'Bounces Off Of Paddle
    If Image1.Left < Label1.Left Then DeltaX = 100
    If Image1.Left + Image1.Width > Label1.Width + Label1.Width Then
    DeltaX = -100
    End If
    If Image1.Top < Label1.Top Then DeltaY = 100
    If Image1.Top + Image1.Height > Label1.Height + Label1.Top Then
    DeltaY = -100
    End If

    Steve

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    Ok here's what u need:
    3 textboxs named text1, toptxt, lefttxt(make each text 90)
    2 shapes, a small circle , a bar rectangle like an I
    Optional:
    a line in the middle etc. art
    Code:
    Private Sub Text1_Change()
    On Error Resume Next
    If Text1.Text = 2 Then Shape2.Top = Shape2.Top + 240
    If Text1.Text = 8 Then Shape2.Top = Shape2.Top - 240
    Text1.Text = ""
    End Sub
    
    Private Sub Timer1_Timer()
    Shape1.Top = Shape1.Top + toptxt.Text
    Shape1.Left = Shape1.Left + lefttxt.Text
    If Shape1.Top + Shape1.Height + 480 >= Form1.Height Then toptxt.Text = -90
    If Shape1.Left <= 0 Then lefttxt.Text = 90
    If Shape1.Top <= 0 Then toptxt = 90
    If Shape1.Top >= Shape2.Top And Shape1.Top + Shape1.Width < Shape2.Top + Shape2.Height And Shape1.Left + Shape1.Width + 60 >= Shape2.Left Then lefttxt.Text = -90
    If Shape1.Left + Shape1.Width >= Form1.Width Then MsgBox "GAME OVER!", 16, "GAME OVER": End
    End Sub
    Hopefully you have VB5 this should just be able to be pasted. you can change the numbers etc. The basics are here took me only a few min but you should be able to expand on this concept.


    ------------------
    DiGiTaIErRoR

  3. #3
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    Oh yeah an explanation:
    text1.text is where you can type 8 and 2 to move the paddle horizontally
    toptxt keeps track of the y change
    lefttxt keeps track of x change
    just put the stuff where it belong set the timer to a smaller interval for harder larger for easier.(you should have a timer if u didn't realize that)
    the rest should be self explanatory


    ------------------
    DiGiTaIErRoR

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