Type Ownership
BlitzPlus Forums/BlitzPlus Beginners Area/Type Ownership
| ||
I am making a Side Scrolling Shooter game in which I am using types to make instances of all the objects in the game -Player -Enemies -Platforms -Bullets and so on... well I have done this successfully so far but I have run into a problem. I am now trying to make a lava/fire/damage-the-player-when-he-touches-this block and I thought it would be nice if it looked different that other blocks (I think the player would be much happier that way). How I planned on doing this was to make the object fade dark to light and back, that went fine but didn't look dangerous enough so I thought it would be cool to have sparks floating upward randomly shaking back and forth as they did so. That went fine as well... until I added another instance of the flaming block. That did NOT go well they started updating each others sparks so that they traveled at twice the normal speed and so even faster if more were added the first thing i did was create 2 types Type Steam Field x,y Field xv,yv Field Limit End Type Type Fire Field x,y Field w,h Field Limit,Cur Field Flame.Steam End Type and a function to create fire blocks in which i can stick into my stage making function to create an instance of a fire block Function Create_Fire(x,y,w,h) Lava.Fire = New Fire Lava\x = x Lava\y = y Lava\w = w Lava\h = h Lava\Limit = Lava\w/25+1 End Function now in the update stage I made it check to see if it had the same number of sparks as it's limit and if not create a spark For Create = Lava\Cur To Lava\Limit Lava\Flame = New Steam Lava\Flame\x = Rand(Lava\x-Lava\w/2,Lava\x+Lava\w/2) Lava\Flame\y = Lava\y-Lava\h/2 Lava\Flame\Limit = Rand(30,50) Lava\Cur = Lava\Cur + 1 Next then when i make a FOR... NEXT loop to draw/update the sparks it updates the sparks for ALL the fire blocks is there a way to make it only update the sparks it "owns" and not all of the sparks present on the screen? if you need more info just say so *EDIT* I figured it out about 5 seconds after I posted this I had the spark update loop inside the Fire Block update loop thinking it would update only it's own when really it updated them all each time it updated the block when the Update Sparks should have been by itself **EDIT** okay never mind that didn't work... my question still stands For Lava.Fire = Each Fire For Lava\Flame = Each Steam Color Rand(170,255),10,10 Oval Lava\Flame\x-2-Screenx,Lava\Flame\y-2-Screeny,4,4,1 Lava\Flame\x = Lava\Flame\x - Rand(-1,1) Lava\Flame\y = Lava\Flame\y - 1 Lava\Flame\Limit = Lava\Flame\Limit - 1 If Lava\Flame\Limit <= 0 Delete Lava\Flame Lava\Cur = Lava\Cur - 1 End If Next Next this is the loop -,- |