Tweening help
Blitz3D Forums/Blitz3D Programming/Tweening help
| ||
Hey peeps... ive created a general tween function, but it doesnt work its best... Now, ive played and played and played, and tweening has always done my head in, this function was like a godsend when i created it... This is just the "include". instead of "renderworld:flip", call "Renderworldtween(frames per second) Can anyone help fix this so that it is actually the same speed on everyones computer? Cheers Damien Global rendertweenskipframes#,oldrendertime# Function RenderWorldTween(fps#) Local tween#,Beforerender#,Afterrender#,tw#,framespd#,renderspd#,afps#,TWEENVAL# If rendertweenskipframes>1 Then rendertweenskipframes=0 If rendertweenskipframes>0.99999999999 Then rendertweenskipframes#=rendertweenskipframes#-1:Goto skiprendertween tween#=0 Repeat If tween#=0 Then beforerender=oldrendertime TWEENVAL#=TWEEN# ;If tween#>1 Then Goto Dontrenderthisbit If rendertweenskipframes<1 Then tweenVAL#=tween#+rendertweenskipframes:rendertweenskipframes=0 om=MilliSecs() ;If tweenval=0 Then RenderWorld tweenVAL# If debugtext=1 Then ;---------------------------------------------------------------------------- ;---PLACE DEBUG AND DRAWING STUFF HERE---- ;-----Note, 2D stuff will NOT be tweened for obvious---- ;-----reasons ---- ;--------------------------------------------------------------------------- EndIf Flip 0 If tween#=0 Then afterrender=MilliSecs() renderspd#=afterrender-beforerender:framespd#=1000.0/fps# tw#=renderspd#/framespd# If tw#<.000001 Then tw#=1 If tw>5 Then tw=5 ;To stop endless loops EndIf DebugLog tween#+" "+tw# tween#=tween#+tw# If twEEN>1 Then rendertweenskipframes#=rendertweenskipframes#+TWEEN#-1 .Dontrenderthisbit Until tween#>=1 .skiprendertween CaptureWorld oldrendertime#=MilliSecs() End Function |
| ||
I always refer people to the original Marcoworld example included with Blitz3D, that always does the trick for me :) |
| ||
"Marcoworld". hehe, right, now, what if i say ive looked at that about 50 times? :P im not looking to implement it specifically, just looking for a function that would work in almost any project by just replacing the Renderworld function oh well, cheers, i will take another look when i get home. BTW, i noticed your fondness of "marcoworld"... all i have is "castle" and "castledemo.bb" :P |
| ||
Try my tutorial: http://www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=johnblackledge09202003161847.html |
| ||
hehe not a fondness, but this topic seems to keep re-appearing quite a lot and I just happen to know in my own experience the code worked for me. I believe the castle demo is the code I'm talking about, I'm not sure how it got to be known as Marcoworld... I probably picked it up from somewhere's around here ;D |
| ||
I use the code from the Castle Demo in everything. Works like magic :-) |
| ||
|
| ||
There are some excellent tutorials on this over at blitzcoder http://www.blitzcoder.com/ Just search for 'tweening' and 'delta timing' should do it. I use tweening as it seems the best solution in most cases. Only problem you can run into is when you just want to 'teleport' an object from one place to another. Tweening will try and make it 'move' there. You can get around this, but you might also want to consider implementing delta timing instead. I mention this, because you are really best implememnting the most suitable solution for your project from the start. Its a pain swapping over part way through ;) |
| ||
I would implement delta time unfortunately im using a physics library. also, the project is near complete, and its set for tweening- my current tween function just doesnt cut it :/ oh well :/ Il take a look around, cheers guys. |
| ||
As Rhyolite said: 'There are some excellent tutorials on this over at blitzcoder ' As I said: Try my tutorial: www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=johnblackledge09202003161847.html |
| ||
Sorry, kinda missed your link was to blitzcoder!! Ooops! This was one of the tutorials I was reffering to. But while I am here, thanks for your excellent tutorial John, it really helped me out. The blitz community is great and one day I hope to put something back in (although its always tricky when others seem to know more than me!). |
| ||
Can I swear? Bloody Hell! About two years ago _I_ said the same as you: the Blitz community is great and one day I hope.... And today it's come full circle and _I_ got thanked! Cheers Rhyolite, just now, I needed that. Can I also mention that I think that one of the great things about being part of this community is that (whether you know it or not) we really _are_ and the start of something new and cutting edge. Where all else has gone predictable and rancid in the professional I.T. sector, 3D is still _that_ new. There are very few rules as such, and every day people are having breakthroughs with lighting, shading, physics etc. Yes, people in this community! Woo-hoo! |
| ||
:) |
| ||
well said john..well said ;) |
| ||
Nice tutorial. Doesnt look like il make a worthy function yet then! Can anyone test my function above just for laughs? Cheers to everyone and John for that tutorial. |