Part II - Sample VB code for RadarRush™ Game
by Mountain Computers Inc, Publication Date: Saturday, August 9, 2025
View Count: 394, Keywords: Game Development, Radar Rush, Engine Strategy and Design, Hashtags: #GameDevelopment #RadarRush #EngineStrategyandDesign
I noticed as I got to Game Level 9 or higher, the performance became slower.
Noticing there are more bullets and enemies to track, I need to refactor the code for performance.
Stand by as I reconsider this function.
more to come...
Sub DoShapesCollide()
Dim i As Integer, j As Integer
Dim Bx As Integer, By As Integer, Bh As Integer, Bw As Integer, Bxc As Integer
Dim ETx As Integer, ETy As Integer, ETh As Integer, ETw As Integer
' Iterate through each pair of shapes in the array
If visible_bullet_count > 0 Then
For i = 1 To bullet_count
DoEvents
If MainScreen.Controls("shpBullet" & CStr(i)).Visible = True Then
If visible_enemy_count > 0 Then
Bx = MainScreen.Controls("shpBullet" & CStr(i)).Left
By = MainScreen.Controls("shpBullet" & CStr(i)).Top
Bh = MainScreen.Controls("shpBullet" & CStr(i)).Height
Bw = MainScreen.Controls("shpBullet" & CStr(i)).Width
Bxc = Bx + (Bw / 2)
For j = 1 To enemy_count
DoEvents
If MainScreen.Controls("shpEnemyTarget" & CStr(j)).Visible = True Then
ETx = MainScreen.Controls("shpEnemyTarget" & CStr(j)).Left
ETy = MainScreen.Controls("shpEnemyTarget" & CStr(j)).Top
ETh = MainScreen.Controls("shpEnemyTarget" & CStr(j)).Height
ETw = MainScreen.Controls("shpEnemyTarget" & CStr(j)).Width
'collision check
If ((By + Bh) <= (ETy + ETh) And ((Bx >= ETx) And (Bx) <= (ETx + ETw))) Then
PlaySound App.Path & "\bullet_sound.wav", 0, &H1
MainScreen.Controls("shpEnemyTarget" & CStr(j)).Visible = False
visible_enemy_count = visible_enemy_count - 1
MainScreen.lbl_EnemyCount.Caption = "Enemy Count: " & CStr(visible_enemy_count)
MainScreen.lbl_EnemyKills.Caption = "Enemy Kills: " & CStr(enemy_count - visible_enemy_count)
If visible_enemy_count = 0 Then
clear_bullets_on_screen = True
End If
MainScreen.Controls("shpBullet" & CStr(i)).Visible = False
visible_bullet_count = visible_bullet_count - 1
End If
End If
Next j
End If
End If
Next i
End If
End Sub
if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.
© 2026 myBlog™ v1.2 All rights reserved. We count views as reads, so let's not over think it.