If you think the Android project DeathRally listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package project.gamedev.deathrally.game.graphics;
/*www.java2s.com*/import javax.microedition.khronos.opengles.GL10;
import android.util.Log;
publicclass Rectangle extends Mesh{
privatestaticfinal String TAG = Rectangle.class.getSimpleName();
//Painting CCW but remember shapes are rotated 180 by default
privatefinalshort indices[] = {0,2,1,0,3,2};
public Rectangle(float px, float py, float width, float height){
super(px,py,GL10.GL_TRIANGLES);
float[] verticeList = {
px-width/2,py+height/2,0.0f,
px-width/2,py-height/2,0.0f,
px+width/2,py-height/2,0.0f,
px+width/2,py+height/2,0.0f
};
setVertices(verticeList);
setIndices(indices);
Log.d(TAG, "Rectangle created successfully");
}
}