So I'm creating an EMP....

Note: this post has been copied from the Programming section, i won't link it b/c all the replies were useless.

A graphical one that is.

The technique that I'm using is this:

-create a grid of points

-have them move around according to formulas

-render them where lines are drawn from point to adjacent point.

So, a particle in the array at [3],[3] would have lines connected to [2][3] & [3][2] & [4][3] & [3][4].

At first, I did the simplest thing:

loop through with Particle p,pp being onces that need to be connected

g.drawLine(p.x,p.y,pp.x,pp.y);

This was incredibly slow.

Then I instead added all points to a Polygon and called:

g.drawPolygon(poly);

This was much faster, but the problem is that the polygon method connects some points that i dont want to be connected and doesn't connect others that i want to be connected.

Is there an algorithm for the order to add points to the polygon in order for it to correctly draw a grid with as little overlapping lines as possible?

Thanks!

[1101 byte] By [Nethera] at [2007-11-27 6:53:35]
# 1
More information:I'm trying to make it look like the EMP (Electro-magnetic pulse) in the matrix.
Nethera at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 2
Nether, Did you write these games? http://www.frozenfountain.net/games.phpThey look really good.
TuringPesta at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 3
ya I did :)
Nethera at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 4

Is this a 3D game?

Ive done 3D programming and this is how i would do it to start with.

The EMP like in the movie is made to look like a blast wave that

is expanding. So just render an expanding Sphere.

The only way to properly render this would be to calculate the

distance between the camera and the emp wave positions at

the screen locations and use lighting to represent depth.

You dont have to to every pixel. Just do some point and interpolate

the rest.

TuringPesta at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 5
no its not a 3d game, but i've already got a good looking solution, i just need to solve the problem of creating a 10x10 grid of points and adding the points to a polygon in such a way, that it actually renders the grid properly.
Nethera at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 6
What is going on with the tank game? I think there is a bug. The rectangle following the tank is supposed tobe the tank barrel I think but its not rotating with the tank. Im using Java 6.
TuringPesta at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 7
i dont remember there being a tank barrel (i havent used that game in a long time)ya, theres definitly not a tank barrel, i guess one of the black blocks got stuck onto the tankMessage was edited by: Nether
Nethera at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 8
No its not the black walls.The red and blue tanks have this little light green wall following them arround.Is it the tank tread?If so, it is only drawing one and not the other.Having the bouncing walls was a good idea by the way.
TuringPesta at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 9
that's really weird, i dont see that when I run it.
Nethera at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 10
I think for your problem you need some form of Triangulation formulawhich might be a bit hard for you.I would use another structure other than an array or Polygon.Then draw that with drawLine.
TuringPesta at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...
# 11

>At first, I did the simplest thing:

>loop through with Particle p,pp being onces that need to be connected

>

>g.drawLine(p.x,p.y,pp.x,pp.y);

>

>This was incredibly slow.

that should not be slow at all. if you only hava a 10 by 10 grid of points it should only take miliseconds. I made a large applet that does pixel by pixel rendering with g.drawLine( x , y , x , y ); You should look over your method of drawing the lines. www.duke.edu/~kef14/Mandelbrot.html

the drawPolygon(); uses the drawLine() function...

Also for the polygons without overlap you should draw polygons in a checker-board pattern. --If you outline all of the black squares in a checker-board, you will get a grid with NO overlap. You will still have to draw a few lines around the perimeter to fill in the gaps.

hope that helps

RAIN_MANa at 2007-7-12 18:28:23 > top of Java-index,Other Topics,Java Game Development...