Implementation of the destruction of the landscape, for example, the game Scorched Earth on iphone or Java

I am looking for an example of how to implement 2D terrain destruction that you see in games like scorched earth or on the iPhone iShoot .

I'm looking for an implementation of a game that needs to make a destructible terrain and render it using OpenGL (LWJGL in Java) and use OpenGL ES on the iPhone.

alt text http://www.vintagecomputing.com/wp-content/images/shareware/scorch_3_large.png

+3
source share
2 answers

, Worms ; "" , -. .

, , Tank Wars, . - , , .

, 1 , 0 . , [0] :

[1,1,1,1,1,1,0,0,0,0]

, :

[1,1,0,0,1,1,0,0,0,0]

. , , , 0 ( ). , , 1 () 1 , 0. , 0 + 1.

[1,1,1,0,0,1,0,0,0,0]

[1,1,1,1,0,0,0,0,0,0]

, . , .

EDIT:

, . , , .

+7

! Scorched Earth iPhone. , , , , . iShoot, iShoot . , , . , , . Scorched Earth - , , , .

, OpenGL , :

1 3 5 7 9
0 2 4 6 8

. . , glVertexPointer, glColorPointer glDrawArrays , :

// prepare vertex buffer
for (int i=0,j,k=0,K=480;k<=K;k++) {
    j = (k-(int)offsetX+480)%480;
    vGroundLevel[i++] = k;
    vGroundLevel[i++] = offsetY>0 ? 0 : offsetY;
    vGroundLevel[i++] = k;
    vGroundLevel[i++] = [env groundLevelAtIndex:j]+offsetY;
}
....
// render vertex buffer
glVertexPointer(2, GL_FLOAT, 0, vGroundLevel);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cGround);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 2*480);

offsetX offsetY , , .

+2

Source: https://habr.com/ru/post/1708004/


All Articles