Monday, July 16, 2012 7:32 PMAnswerer
PZR676. I'm trying to make a cannon shoot a ball but, as time goes on the program slows down. help! I've asked questions Just like this before and I was generiously given some sample code from gotoloop and litdev. But I was wondering If anyone would explane how to do this so I wouldn't have to ask.
Thanks in advance!
Monday, July 16, 2012 9:10 PMModerator
You are removing the shapes as the missiles are deleted, but the arrays of positions etc continue to grow and the large array cause the slowing.
Perhaps something like this, import PZR676-1.
Time[i] = ""
x[i] = ""
y[i] = ""
to the cleanup subAlso, if the timer calls the computerfire too often the missiles build up and their movement slows and they build up and therefore adding more at the same timer interval causes more missiles and a slow down - perhaps don't add more missiles if there are already more than some limit already in motion.
- Edited by litdevMicrosoft Community Contributor, Moderator Monday, July 16, 2012 9:32 PM
Monday, July 16, 2012 10:24 PMAnswerer
Sub GarbageCleanup Elapsed = Elapsed + 1 While ii < i-MTrack ' <--- ii is always behind most recent fired missile #i up to MTrack older ones Shapes.Remove( Missile[ii] ) Missile [ii] = "" TimeStart [ii] = "" vCosInit [ii] = "" vSinInit [ii] = "" ii = ii + 1 EndWhile EndSub
And to gain some execution speed, I've removed 4 or 5 arrays from the game as well. Arrays are very slow in SB anyways!
PS: Dunno why Missile Turret stopped working on Silverlight. *_*
Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)
Tuesday, July 17, 2012 4:02 AMAnswererHmm It works but the array keeps getting larger.
Tuesday, July 17, 2012 7:52 AM
Zock77 , Maybe you want to do is like this?
For i=1 To 20
If y[i]<0 Then
x[i]=100 ' starting position
For i=1 To 20
Tuesday, July 17, 2012 4:22 PMAnswererHmm. I see where your going. only track the max ball that can be on the screen with that rate of fire. that way the program would never slow down. ill try that. Thank you All for replying!!
- Edited by Zock77Editor Tuesday, July 17, 2012 4:24 PM