public void update() { float proposedX = mGame.getSpaceShip().getXPosition() - (mXDimension / 2) + count; float proposedY = mGame.getSpaceShip().getYPosition() - (mYDimension / 2) + count; if (proposedX > 0 && proposedX + mXDimension < mGame.getCurrentLevel().getWidth()) { mXPosition = proposedX; } if (proposedY > 0 && proposedY + mYDimension < mGame.getCurrentLevel().getHeight()) { mYPosition = proposedY; } mMiniMap.update(); }
public void draw() { // Draw outer (border) rectangle DrawingHelper.drawFilledRectangle( new Rect( (int) (DrawingHelper.getGameViewWidth() * .8f) - 6, 0, DrawingHelper.getGameViewWidth(), (int) (DrawingHelper.getGameViewHeight() * .2f) + 6), Color.BLUE, 100); // Draw inner rectangle DrawingHelper.drawFilledRectangle( new Rect( (int) (DrawingHelper.getGameViewWidth() * .8f), 3, DrawingHelper.getGameViewWidth() - 3, (int) (DrawingHelper.getGameViewHeight() * .2f)), Color.BLACK, 100); ArrayList<AsteroidType> gameAsteroids = AsteroidsGameModel.getInstance().getAsteroidTypes(); SpaceShip ship = AsteroidsGameModel.getInstance().getSpaceShip(); // Calculate and draw position for the ship float xScaledAndShifted = (ship.getXPosition() * .2f) * mXDimension / mGame.getCurrentLevel().getWidth() + // mXPosition + (DrawingHelper.getGameViewWidth() * .8f); float yScaledAndShifted = (ship.getYPosition() * .2f) * mYDimension / mGame.getCurrentLevel().getHeight(); /*+ mYPosition;*/ DrawingHelper.drawPoint( new PointF(xScaledAndShifted, yScaledAndShifted), 3, Color.GREEN, 255); // Calculate position for the asteroids for (AsteroidType a : gameAsteroids) { float xScaleShift = (a.getPosition().x * .2f) * mXDimension / mGame.getCurrentLevel().getWidth() + // mXPosition + (DrawingHelper.getGameViewWidth() * .8f); float yScaleShift = (a.getPosition().y * .2f) * mYDimension / mGame.getCurrentLevel().getHeight(); /*+ mYPosition;*/ DrawingHelper.drawPoint(new PointF(xScaleShift, yScaleShift), 4, Color.RED, 255); } }
public void draw() { int newXPos = Math.round((mXPosition / mGame.getCurrentLevel().getWidth()) * 1300); int newYPos = Math.round((mYPosition / mGame.getCurrentLevel().getHeight()) * 1500); int newXDim = Math.round(newXPos + (mXDimension)); // * mGame.getCurrentLevel().getWidth()) / 2048); int newYDim = Math.round(newYPos + (mYDimension)); // * mGame.getCurrentLevel().getWidth()) / 2048); DrawingHelper.drawImage( ContentManager.getInstance().getImageId("images/space.bmp"), new Rect(newXPos, newYPos, newXDim, newYDim), null); mMiniMap.draw(); }