Författararkiv: bob
Converting AS2 to AS3, an art of casting.
Years ago when I started coding, I didn’t actually know how to code. Thankfully it has made all my old AS2 project perfectly compatible with the very restricted ways of building iPhone-apps using the new 5.5 techniques. I just need to convert everything to AS3 first, and the Search and Replace tool is by far the most powerful tool which I tend to forget. ( I assume it’s also available in other verisons than mine CS4) Just bring it up from the EDIT menu and don’t confuse it with the regular Search which also have a replace-function, but only for the text you are currently editing. This Sucker can search and replace through your whole project, on every frame in every object.
So what are we looking at?
_parent refeers to the movieClip’s parent. In most cases I got a movieClip lying on the stage in flash and if I enter them, this _parent refeers to the main stage from where I was.
Problem with getting that garbage working in AS3 is first, that the name is parent without the underscore.
Second that it doesn’t know what the parent is wich generates an error. By telling Flash (parent as MovieClip) it goes. ”oh! fine, thanks!” and then goes about, unknowing of the horrors I’ve just unleached.
This solves most problems.
Second thing to do is to define all variables for real.
apan=1;
now becomes
var apan:Boolean=true;
or
var apan:int=1;
Depending on what I need apan for.
Thirdly I change the name of the onEnterFrame() function or functions to something unique, and add a listener.
like
addEventListener(Event.ENTER_FRAME,onEveryMothaFacknnFrameBitch);
function onEveryMothaFacknnFrameBitch():void
{
trace(”hello world”);
}
And then I export, and of course get a ton of more errors but most of them variant’s of these solutions. I just step through the errors one at the time using some wits and lots of google.
Please do abuse these tips and spread awesome haxx onto the world and keep away from lazy helpers like ”Builders”. All you need is a very good memory on where everything is in your project, and how it works. This will also make it hack-free since noone will be able to read your code. It will take some hours everytime you need to get back to it in the future but it’s totally worth it.
k thnkz bye.
wireframe line intersection && z-sorting.
Clock is 06:08 , I’m of to work any minute now, just woke up an hour ago and really wanted to finish this before the ”weekend” ends. And hey. It finally works!
3D wireframe line intersection
So what are we looking at?
- First it backcull like I described last time.
- Then, I remove all dubplicate lines, most polygon share edges with other polygons and I don’t want to draw those edges twice.
- Sort all the lines based on their combined Z-value of it’s two cordinates.
I’ve made the first drawn line THICKER so it’s visible. For once I actually used a built in flash function called ”sort” which defaulted to sorting alfabetical. I did not notice that at first which led to very strange behaviours.
myArray.sort(Array.NUMERIC); // is the way to go.
- Then, I draw the lines, from my sorted line-array, front to back. For each line I draw I compare to already drawn lines to see if they intersect. If they do, I draw a little rectangle at that spot.
I had big help from this nice article http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html#OUT32.5.3
that in the end helped me solve the math a bit more elegant than my initial approuch. I have issues with using math and algorithms that I don’t understand so I can be a bit slow sometimes. But it’s important for me to understand it all. Otherwise I will not be able to use it later.
And that’s it for now.
Next step is cutting the lines at those spots. Since I know all visible triangles on the scene are clockwise, I will be able to calculate which side of the line should be visible.
Then I’m gonna built in a check to see if a line starts inside a polygon using the Barycentric algoritm described here :
http://www.blackpawn.com/texts/pointinpoly/default.html
I will try to build it so that a line can be cut off several time during it’s course and still function. For instance, if both ends of a line should start inside a polygon it still is possible that parts of the line is visible. So,
Yeah, that’s it for now.
3D wireframe clockwise clipping
I’ve been continuing on my wireframe 3D-engine.
You can steer the cube X && Y with arrow-keys .
in the edges of the screen it clip’s the edges right off, per edge.
in the edges of the screen it tries to do it in two directions and it bugs the hell out. UPDATED!
Then I tried to solve depthsorting, so it wouldn’t render the backside of the object. This was a painful process of trying to invent something new and exciting that could cut edges nicely anywhere on the edge that ended up with me throwing away the edge-drawer and made a proper polygon-drawer instead, cause I needed surfaces to calculate normals. I even ended up with triangles, so now I feel like a conformist asshole.
What it does is calculate wheter the surface rendered has it’s vertex on the screen clockwise or counterclockwise, since the cube is built with all polygons constructed clockwise if you where standing on each one of them when constructing. Thus the only reason a surface would end up counterclockwise on screen is if it’s pointed AWAY from it, thus it’s not tagged for the render-pass.
I had great help from this article when understanding the principle and math of it.: http://paulbourke.net/geometry/clockwise/index.html
This kind of depth-sort will not cull away polygons that are just overlapped, and by far does not help with render a partly-overlapped polygon, since it just draws whatever is pointed at the viewer, so I have a long road ahead of me, but it’s a nice start.
For the more advanced clipping I first must solve the edge-clipping routine that’s still a bit unstable, since if I can’t even cut the edges of the screen properly, how could I ever cut of an overlapping surface? .
G*P CAVE++
we made a little SFCave-clone, with some helpers.
Now it featured zoomed in bullettime when you are close to walls, && extra lifes so you can bounce around a bit.
UPDATE:
coloured levels. (it’s fun to feel progress)
Lifes are replaced by a auto-regenerate shield (it’s fun to bounce)
gamespeed slowed down a bit. (it’s fun to navigate)
yeah.
Also here’s the executable, without the browser lag, (better framerate)
version 1.3 (pc && mac executable)
version 1.3
version 1.2
The bullettime is achieved by splitting up the graphic-render timer with the gamelogic. A strange bug occured in the browser however, locking the gamelogic timer to slower value than I demanded. Quick fixed by putting everything in the gamelogic through a small forloop to force it to update quicker, resulting in a somewhat jaggy experience.
Well, it’s a quick n dirty 3hour take on SFCave / DWCave (c64) .
enjoy.
Sound Generator Special Oscilator Button
I’m in the process of something big now I feel. One big step before going further has been to make the oscilator a bit more usable.
So I added an ”osc”-button. What it does is nail the latest soundwave to the left side of the oscilatorwindow and then draws it out. If it’s high freq it’s short, and if it’s low it’s of course longer than the actual screen. This will be MY GREATEST TOOL YET for analyzing exactly what I do with the bytearray. It’s also a bit more sane than a regular spectrum-view.
Next up, sliders for all attributes available attributes, some strange compressorstyle normalizer and finally, vowels. Vowels are my current main goal so what I need to do now is really dig into the math and algorithms surrounding curve-generation and make some kind of soundwave-editor.



