I am trying to understand code better, not just knowing what a function does because ,or what to do if you get this syntax error or that glitch but a fundamental understanding of what you’re asking of your program
I personally spend 90% of my time on this forum looking for the meaning of certain scripts so why not make a topic about it. so here I am, with a shiny new account, asking for your help with informing this growing community and inform aspiring coders on what they are asking of their computer and in turn teaching them when it is better for certain code or another.
it is in a snake game and i dont know for sure if i need to put the entire script in for it to be relivent but what i got form it it was something along the lines that when it hits a wall or eats itself it makes a new head and i just dont know
Select Case $newhead[0] < 0 Or $newhead[0] > 39 Or $newhead[1] < 0 Or $newhead[1] > 39 If $snakelength > 0 Then MsgBox(0, "Your snake ate the wall.", "Your snake was "& ($snakelength + 1) & " units long") Else MsgBox(0, "Your snake ate the wall.", "You should play with your snake more.") EndIf _cleanup() Case $board[$newhead[0]][$newhead[1]] ; OK to go there $newhead[2] = GUICtrlCreateLabel("", $newhead[0] * 10, $newhead[1] * 10, 10, 10) GUICtrlSetBkColor($newhead[2], 16777215) If $board[$newhead[0]][$newhead[1]] = 2 Then ; Ate Food ; Move food Do $a = Int(Random(0, 39)) $b = Int(Random(0, 39)) Until $board[$a][$b] = 1 ; empty $board[$a][$b] = 2 ; food GUICtrlSetPos($food, $a * 10, $b * 10) $snakelength = $snakelength + 1 ReDim $snake[$snakelength + 1][3] Else GUICtrlDelete($oldtail[2]) $board[$oldtail[0]][$oldtail[1]] = 1 EndIf $board[$newhead[0]][$newhead[1]] = 0 For $i = $snakelength To 1 Step - 1 ; Array shift $snake[$i][0] = $snake[$i - 1][0] $snake[$i][1] = $snake[$i - 1][1] $snake[$i][2] = $snake[$i - 1][2] Next $snake[0][0] = $newhead[0] $snake[0][1] = $newhead[1] $snake[0][2] = $newhead[2]
p.s. sorry for the confusion first post's make me Skittish