1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.tests.bullet; 18 19 import com.badlogic.gdx.Gdx; 20 import com.badlogic.gdx.graphics.Color; 21 import com.badlogic.gdx.graphics.Texture; 22 import com.badlogic.gdx.graphics.VertexAttribute; 23 import com.badlogic.gdx.graphics.VertexAttributes; 24 import com.badlogic.gdx.graphics.VertexAttributes.Usage; 25 import com.badlogic.gdx.graphics.g3d.Material; 26 import com.badlogic.gdx.graphics.g3d.Model; 27 import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; 28 import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; 29 import com.badlogic.gdx.graphics.g3d.utils.TextureDescriptor; 30 import com.badlogic.gdx.graphics.glutils.ShaderProgram; 31 import com.badlogic.gdx.math.Vector3; 32 33 /** @author Xoppa */ 34 public class ShootTest extends BaseBulletTest { 35 final int BOXCOUNT_X = 5; 36 final int BOXCOUNT_Y = 5; 37 final int BOXCOUNT_Z = 1; 38 39 final float BOXOFFSET_X = -2.5f; 40 final float BOXOFFSET_Y = 0.5f; 41 final float BOXOFFSET_Z = 0f; 42 43 BulletEntity ground; 44 45 @Override create()46 public void create () { 47 super.create(); 48 49 // Create the entities 50 (ground = world.add("ground", 0f, 0f, 0f)).setColor(0.25f + 0.5f * (float)Math.random(), 51 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f); 52 53 for (int x = 0; x < BOXCOUNT_X; x++) { 54 for (int y = 0; y < BOXCOUNT_Y; y++) { 55 for (int z = 0; z < BOXCOUNT_Z; z++) { 56 world.add("box", BOXOFFSET_X + x, BOXOFFSET_Y + y, BOXOFFSET_Z + z).setColor(0.5f + 0.5f * (float)Math.random(), 57 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f); 58 } 59 } 60 } 61 } 62 63 @Override tap(float x, float y, int count, int button)64 public boolean tap (float x, float y, int count, int button) { 65 shoot(x, y); 66 return true; 67 } 68 69 @Override dispose()70 public void dispose () { 71 super.dispose(); 72 ground = null; 73 } 74 } 75