Results 1 to 10 of 10

Thread: Got a game that doesn't work right!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82

    Cool Got a game that doesn't work right!

    Yeah, um, ima newbie, so try not to get too pissed off at me.
    I gotta game, and the collision system doesn't quite work, so i was wondering if there was anyone with some free time who could help me out.
    Attached Files Attached Files
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    Why does no one want to help?
    Is it because im a newbie?
    Or because they're afraid of getting a virus from my file?
    If thats the problem, I'll put the code right on the board.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    I think this is all you will need. The walls are types that have top, left, height, width, and visible properties. Rects have top,left, bottom, and right.

    Private Sub Intersection()
    Dim rDest As RECT
    Dim i As Integer

    'set the ball rectangle to shpBall's size
    With rBall
    .Bottom = shpBall.Top + shpBall.Height
    .Left = shpBall.Left
    .Right = shpBall.Left + shpBall.Width
    .Top = shpBall.Top
    End With

    'check all walls to see if they are intersecing w/ ball
    For i = 0 To 84
    If IntersectRect(rDest, rWall(i), rBall) <> 0 Then
    'if they intersect and are visible...
    If Wall(i).Visible = True Then
    'reverse ball direction,make wall invisible
    BallDir = -BallDir
    Wall(i).Visible = False
    'Redo all the walls
    Repaint
    'if they intersect ans are invisible...
    ElseIf Wall(i).Visible = False Then
    'don't worry about it
    BallDir = BallDir
    End If
    End If
    Next i
    End Sub

    Private Sub LoadLevel()
    Dim FileHandle%
    Dim strXBuffer As String
    Dim strYBuffer As String
    Dim strTypeBuffer As String
    Dim LineNum As Integer
    Dim i As Integer

    'get next fre file handle
    FileHandle% = FreeFile
    'open level for inputing
    Open App.Path + "\levels\Level" & Level & ".lvl" For Input As #FileHandle%
    'while not at end of file...
    Do While Not EOF(FileHandle%)
    'input the x,y,and type of wall
    Line Input #FileHandle%, strXBuffer
    Line Input #FileHandle%, strYBuffer
    Line Input #FileHandle%, strTypeBuffer
    'increment the number line/wall we are on
    LineNum = LineNum + 1
    'set props of current wall
    Wall(LineNum).Left = ((strXBuffer * picCurrWall.Width) / 15) - (lblStatus.Width / 30)
    Wall(LineNum).Top = ((strYBuffer * picCurrWall.Height) / 15) - (picCurrWall.Height / 15) '16
    Wall(LineNum).Type = strTypeBuffer
    Wall(LineNum).Visible = True
    Wall(LineNum).Height = picCurrWall.Height
    Wall(LineNum).Width = picCurrWall.Width
    'set currwall's rectangel (see Intersection())
    rWall(LineNum).Bottom = (Wall(LineNum).Top + Wall(LineNum).Height) * 15
    rWall(LineNum).Left = (Wall(LineNum).Left) * 15
    rWall(LineNum).Right = (Wall(LineNum).Left + Wall(LineNum).Width) * 15
    rWall(LineNum).Top = (Wall(LineNum).Top) * 15
    Loop
    'close level file
    Close #1

    'refresh the scene
    Refresh

    'loop through all walls
    For i = 0 To 84
    'if the wall is visible...
    If Wall(i).Visible = True Then
    'get what type of wall it is...
    Select Case (Wall(i).Type)
    'and put it on the screen
    Case "BlankWall"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picBlankWall.hDC, 0, 0, vbSrcCopy
    Case "SpikeWall"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picSpikeWall.hDC, 0, 0, vbSrcCopy
    Case "Wall01"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picWall01.hDC, 0, 0, vbSrcCopy
    Case "Wall02"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picWall02.hDC, 0, 0, vbSrcCopy
    Case "wall03"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picWall03.hDC, 0, 0, vbSrcCopy
    Case "Wall04"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picWall04.hDC, 0, 0, vbSrcCopy
    Case "ChWall01"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picChWall01.hDC, 0, 0, vbSrcCopy
    Case "ChWall02"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picChWall02.hDC, 0, 0, vbSrcCopy
    Case "Chwall03"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picChWall03.hDC, 0, 0, vbSrcCopy
    Case "ChWall04"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picChWall04.hDC, 0, 0, vbSrcCopy
    Case "FullWall"
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picFullWall.hDC, 0, 0, vbSrcCopy
    Case Else
    BitBlt frmMain.hDC, Wall(i).Left, Wall(i).Top, Wall(i).Width, Wall(i).Height, frmPics.picBlankWall.hDC, 0, 0, vbSrcCopy
    End Select
    End If
    Next i
    End Sub
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  4. #4
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Looked at your code, seems to be alright, not sure about intersectRect, never used it so not sure what rDest is used for (best guess would be the rect of the overlapping section)
    (not downloaded)

    One problem with this method is that the ball's speed must not be faster than the size of the wall section.

    for example

    if a ball is two by two pixels.

    and a wall is 3 by 3 pixels

    if the ball is 1 pixel under the wall and is moving at a speed of 6 pixels per frame then the ball will pass through the wall and out on the otherside without causing a collision.

    there are other more complex methods that can be used to beat this problem (like line-intersection, determining which wall the ball WILL hit, then checking to see if it has happened yet)
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    Thnx for your help, but it didn't help. I went back and checked over all that and it seems to be ok. The ball increased 100 or -100 (depending on its curr direction) The ball height was 255 and the wall height was 600. rWall height was 9000 and rball height was 225. Don't know what units they are (pixels, twips, etc) Its just what the compiler said when I pressed F8 to step through my code and hovered my mouse over the variables to get their current value.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  6. #6
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Ok been looking at the code for a couple of hours now (anything to put off wirtting that dang report :P)

    I knew what was wrong a while ago, but your code is bad and every fix i made stopped the entire thing working.

    your problem is scale

    you are using pixels for some values and twips for others.

    Switch everything to using pixels (no *15 /15), when refering to the forms use scale height/width

    all controls will use the scale of the form.
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    Thnx, I made a few adjustments to scales and such and now my code works great. Check back in a few days and i'll post the final (or near final) version of my crappy first game.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  8. #8
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    I just popped in to see if I could help and Nirces has beat me to it.

    Couple of hours looking at someone elses code? You must really not want to do that report...

    Killerguppy,

    Be sure to let us know when you post a playable version of your game.
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    Its finally here!!!

    The first playable version!!!

    press the space bar to pause
    use the arrow keys to move back and forth.
    the block in the lower right is the only type you can kill.
    hit blocks that are half white and half another color to change block types to kill.
    the blocks with blue crosses are deadly!

    p.s.- Its still under construction, but i think you can get the general idea of what its gonna look like.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    stoopid board doesn't want to post my game, eh?

    lets try it now!
    Attached Files Attached Files
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

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