Collision detection,
All games have them. Whether its mario running into a turtle or a bullet flying past your head in CS or you getting stuck in a tree in your favorite mmorpg.
So how do you do it ? How do you detect if one object is colliding with another ?
One very inefficient way is to just compare each objects (x,y) to the bounds of every other object on the screen. So if you have 5 objects each object must compare to each other so thats 5*5, for n objects thats n*n. So thats big oh of O(N2).
But what if we were to split the screen into 4 sections and only check for object collisions between objects that are in the same quadrant? Well ya, that works great! What if we split those four quadrants into 4 more quadrants ? This way we can only check for a collision between objects in the smallest quadrants. I dont like the name “quadrant” it only works when you have 4 so lets call them “nodes”.
So there are 4 nodes for each parent node, well that sounds like some sort of tree, it is!
A quad tree has 4 child nodes for each parent nodes. We only check for collisions in leaf nodes, so for depth=1 that is 4 nodes, for depth=2 that is 16 nodes and so on.
This really reduces collision calculations.
I wont explain anymore, ill show it to you. Use this java applet to see. Start with 50 objects and a depth of 1, then increment your depth. Keep your eye on the calculation in the upper left corner of the screen, this is the total number of calculations. Each node also shows its current calculations.
To pause it drag over the screen, to resume just move the mouse without dragging. Also the objects repel off each other and your mouse, and the sides of the screen.
here is the link (i would stay below 200 objects, and depth 5 or else you might crash
)
http://www.zonemikel.com/Java/quadtreeexample/quadtreeexample.html
Picture Math By Zonemikel,

If you want a way for kids to do math homework and have fun, well it does not exist
You can however make it a little more personal.
With Picture Math you can select a folder on your local machine with pictures and while kids are doing their math homework they can see the pictures. The pictures only change if the math problem was correct, so this motivates children to see what is next.
This applet can be run right from this web page. It will scan the folder you select for pictures, and it will get sub folders of that folder and randomly display images when a correct math problem is solved.
How to use ?
All you have to do is click the link below and put in the information, then hit launch.
The “operator” can be +, – or *
The “arguments” can be from 0 to 5. If you have smaller kids set arguments to 1 and let them practice typing numbers!
Difficulty should start out at 0. Difficulty of 0 means the numbers will be around 0 to 5. Above that setting the maximum value of arguments will be difficulty*10. so for instance a difficulty of 2 would give you problems like 13 + 20.
Set size is the amount of problems before finishing a level.
You must click the button “set pics” and select a picture in a folder with lots of pictures, if not no picture will show and it will look bland !
How do the levels work ?
Well every time a set is compleated, if above 90% was recived arguments will get incramented. So if you had 2 arguments before (2+4) you will now have 3 (2+3+4) but the difficulty will remain the same until you have reached 5 arguments, then it will increase the difficulty and change arguments to 2 again.
Few more things you should know
When you finish a level hit ‘n’ to go to the ‘n’ext level
If you want to see a log of all the progress hit ‘l’ L and hit ‘l’ again to turn it off
After each level is completed it will display your grade and problems per second
To start over again just refresh the page.
You must accept the security thing or the applet cannot read files on your pc
I am no longer working on this.
Well for some reason i hate swing. I think it looks really crappy and I think its really clumsy to work with! All that .add this etc, horrible and cumbersome.
So I’ve set out to make my own window type class, I am unable to make something nice at least I’ll have more respect for the swing class 
Im having troubles making it so when you move/resize select a window you dont select or preform actions on windows below it. Since the window below your window’s bounds actually contains the mouse point also. This is only a problem when there are tons of windows, none the less I plan on fixing that before i move on to window components like text areas and buttons etc.

here is the applet if you wish to run it, you can resize and move the windows.
http://www.zonemikel.com/Java/appletwindows/preview1/MainApplet.html
I will continue to post here as this progresses.
Believe it or not there is only one thread running. And im using two classes a SceneManager and the Window class itself. I can make the windows easily, like so
for (int i=0; i< 25; i++){
if(j==5){j=0;k++;}
winText = "Window: " + i + '^';
asm.addWindow(winText, j*160, k*120,160,120);
j++;
}

Categories
Tag Cloud
Blog RSS
Comments RSS

Void « Default
Life
Earth
Wind
Water
Fire
Light 