I re-did your arrays to help you be more organized with them. I thought about making them TYPE variables, but that is a little more advanced topic and a better understanding of arrays would be first on the list. This code has proper collision between the bullets and the enemies. The explosion is placed at the collision, but it just sits there until the next explosion, and is not animated.
Rem Project: Inferno Source X
Rem Created: 9/25/2010 11:55:28 PM
Rem ***** Main Source File *****
Set Display Mode 1024,768,32
Set Image Colorkey 255,255,0
Sync Rate 60
Sync On
Hide Mouse
CLS RGB(0,0,0)
Randomize Timer()
Backdrop Off
ScrWid = screen width()
MaxBullets = 20
BulletCount = 0
BulletSpeed = 15
Dim Bullet(MaxBullets,3) : ` 1 = X, 2 = Y, 3 = status
`Dim FiredBullet(MaxBullets)
`Dim BulletX(MaxBullets)
ScrWid2 = 0
EnemySpeed = 1
MaxEnemies = 10
Dim Enemy(MaxEnemies,7) ` 1 = X, 2 = Y, 3 = status, 4 = engine, 5 = speed, 6 = start frame, 7 = end frame
`Dim EnemyExist(MaxEnemies)
`Dim EnemyX(MaxEnemies)
`Dim EnemyY(MaxEnemies)
`Dim EnemyEngine(MaxEnemies)
Load Sound "Shoot.wav",1
Load Music "explosion.wav",1
Load Image "EnemyShip.bmp",4
Load Image "PlayerShip.bmp",1
Load Image "EngineOutput.bmp",2
Load Image "Shot.bmp",3
Load Image "Explosion.bmp",6
Load Image "Healthbar.bmp",7
Load Image "BG.jpg",8
Sprite 1,78,500,1
Scale Sprite 1,150
Create Animated Sprite 2,"EngineOutput.bmp",2,1,2
Sprite 2,78,500,2
Scale Sprite 2,50
Create Animated Sprite 6,"explosion.bmp",4,4,6
Sprite 7,10,10,7
Sprite 8,0,0,8
Set Sprite Priority 8,0
Set Sprite Priority 7,6
Set Sprite Priority 1,3
Set Sprite Priority 2,2
Set Sprite Priority 6,7
P1SprX = Sprite X(1)
P1SprY = Sprite Y(1)
Speed = 5
BulletTimer = Timer() + 200
Do
ClS
GoSub Player
GoSub EnemySpawn
GoSub EnemyMove
If SpaceKey() = 1 And Timer() > BulletTimer Then GoSub Add_Bullet
If BulletCount > 0 Then GoSub Move_Bullet
Sync
Loop
Player:
Play Sprite 2,1,2,200
Sprite 1,P1SprX,P1SprY,1
Sprite 2,P1SprX-13,P1SprY,2
If KeyState(17) = 1 Then Dec P1SprY,Speed
If KeyState(31) = 1 Then Inc P1SprY,Speed
If KeyState(30) = 1 Then Dec P1SprX,Speed
If KeyState(32) = 1 Then Inc P1SprX,Speed
If P1SprX < 10 Then Inc P1SprX,Speed
If P1SprX > 950 Then Dec P1SprX,Speed
If P1SprY < 1 Then Inc P1SprY,Speed
If P1SprY > 745 Then Dec P1SprY,Speed
Return
Add_Bullet:
For N = 1 To Maxbullets
If Bullet(N,3) = 0
Bullet(N,3) = 1
Bullet(N,1) = P1SprX + 50
Bullet(N,2) = P1SprY + 12
Sprite N + 10,Bullet(N,1),Bullet(N,2),3
Set Sprite Priority N + 10,7
Inc BulletCount
BulletTimer = Timer() + 200
Play Sound 1
Exit
EndIf
Next N
Return
Move_Bullet:
For N = 1 To Maxbullets
If Bullet(N,3) = 1
Bullet(N,1) = Bullet(N,1) + BulletSpeed
Sprite N + 10,Bullet(N,1),Bullet(N,2),3
For A = 1 to MaxEnemies
if Enemy(A,3) = 1 and Bullet(N,3) = 1
If Sprite Collision(N + 10,A + 100)
Bullet(N,3) = 0
Delete Sprite N + 10
Enemy(A,3) = 0
Delete Sprite A + 100
Dec BulletCount
if sprite exist(4) = 1 then Hide Sprite 4
if sprite exist(5) = 1 then Hide Sprite 5
Sprite 6,Enemy(A,1),Enemy(A,2),6
EnemyDead = 1
EndIf
Endif
if Bullet(N,3) = 1 and Bullet(N,1) > ScrWid Then Bullet(N,3) = 0 : Delete Sprite N + 10 : Dec BulletCount
Next A
EndIf
Next N
Return
EnemySpawn:
For A = 1 To MaxEnemies
If Enemy(A,3) = 0 : ` is the enemy active already?
Enemy(A,3) = 1 :` change status to active
Create Animated Sprite A + 100,"EnemyShip.bmp",2,2,4
Enemy(A,1) = ScrWid + Rnd(550) : ` X coord
Enemy(A,2) = rnd(600) : ` Y coord
Enemy(A,5) = 1 : ` speed
Enemy(A,6) = 1 : ` start frame
Enemy(A,7) = 4 : ` end frame
Sprite A + 100,Enemy(A,1),Enemy(A,2),Enemy(A,6)
Set Sprite Priority A + 100,7
EndIf
Next A
Return
EnemyMove:
For A = 1 To MaxEnemies
If Enemy(A,3) = 1
Enemy(A,1) = Enemy(A,1) - Enemy(a,5)
Sprite A + 100,Enemy(A,1),Enemy(A,2),Enemy(a,6)
Play Sprite A + 100,Enemy(a,6),Enemy(A,7),100
If Enemy(A,1) < ScrWid2 Then Delete Sprite A + 100 : Enemy(A,3) = 0
EndIf
Next A
Return
Also, you will need to code where an enemy can collide with the player. I couldn't figure out why the enemies weren't showing up and tried all sorts of ways to get them to show and realized that the sprite priority had not been set on them.
Hope this helps you. If you have any questions, please ask.
LB
I'm not really a programmer.....I only play one on TGC.