Ok,heres the deal. My program was running at a rock solid 40 fps (maybe coulda went higher,havent tryed) but after adding a fairly small amount of code to my bullet system,my FPS is dropping to 30-36 fps,which makes the game seem sluggish. When firing bullets before it still remained a solid 40. Here is the code I added that has affected performance so much. If anyone can spot something that im doing horribly wrong let me know. Also,if you wanna take a look at the entire program so far I can send it to you via email (only 88k)
'Bullet Collision Detect
bSwitch=Sprite Col(3,4 to 1000)
sprite off 3
bSwitch=Sprite Col(4,5 to 1000)
sprite off 4
bSwitch=Sprite Col(5,6 to 1000)
sprite off 5
bSwitch=Sprite Col(6,7 to 1000)
sprite off 6
bSwitch=Sprite Col(7,8 to 1000)
sprite off 7
bSwitch=Sprite Col(8,9 to 1000)
sprite off 8
bSwitch=Sprite Col(9,10 to 1000)
sprite off 9
bSwitch=Sprite Col(9,11 to 1000)
sprite off 10
bSwitch=Sprite Col(10,12 to 1000)
sprite off 11
bSwitch=Sprite Col(11,13 to 1000)
sprite off 12
bSwitch=Sprite Col(12,14 to 1000)
sprite off 13
bSwitch=Sprite Col(13,15 to 1000)
sprite off 14
You're not really doing anything wrong, it's really just what you're doing is taking TNT Basic a long time. You're asking it to check for collisions between 1 sprite and pretty much a thousand others, and then doing that 12 times, that means TB's trying to test 12,000 every frame, which is why it's struggling.
I'm assuming most of these sprites aren't actually on, so I might be able to optimise TNT Basic there. Could you email me your project and I'll have a ponder over making things faster in that area.
In the meanwhile, I'd recommend trying 2 things:
1) Lower the number of sprites it checks against if possible, (ie do you really need to check against a 1000 other sprites?)
2) Alternate your checking code, like check the even numbered bullets on one frame, then the odd numbered bullets on the next frame.
If that's not fast enough try checking 2 bullets per frame or something. This is probably alright because unless your bullets are moving very fast, their turn for collision detection will come up before they've moved through their target.
By implementing these, you will lower the number of collision tests per frame and speed up your game.
If you need any more help (because I'm not sure I explained this well!) - just post.
Hehe..ok that was a mistake on my part. I set it to check through 1000 just so I wouldnt ever have to go back and raise those numbers as I added sprites to my game. I didnt realise it would check over the sprites that werent there..doh! Hehe,guess I just cant be so lazy! And btw,thanks for responding so fast to all my questions!