Burst Effect?
BlitzMax Forums/BlitzMax Beginners Area/Burst Effect?
| ||
I have some balls which are arranged in a circle. I draw them to screen with the following:Function drawBalls() For Local b:ball = EachIn ballList SetRotation(BallRotationAngle) DrawImage balls,b.xpos+BallXoffSet+Sin(b.angle)*distanceFromCenter,.. b.ypos+BallYoffSet+Cos(b.angle)*distanceFromCenter,b.ballFrame SetRotation(0) Next End Function I want there to be a sort of burst effect which causes the balls to burst outward then return inward to the center of the screen. I thought I could use something like this. Function testBurst() Local temp:Float = distancefromcenter BurstDistance = 100 If KeyDown(KEY_SPACE) distanceFromCenter = Sin(temp)*temp temp:+1 If temp <=0 Then temp = 360 EndIf DrawText "temp = " +temp,0,0 End Function It craetes a nice smooth movement inwards but then it stops and hangs. Any ideas on how I can proceed? |
| ||
To go out and then back in you shouldn't need the full range of angles for Sin, you'd only need up to 180. |
| ||
Hi, I've modified the code accordingley but it still has no effect. Anymore tips would be appreciated. Thanks :) |
| ||
You seem to have Cos() and Sin() mixed up in your code example. Use Cos() to calulate X position and Sin() to calculate Y position. In your code you are doing the opposite(Sin() for X and Cos() for y). |
| ||
@Aten I whipped together some thing really quick to set you on the right track: Hope it helps! ( Slow day at work today ;-) ) |
| ||
Sigh, This is a much better approach then what I've been using. I'm Still an OOP noob. This is the exact effect i wanted. Thanks. :) |
| ||
Don't sigh :) Just keep at it! OOP takes some getting used to. Remember that OOP is more of a mindset than actual coding techniques. It's all about the process. Try thinking in objects and their properties first instead of thinking of how to implement the details. If you have you have a good set of objects, your implementation of the details will easily (well, sort of...) fall into place. |