private void initHolesBitmaps(List<Hole> holes) throws ParseException, LoadException { for (Hole hole : holes) { hole.setBitmap( (Bitmap) ContentProcessor.init() .useCache(BitmapMemoryCache.getInstance()) .fromRes(resources) .bitmap() .load(String.valueOf(Hole.getModelIds()[0]))); hole.setRocksBitmap( (Bitmap) ContentProcessor.init() .useCache(BitmapMemoryCache.getInstance()) .fromRes(resources) .bitmap() .load(String.valueOf(Hole.getRocksModelIds()[0]))); for (Rock rock : hole.getRocks()) { rock.setBitmap( (Bitmap) ContentProcessor.init() .useCache(BitmapMemoryCache.getInstance()) .fromRes(resources) .bitmap() .load(String.valueOf(Rock.getRandomModelResId()))); } } }
@Test public void shouldNotReturnScissorsName() { Rock mockRock = new Rock(); mockRock.setName("falseRockName"); assertNotSame(mockRock.getName(), this.rockName); assertFalse(mockRock.getName() == this.rockName); }
public static Polygon getPolygon() { // Create one vertex per segment. Each vertex has 2 coordinates. // Remember to save one vertex for the center point. return Rock.getRockPolygon(Debris.RADIUS, 12); }
private void initKalahBitmaps(Kalah kalah) throws ParseException, LoadException { kalah.setBitmap( (Bitmap) ContentProcessor.init() .useCache(BitmapMemoryCache.getInstance()) .fromRes(resources) .bitmap() .load(String.valueOf(Kalah.getModelIds()[0]))); kalah.setRocksBitmap( (Bitmap) ContentProcessor.init() .useCache(BitmapMemoryCache.getInstance()) .fromRes(resources) .bitmap() .load(String.valueOf(Kalah.getRocksModelIds()[0]))); for (Rock rock : kalah.getRocks()) { rock.setBitmap( (Bitmap) ContentProcessor.init() .useCache(BitmapMemoryCache.getInstance()) .fromRes(resources) .bitmap() .load(String.valueOf(Rock.getRandomModelResId()))); } }
@Test public void shouldReturnRockName() { Rock mockRock = new Rock(); mockRock.setName(rockName); assertEquals(mockRock.getName(), this.rockName); assertTrue(mockRock.getName() == this.rockName); }
public Rock at(final int derivative, final double t, Rock ret) { if (ret == null) ret = new RockDouble(); ret.setLocation(at(0, derivative, t), at(1, derivative, t), at(2, derivative, t)); return ret; }
private void updateWorld() { float deltaTime = Gdx.graphics.getDeltaTime(); planeStateTime += deltaTime; if (Gdx.input.justTouched()) { if (gameState == GameState.Start) { gameState = GameState.Running; } if (gameState == GameState.Running) { planeVelocity.set(PLANE_VELOCITY_X, PLANE_JUMP_IMPULSE); } if (gameState == GameState.GameOver) { gameState = GameState.Start; resetWorld(); } } if (gameState != GameState.Start) planeVelocity.add(gravity); planePosition.mulAdd(planeVelocity, deltaTime); camera.position.x = planePosition.x + 350; if (camera.position.x - groundOffsetX > ground.getRegionWidth() + 400) { groundOffsetX += ground.getRegionWidth(); } rect1.set( planePosition.x + 20, planePosition.y, plane.getKeyFrames()[0].getRegionWidth() - 20, plane.getKeyFrames()[0].getRegionHeight()); for (Rock r : rocks) { if (camera.position.x - r.position.x > 400 + r.image.getRegionWidth()) { boolean isDown = MathUtils.randomBoolean(); r.position.x += 5 * 200; r.position.y = isDown ? 480 - rock.getRegionHeight() : 0; r.image = isDown ? rockDown : rock; r.counted = false; } rect2.set( r.position.x + (r.image.getRegionWidth() - 30) / 2 + 20, r.position.y, 20, r.image.getRegionHeight() - 10); if (rect1.overlaps(rect2)) { if (gameState != GameState.GameOver) explode.play(); gameState = GameState.GameOver; planeVelocity.x = 0; } if (r.position.x < planePosition.x && !r.counted) { score++; r.counted = true; } } if (planePosition.y < ground.getRegionHeight() - 20 || planePosition.y + plane.getKeyFrames()[0].getRegionHeight() > 480 - ground.getRegionHeight() + 20) { if (gameState != GameState.GameOver) explode.play(); gameState = GameState.GameOver; planeVelocity.x = 0; } }