Here's my second Papervision3d routine.
This is actually the first time since school that I used linked lists. wow.
My first attempt had a garbage collection problem, in that it didn't garbage collect, so the memory usage just kept growing, eventhough Flashplayer should've kept it in check. Gotta dive deeper into that, cuz this stuff is fun :)
I've solved it by recycling the objects in my list, works fine and is probably not as memory-fragmenting as the 'correct way'...
It's probably been done before, you know, snake, but now in 3d- whee... But it has not yet been done by me, unil now. :P
Click to view
Oh yeah, I've made this using FlashDevelop, and I like it, so I'm gonna use it more in the future :)
Let me know what you think
Monday, February 25, 2008
Thursday, February 21, 2008
Papervision test
For some reason I'm really crap at finding documentation about stuff online.
So it took me a while to download Papervision3d, and get started, but as soon as I got the sources installed I was ready to go to mess around a bit, and finally make this little test.
Simple papervision scene navigation
You can navigate around the scene using the cursor keys, press shift and left-right for strafing, and if you press space you go up :)
Unfortunately, after I made this, I found out that the source I downloaded from the papervision site was the OLD version of papervision. V1.5 or something, while 2alpha was already out. But for some reason, not available on the papervision site itself.
Or.. i was just looking in the wrong spot?
Anyway, I had to download the new version from Ralph's blog
Haven't been able to mess with it yet though, hopefully soon :)
I've setup FlashDevelop at home now, which looks promising, but haven't gotten round to using it yet.
So it took me a while to download Papervision3d, and get started, but as soon as I got the sources installed I was ready to go to mess around a bit, and finally make this little test.
Simple papervision scene navigation
You can navigate around the scene using the cursor keys, press shift and left-right for strafing, and if you press space you go up :)
Unfortunately, after I made this, I found out that the source I downloaded from the papervision site was the OLD version of papervision. V1.5 or something, while 2alpha was already out. But for some reason, not available on the papervision site itself.
Or.. i was just looking in the wrong spot?
Anyway, I had to download the new version from Ralph's blog
Haven't been able to mess with it yet though, hopefully soon :)
I've setup FlashDevelop at home now, which looks promising, but haven't gotten round to using it yet.
Thursday, February 7, 2008
int bug
I found a little bug in actionscript 2, which apparantly has been fixed in actionscript 3 but which I found funny enough to show you guys.
Trying to fix a bug in an older source, where I took part of a symbolname "Button037", and cut out the 035 part as a substring, which I then used to flip to some page in a pageflipper component.
After the pageflipper bugged out (trying to add 5 to "037" which ended up with "0375" instead of 37 ..duh, I know) I put an int() around the value I got from the symbol name.
(Never having looked at the manual entry for int() but beeing used to its function from ASP/vbscript, I didn't know it was deprecated and I should use Math.floor() instead ...lesson learned :)
Anywho.
Whats the bug you ask?
Well.. If you use int() to convert a string to a number, it doesn't always work correctly in actionscript 2.0 if you have leading zero's.
I plotted the values out in a graph to see if there was some kind of pattern to it, and there was. Click here to see it
Sourcecode for that is:
Anyway.. it's fixed in actionscript 3, and you shouldn't use int() anyway, but hey, it might come in handy to know this if you're still using int() in your code, and it doesnt work the way it should :)
Edit : My Collegue Hugo asked if Number() had the same bug. Apparantly it does, BUT. its not what I thought it was.
When you use Number() to convert a string to a number, you can use a leading zero to indicate you're using an OCTAL value just like 0x denotes a hexadecimal value.
So the bug actually isn't that int() works incorrectly, but that the manual doesn't say that you can use a leading 0 to indicate an octal value.
So why does it seem to be 'fixed' in as3.0? Well, you can use octal notation in as2.0, but this doesnt work anymore in as3.0.
Not sure why anyone would want to use octal notation, but to prove this, try this little example in as3.0 and as2.0
as2.0 will count to 15
as3.0 will count to 19
Trying to fix a bug in an older source, where I took part of a symbolname "Button037", and cut out the 035 part as a substring, which I then used to flip to some page in a pageflipper component.
After the pageflipper bugged out (trying to add 5 to "037" which ended up with "0375" instead of 37 ..duh, I know) I put an int() around the value I got from the symbol name.
(Never having looked at the manual entry for int() but beeing used to its function from ASP/vbscript, I didn't know it was deprecated and I should use Math.floor() instead ...lesson learned :)
Anywho.
Whats the bug you ask?
Well.. If you use int() to convert a string to a number, it doesn't always work correctly in actionscript 2.0 if you have leading zero's.
trace(int("037")); returns 31 for exampleI plotted the values out in a graph to see if there was some kind of pattern to it, and there was. Click here to see it
Sourcecode for that is:
_root.lineStyle(1,0x000000);
for (intT=0; intT<400; intT++)
{
trace(intT + " : " + int("0" + intT));
_root.moveTo(intT,0);
_root.lineTo(intT, int("0" + intT));
}
Anyway.. it's fixed in actionscript 3, and you shouldn't use int() anyway, but hey, it might come in handy to know this if you're still using int() in your code, and it doesnt work the way it should :)
Edit : My Collegue Hugo asked if Number() had the same bug. Apparantly it does, BUT. its not what I thought it was.
When you use Number() to convert a string to a number, you can use a leading zero to indicate you're using an OCTAL value just like 0x denotes a hexadecimal value.
So the bug actually isn't that int() works incorrectly, but that the manual doesn't say that you can use a leading 0 to indicate an octal value.
So why does it seem to be 'fixed' in as3.0? Well, you can use octal notation in as2.0, but this doesnt work anymore in as3.0.
Not sure why anyone would want to use octal notation, but to prove this, try this little example in as3.0 and as2.0
for (var intT=00; intT< 020; intT++)
{
trace(intT);
}
as2.0 will count to 15
as3.0 will count to 19
Saturday, February 2, 2008
Water ripple source
Here's the sourcecode for the water ripple effect.
Let me know what you think.
Download source
Have fun!
Let me know what you think.
Download source
Have fun!
Thursday, January 31, 2008
Comment mails
I thought I had turned on the 'send me an email when someone comments' but I hadn't. Silly me.
(Not that a lot of people comment on my posts yet... hint hint. ;)
So, sorry pCreate, I didn't see your comment until now. But I will post the sourcecode for the water-ripple when I get home tonight :P
(Not that a lot of people comment on my posts yet... hint hint. ;)
So, sorry pCreate, I didn't see your comment until now. But I will post the sourcecode for the water-ripple when I get home tonight :P
Saturday, January 26, 2008
Particle Fun
Using particles is fun, I've started working on my own Particle class for as2.0 (WHY as2.0 ? well, we have fidgety customers who still demand flashmovies in flash 8 or even flash 7 or 6 to be published by us :( )
Instead of the usual fireworks, sparks, explosions, clouds, etc, I've put together a small pseudo-game that was only meant for my collegues to show what other stuff you can do with particls. I've created a small game with it.
What it does :
- star particles, that move according to the relative position of the mouse compared to the middle of the screen. And that stretch to fake a motion-blur effect as they go faster.
- fake depth, slower stars are less bright.
- asteroid particles, which are the same as star-particles, but they dont rotate and stretch.
- missile - a plain particle with movement that gets shot out from the spaceship when you press the mousekey.
- spaceship - asteroid collision detection... hit an asteroid, and boom. your ship will explode in a fiery explosion... well it would have, if i had any graphics skills ;)
What it does NOT do:
- garbage collection. leave the movie on too long and it will just slow down your system :)
- the missile is just for show, it wont hit anything, and the movement is not correct. To have 'working' missiles you'd need to make the coordinates and speed in 'particle space' relative to the spaceship, take velocity into account etc... this is just a particle that moves like a rocket... as long as you dont turn away after you've fired :P
- no score or anything.
- 'tis just a particle demo.
Instead of the usual fireworks, sparks, explosions, clouds, etc, I've put together a small pseudo-game that was only meant for my collegues to show what other stuff you can do with particls. I've created a small game with it.
What it does :
- star particles, that move according to the relative position of the mouse compared to the middle of the screen. And that stretch to fake a motion-blur effect as they go faster.
- fake depth, slower stars are less bright.
- asteroid particles, which are the same as star-particles, but they dont rotate and stretch.
- missile - a plain particle with movement that gets shot out from the spaceship when you press the mousekey.
- spaceship - asteroid collision detection... hit an asteroid, and boom. your ship will explode in a fiery explosion... well it would have, if i had any graphics skills ;)
What it does NOT do:
- garbage collection. leave the movie on too long and it will just slow down your system :)
- the missile is just for show, it wont hit anything, and the movement is not correct. To have 'working' missiles you'd need to make the coordinates and speed in 'particle space' relative to the spaceship, take velocity into account etc... this is just a particle that moves like a rocket... as long as you dont turn away after you've fired :P
- no score or anything.
- 'tis just a particle demo.
Saturday, December 15, 2007
Iso, Particle, easing and water
I've wanted to do some AS3 stuff, never got round to do it yet so I finally set down and created this little thing.
Click to view
It shows 5000 little isometric bar-type thingies. and if you click and drag on them, they will simulate water ripples.
The bars ease to the ripple-data to make it all wobble around a bit smoother then by just using the ripple effect.
There's some bugs if you splash around too much at the top and bottom, but I couldn't be arsed to fix it. I'm coding this with my laptop actually on my lap, and its not the most convenient way to code thats for sure :)
Let me know what you think.
I got the water ripple routine from here
Click to view
It shows 5000 little isometric bar-type thingies. and if you click and drag on them, they will simulate water ripples.
The bars ease to the ripple-data to make it all wobble around a bit smoother then by just using the ripple effect.
There's some bugs if you splash around too much at the top and bottom, but I couldn't be arsed to fix it. I'm coding this with my laptop actually on my lap, and its not the most convenient way to code thats for sure :)
Let me know what you think.
I got the water ripple routine from here
Subscribe to:
Posts (Atom)