Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help in making table..
#11
GOTO's, ah, I used to use those those then I was showed the light of loops and SUB's.
Reply
#12
could someone help me write equivalent functioning code without GOTO's?

Code:
Function check_against( o As char_type Ptr, othr As char_type Ptr, check As Integer, d As Integer )

  '' object to object collision detection


  Dim As Integer x_opt, y_opt
  
  
  Select Case d
  
    Case 0
      y_opt = -1
    
    Case 1
      x_opt = 1
    
    Case 2
      y_opt = 1
    
    Case 3
      x_opt = -1
      
  End Select


  ''''
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  ''''
    
  If o->uni_directional = 0 Then
      '' factor in directional data.

    o->frame_check = o->frame + (o->direction * o->anim[o->current_anim].dir_frames)


  Else
    '' the contra of this statement's other half.
    '' ignore directional data.
  
    o->frame_check = o->frame

  End If

  ''''
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  ''''
  
  
  With othr[check]  
    
    If .uni_directional = 0 Then
        '' factor in directional data.
  
      .frame_check = .frame + (.direction * .anim[.current_anim].dir_frames)
  
  
    Else
      '' the contra of this statement's other half.
      '' ignore directional data.
    
      .frame_check = .frame
  
    End If

  End With

  Dim As Integer x_imp, y_imp, c_x, c_y, c_x2, c_y2, c_rx, c_ry, c_rx2, c_ry2

  If othr[check].anim[othr[check].current_anim].frame[othr[check].frame_check].faces = 0 Then  
    Goto jmp1
    
  End If
  Dim As Integer check_fields, check_fields2
  
  For check_fields = 0 To othr[check].anim[othr[check].current_anim].frame[othr[check].frame_check].faces - 1
  
    jmp1:
    
    If o->anim[o->current_anim].frame[o->frame_check].faces = 0 Then
      check_fields2 = 0
      Goto jmp2
      
    End If

    For check_fields2 = 0 To o->anim[o->current_anim].frame[o->frame_check].faces - 1
    
      jmp2:
    
      c_x = o->x + x_opt
      c_y = o->y + y_opt
    
      c_x2 = othr[check].x
      c_y2 = othr[check].y
    
    
      calc_positions( o    , x_imp, c_x , c_y , c_rx , c_ry , check_fields2 )  

      calc_positions( @othr[check], y_imp, c_x2, c_y2, c_rx2, c_ry2, check_fields )  
    

      If check_bounds( 0, c_x, c_y, c_x2, c_y2, c_rx, c_ry, c_rx2, c_ry2 ) = 0 Then
    
        If check_collision( x_imp, _
                            y_imp, _
                            o->dead, _
                            othr[check].dead, _
                            othr[check].dead_anim, _
                            othr[check].unique_id ) <> 0 Then
          Return 1
          
        End If
    
      End If
  
    Next

  Next    



End Function
Reply
#13
?

Shouldn't this be in a new thread?

If you make standard capitalization, get rid of all the tabs, spaces, "_"s, and "->"s, I will consider it... :king:
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#14
for one, its freebasic., so ph34R. second of all its a *flow* problem, not a *syntax* problem. i posted it as basically a joke, i would almost be willing to be money you can't come up with a more elegant solution (that won't cause bugs in my engine)
Reply
#15
Yes it is a syntax problem, because I can't analyze the flow without understanding your code. And your coding style is an abberation upon humanity... :x

I'm sure I could get rid of the GOTOs and make it much better code if I knew what the heck was going on.... baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhh..............
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#16
Oi...get over the anti-GOTO kick, people. And cha0s, enough of the FB-pushing...we all know you sleep with a hard copy of the FB manual as a child would with a teddy bear, but this is getting ridiculous... Tongue

When someone asks for QB help, they want QB help, not FB help. Tongue
\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Reply
#17
Yeah, that's telling him, Nec. Big Grin
*****
Reply
#18
obviously its difficult to tell from that snippet, but to me both gotos look redundant, because even if the condition they rely on it not met, they will still step to the same code.

Code:
If condition Then  
    Goto jmp1
  End If

  For a = b To c

    jmp1:

   .....

  Next a
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#19
dingdingding, thanks for playing! nek and aga You Lose o.o

edit: its not that simple.
Code:
If othr[check].anim[othr[check].current_anim].frame[othr[check].frame_check].faces = 0 Then  
    Goto jmp1
    
  End If
  Dim As Integer check_fields, check_fields2
  
  For check_fields = 0 To othr[check].anim[othr[check].current_anim].frame[othr[check].frame_check].faces - 1

look at the values. if othr[check].anim[othr[check].current_anim].frame[othr[check].frame_check].faces = 0 then, if there is no goto, the FOR..NEXT loop will be skipped. if that value is 0 the loop must be manually entered.. see the problem?
Reply
#20
I just go semi-blind looking at it, it's not my fault..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)