Games aren’t particularly renowned for their spot-on physics simulations. In fact, they often take quite a few liberties with reality. But therein lies a curious charm—a world where the laws of nature bend to the whims of entertainment. In this article, we dive into the realm of game physics, where simplicity reigns supreme, and accuracy takes a backseat to gameplay.
In the vast landscape of game development, physics engines can range from hyper-realistic to downright whimsical. While some games strive for lifelike representations of physical phenomena, others opt for a more simplified approach, sacrificing precision for accessibility and fun.
Our journey begins with a humble premise: a lone ball bouncing within the confines of a grid, its movements governed by the simplest of rules. Bounce in a way that makes sense. This ball, though far from embodying the intricacies of real-world physics, serves as the arbiter of fun in the game Shirly. A game that I was so surely sure was fun that I named it Shirly. Our lone ball followed simple rules:
- Bounce whenever we can no longer move forward
- Move at 45 degree angles
- Push moveable blocks upon collision
- Convert moveable blocks to immoveable blocks when moveable blocks have nowhere they can move to
Now, given that this was maybe the 5th thing I had ever programmed it wasn’t the greatest. It was just a giant if-tree with horrifyingly named variables such as nLCx. The stuff nightmares are made of to be honest. At least it was relatively simple, and more importantly… fast!!
Private Sub Ball_Timer() Dim x As Integer Dim y As Integer Ball.Interval = s Board(bLCx, bLCy) = 0 'movement (based on difference of previous movements) amX = bLCx - pLCx amY = bLCy - pLCy 'where are we going next? nLCx = bLCx + amX nLCy = bLCy + amY 'look ahead. Based on movement. If ((Board(bLCx + amX, bLCy) = 1) And (Board(bLCx, bLCy + amY) = 1)) Then 'Or Board(nLCx, nLCy) = 1 Then 'bounce out of corner nLCx = nLCx - (amX * 2) 'inverse of current direction COMPLETELY nLCy = nLCy - (amY * 2) 'ditto ElseIf Board(bLCx + amX, bLCy) = 1 Then 'bounce off side nLCx = nLCx - (amX * 2) ElseIf Board(bLCx, bLCy + amY) = 1 Then 'bounce off top/bottom nLCy = nLCy - (amY * 2) ElseIf (Board(bLCx + amX, bLCy) = 4) And (Board(bLCx, bLCy + amY) = 4) Then If Board(nLCx, nLCy) = 4 Then Board(bLCx + amX, bLCy + amY) = 0 Board(nLCx + amX, nLCy + amY) = 4 End If nLCx = nLCx - (amX * 2) nLCy = nLCy - (amY * 2) ElseIf Board(bLCx + amX, bLCy) = 4 Then If Board(nLCx + amX, nLCy) = 4 Or Board(nLCx + amX, nLCy) = 1 Then Board(bLCx + amX, bLCy) = 1 ElseIf Board(nLCx + amX, nLCy) = 0 Then Board(bLCx + amX, bLCy) = 0 Board(nLCx + amX, nLCy) = 4 End If nLCx = nLCx - (amX * 2) nLCy = nLCy ElseIf Board(bLCx, bLCy + amY) = 4 Then If Board(nLCx, nLCy + amY) = 4 Or Board(nLCx, nLCy + amY) = 1 Then Board(bLCx, bLCy + amY) = 1 ElseIf Board(nLCx, nLCy + amY) = 0 Then Board(bLCx, bLCy + amY) = 0 Board(nLCx, nLCy + amY) = 4 End If nLCx = nLCx nLCy = nLCy - (amY * 2) ElseIf Board(nLCx, nLCy) = 4 Then If Board(nLCx + amX, nLCy + amY) = 4 Or Board(nLCx + amX, nLCy + amY) = 1 Then Board(bLCx + amX, bLCy + amY) = 1 ElseIf Board(nLCx + amX, nLCy + amY) = 0 Then Board(bLCx + amX, bLCy + amY) = 0 Board(nLCx + amX, nLCy + amY) = 4 End If For x = -1 To 1 'Step 2 For y = -1 To 1 'Step 2 If x <> 0 And y <> 0 Then If Board(bLCx + x, bLCy + y) = 0 Then 'go there, get out of trouble :D nLCx = bLCx + x nLCy = bLCy + y End If End If Next y Next x 'nLCx = nLCx - (amX * 2) 'nLCy = nLCy - (amY * 2) ElseIf Board(nLCx, nLCy) = 1 Then 'don't go through MY trail basically(more to it but not essential info) 'find us a position!! For x = -1 To 1 'Step 2 For y = -1 To 1 'Step 2 If x <> 0 And y <> 0 Then If Board(bLCx + x, bLCy + y) = 0 Then 'go there, get out of trouble :D nLCx = bLCx + x nLCy = bLCy + y End If End If Next y Next x 'nLCx = nLCx - (amX * 2) 'nLCy = nLCy - (amY * 2) 'look for "fours" End If pLCx = bLCx pLCy = bLCy bLCx = nLCx bLCy = nLCy Score3 = Score3 + Board(bLCx, bLCy) Board(bLCx, bLCy) = 2 End Sub