com.badlogic.gdx.math.Rectangle Java Examples

The following examples show how to use com.badlogic.gdx.math.Rectangle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShopCard.java    From Klooni1010 with GNU General Public License v3.0 6 votes vote down vote up
ShopCard(final Klooni game, final GameLayout layout,
         final String itemName, final Color backgroundColor) {
    this.game = game;
    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font_small");

    priceLabel = new Label("", labelStyle);
    nameLabel = new Label(itemName, labelStyle);

    Color labelColor = Theme.shouldUseWhite(backgroundColor) ? Color.WHITE : Color.BLACK;
    priceLabel.setColor(labelColor);
    nameLabel.setColor(labelColor);

    priceBounds = new Rectangle();
    nameBounds = new Rectangle();

    layout.update(this);
}
 
Example #2
Source File: DebugRendererSystem.java    From Entitas-Java with MIT License 6 votes vote down vote up
@Override
public void render() {
   // cam.update();
    batch.begin();
    Rectangle rect = new Rectangle(cam.position.x, cam.position.y, 3, 10);

    shapeRenderer.setProjectionMatrix(cam.combined);

    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    shapeRenderer.identity();
    shapeRenderer.translate(20, 12, 2);
    shapeRenderer.rotate(0, 0, 1, 90);
    shapeRenderer.rect(cam.position.x , cam.position.y, 50, 30);
    shapeRenderer.end();

    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    shapeRenderer.identity();
    shapeRenderer.translate(20, 12, 2);
    shapeRenderer.rotate(0, 0, 1, 90);
    shapeRenderer.rect(-rect.getX() / 2, -rect.getY() / 2, rect.width, rect.height);
    shapeRenderer.end();
    debugRenderer.render(physics, cam.combined);
    batch.end();
}
 
Example #3
Source File: SkinTextFont.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
private void setLayout(Color c, Rectangle r) {
    if (isWrapping()) {
        layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], true);
    } else {
        switch (getOverflow()) {
        case OVERFLOW_OVERFLOW:
            layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false);
            break;
        case OVERFLOW_SHRINK:
            layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false);
            float actualWidth = layout.width;
            if (actualWidth > r.getWidth()) {
                font.getData().setScale(font.getData().scaleX * r.getWidth() / actualWidth, font.getData().scaleY);
                layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false);
            }
            break;
        case OVERFLOW_TRUNCATE:
            layout.setText(font, getText(), 0, getText().length(), c, r.getWidth(), ALIGN[getAlign()], false, "");
            break;
        }
    }
}
 
Example #4
Source File: DrawTheCantorGasket.java    From ud405 with MIT License 6 votes vote down vote up
private Rectangle findLargestSquare() {
    Rectangle largestSquare = new Rectangle();
    float screenWidth = Gdx.graphics.getWidth();
    float screenHeight = Gdx.graphics.getHeight();

    Gdx.app.log("Derp",  "Screen size " + screenWidth + " " + screenHeight);

    if (screenWidth > screenHeight) {
        largestSquare.x = (screenWidth - screenHeight) / 2;
        largestSquare.y = 0;
        largestSquare.width = screenHeight;
        largestSquare.height = screenHeight;
    } else {
        largestSquare.x = 0;
        largestSquare.y = (screenHeight - screenWidth) / 2;
        largestSquare.width = screenWidth;
        largestSquare.height = screenWidth;
    }
    return largestSquare;
}
 
Example #5
Source File: PieceHolder.java    From Klooni1010 with GNU General Public License v3.0 6 votes vote down vote up
public boolean pickPiece() {
    Vector2 mouse = new Vector2(
            Gdx.input.getX(),
            Gdx.graphics.getHeight() - Gdx.input.getY()); // Y axis is inverted

    final float perPieceWidth = area.width / count;
    for (int i = 0; i < count; ++i) {
        if (pieces[i] != null) {
            Rectangle maxPieceArea = new Rectangle(
                    area.x + i * perPieceWidth, area.y, perPieceWidth, area.height);

            if (maxPieceArea.contains(mouse)) {
                heldPiece = i;
                return true;
            }
        }
    }

    heldPiece = -1;
    return false;
}
 
Example #6
Source File: RectangleCircleCollisionScreen.java    From ud406 with MIT License 6 votes vote down vote up
private boolean areColliding(Rectangle rectangle, Circle circle) {

        // TODO: Complete this function!

        boolean containsACorner = circle.contains(rectangle.x, rectangle.y) || // Bottom left
                circle.contains(rectangle.x + rectangle.width, rectangle.y) || // Bottom right
                circle.contains(rectangle.x + rectangle.width, rectangle.y + rectangle.height) || // Top Right
                circle.contains(rectangle.x, rectangle.y + rectangle.height); // Top left

        boolean inHorizontalInterval = rectangle.x < circle.x && circle.x < rectangle.x + rectangle.width;
        boolean inVerticalInterval = rectangle.y < circle.y && circle.y < rectangle.y + rectangle.height;

        boolean inHorizontalNeighborhood = rectangle.x - circle.radius < circle.x && circle.x < rectangle.x + rectangle.width + circle.radius;
        boolean inVerticalNeighborhood = rectangle.y - circle.radius < circle.y && circle.y < rectangle.y + rectangle.height + circle.radius;

        boolean touchingAnEdge = inHorizontalInterval && inVerticalNeighborhood ||
                inHorizontalNeighborhood && inVerticalInterval;

        return containsACorner || touchingAnEdge;
    }
 
Example #7
Source File: MundusMultiSplitPane.java    From Mundus with Apache License 2.0 6 votes vote down vote up
/**
 * Changes widgets of this split pane. You can pass any number of actors
 * even 1 or 0. Actors can't be null.
 */
public void setWidgets(Actor... actors) {
    clearChildren();
    widgetBounds.clear();
    scissors.clear();
    handleBounds.clear();
    splits.clear();

    for (Actor actor : actors) {
        super.addActor(actor);
        widgetBounds.add(new Rectangle());
        scissors.add(new Rectangle());
    }
    float currentSplit = 0;
    float splitAdvance = 1f / actors.length;
    for (int i = 0; i < actors.length - 1; i++) {
        handleBounds.add(new Rectangle());
        currentSplit += splitAdvance;
        splits.add(currentSplit);
    }
    invalidate();
}
 
Example #8
Source File: MoveSystem.java    From Entitas-Java with MIT License 6 votes vote down vote up
@Override
public void execute(float deltatime) {
    for (CoreEntity e : _group.getEntities()) {
        Motion motion = e.getMotion();
        View view = e.getView();

        if (view.shape instanceof Rectangle) {
            Rectangle ret = (Rectangle) view.shape;
            ret.setPosition(ret.x + motion.velocity.x * Gdx.graphics.getDeltaTime(),
                    ret.y + motion.velocity.y * Gdx.graphics.getDeltaTime());
        } else {
            Circle circle = (Circle) view.shape;
            circle.setPosition(circle.x + motion.velocity.x * Gdx.graphics.getDeltaTime()
                    , circle.y + motion.velocity.y * Gdx.graphics.getDeltaTime());
        }
    }
}
 
Example #9
Source File: SkinTextBitmap.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
private void setLayout(Color c, Rectangle r) {
	if (isWrapping()) {
		layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], true);
	} else {
		switch (getOverflow()) {
		case OVERFLOW_OVERFLOW:
			layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false);
			break;
		case OVERFLOW_SHRINK:
			layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false);
			float actualWidth = layout.width;
			if (actualWidth > r.getWidth()) {
				font.getData().setScale(font.getData().scaleX * r.getWidth() / actualWidth, font.getData().scaleY);
				layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false);
			}
			break;
		case OVERFLOW_TRUNCATE:
			layout.setText(font, getText(), 0, getText().length(), c, r.getWidth(), ALIGN[getAlign()], false, "");
			break;
		}
	}
}
 
Example #10
Source File: DrawTheCantorGasket.java    From ud405 with MIT License 6 votes vote down vote up
private Rectangle findLargestSquare(){
    Rectangle largestSquare = new Rectangle();
    float screenWidth = Gdx.graphics.getWidth();
    float screenHeight = Gdx.graphics.getHeight();

    if (screenWidth > screenHeight){
        largestSquare.x = (screenWidth - screenHeight)/2;
        largestSquare.y = 0;
        largestSquare.width = screenHeight;
        largestSquare.height = screenHeight;
    } else {
        largestSquare.x = 0;
        largestSquare.y = (screenHeight - screenWidth)/2;
        largestSquare.width = screenWidth;
        largestSquare.height = screenWidth;
    }
    return largestSquare;
}
 
Example #11
Source File: Renderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
public Renderer (OrthographicCamera cam, Worm worm, Food food, Level level) {
	font = new BitmapFont(Gdx.files.internal(FONT_LOC));
	this.cam = cam;
	this.worm = worm;
	wholeWorm = worm.getAllBody();
	this.food = food;
	levelArray = level.getLevelArray();
	shapeRenderer = new ShapeRenderer();
	random = new Random();
	color = new Color();
	color.r = Color.WHITE.r;
	color.g = Color.WHITE.g;
	color.b = Color.WHITE.b;
	color.a = Color.WHITE.a;
	rect = new Rectangle();
	batch = new SpriteBatch();
}
 
Example #12
Source File: DrawTheCantorGasket.java    From ud405 with MIT License 6 votes vote down vote up
@Override
public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Rectangle bounds = findLargestSquare();

    // TODO: Begin a filled shapeRenderer batch
    shapeRenderer.begin(ShapeType.Filled);

    // TODO: Draw a white square matching the bounds
    shapeRenderer.setColor(Color.WHITE);
    shapeRenderer.rect(bounds.x, bounds.y, bounds.width, bounds.height);

    // TODO: Set the working color to black, and call punchCantorGasket with the bounds
    shapeRenderer.setColor(Color.BLACK);
    punchCantorGasket(bounds.x, bounds.y, bounds.width, RECURSIONS);

    // TODO: End the batch
    shapeRenderer.end();
}
 
Example #13
Source File: MultiSplitPane.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
/** Changes widgets of this split pane. You can pass any number of actors even 1 or 0. Actors can't be null. */
public void setWidgets (Iterable<Actor> actors) {
	clearChildren();
	widgetBounds.clear();
	scissors.clear();
	handleBounds.clear();
	splits.clear();

	for (Actor actor : actors) {
		super.addActor(actor);
		widgetBounds.add(new Rectangle());
		scissors.add(new Rectangle());
	}
	float currentSplit = 0;
	float splitAdvance = 1f / getChildren().size;
	for (int i = 0; i < getChildren().size - 1; i++) {
		handleBounds.add(new Rectangle());
		currentSplit += splitAdvance;
		splits.add(currentSplit);
	}
	invalidate();
}
 
Example #14
Source File: RectangleCircleCollisionScreen.java    From ud406 with MIT License 6 votes vote down vote up
public RectangleCircleCollisionScreen() {
    startTime = TimeUtils.nanoTime();
    shapeRenderer = new ShapeRenderer();
    viewport = new FitViewport(WORLD_SIZE, WORLD_SIZE);

    rectangles = new Array<Rectangle>(new Rectangle[]{
            new Rectangle(40, 40, 20, 20), // Middle
            new Rectangle(10, 40, 10, 20), // Left
            new Rectangle(70, 45, 20, 10) // Right
    });

    circles = new Array<OscillatingCircle>(new OscillatingCircle[]{
            new OscillatingCircle(50, 65, 7, 0, 40, 3), // High horizontal
            new OscillatingCircle(50, 35, 7, 0, 40, 3.1f), // Low horizontal
            new OscillatingCircle(50, 50, 3, MathUtils.PI / 4, 40, 5f), // Diagonal
            new OscillatingCircle(25, 50, 5, 0, 11, 7f), // Middle horizontal
    });
}
 
Example #15
Source File: LookAtAction.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
@Override
public boolean run(VerbRunner cb) {

	// EngineLogger.debug("LOOKAT ACTION");
	InteractiveActor a = (InteractiveActor) w.getCurrentScene().getActor(actor, true);

	if (w.getInventory().get(actor) == null) {
		CharacterActor player = w.getCurrentScene().getPlayer();

		if (direction != null && player != null)
			player.lookat(direction.getDirection());
		else if (a != null && player != null) {
			Rectangle bbox = a.getBBox().getBoundingRectangle();
			player.lookat(new Vector2(bbox.width / 2 + bbox.x, bbox.y));
		}
	}

	if (text != null) {
		String actorId = w.getCurrentScene().getPlayer() != null ? w.getCurrentScene().getPlayer().getId() : null;

		w.getCurrentScene().getTextManager().addText(text, TextManager.POS_SUBTITLE, TextManager.POS_SUBTITLE,
				false, Text.Type.SUBTITLE, null, null, actorId, voiceId, null, wait ? cb : null);

		return wait;
	}

	return false;
}
 
Example #16
Source File: LyU.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
public static Rectangle parseRect(String vector) {
    Rectangle res = new Rectangle();
    String[] strs = vector.split(",");
    if (strs.length != 4) {
        throw new RuntimeException("parseRect error!!");
    }
    res.x = Integer.parseInt(strs[0].substring(strs[0].lastIndexOf('{') + 1, strs[0].length()).trim());
    res.y = Integer.parseInt(strs[1].substring(0, strs[1].indexOf('}')).trim());
    res.width = Integer.parseInt(strs[2].substring(strs[2].indexOf('{') + 1, strs[2].length()).trim());
    res.height = Integer.parseInt(strs[3].substring(0, strs[3].indexOf('}')).trim());
    return res;
}
 
Example #17
Source File: Scene2dUtils.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
public static Rectangle localToStageBounds(Actor actor, float x0, float y0, float x1, float y1) {
    Rectangle stageRect = Scene2dUtils.tmpRect;
    actor.localToStageCoordinates(tmpVec2.set(x0, y0));
    stageRect.setX(tmpVec2.x);
    stageRect.setY(tmpVec2.y);
    actor.localToStageCoordinates(tmpVec2.set(x1, y1));
    stageRect.setWidth(tmpVec2.x - stageRect.x);
    stageRect.setHeight(tmpVec2.y - stageRect.y);
    return stageRect;
}
 
Example #18
Source File: MultiSplitPane.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void layout () {
	if (!vertical)
		calculateHorizBoundsAndPositions();
	else
		calculateVertBoundsAndPositions();

	SnapshotArray<Actor> actors = getChildren();
	for (int i = 0; i < actors.size; i++) {
		Actor actor = actors.get(i);
		Rectangle bounds = widgetBounds.get(i);
		actor.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
		if (actor instanceof Layout) ((Layout) actor).validate();
	}
}
 
Example #19
Source File: GameLayout.java    From Klooni1010 with GNU General Public License v3.0 5 votes vote down vote up
public void update(Band band) {
    final Rectangle area = new Rectangle(
            0, pieceHolderHeight + boardHeight,
            screenWidth, scoreHeight);

    band.setBounds(area.x, area.y, area.width, area.height);
    // Let the band have the following shape:
    // 10% (100) padding
    // 35% (90%) score label
    // 10% (55%) padding
    // 35% (45%) info label
    // 10% (10%) padding
    band.scoreBounds.set(area.x, area.y + area.height * 0.55f, area.width, area.height * 0.35f);
    band.infoBounds.set(area.x, area.y + area.height * 0.10f, area.width, area.height * 0.35f);
}
 
Example #20
Source File: HelpScreen5.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
public HelpScreen5 (SuperJumper game) {
	this.game = game;

	guiCam = new OrthographicCamera(320, 480);
	guiCam.position.set(320 / 2, 480 / 2, 0);
	nextBounds = new Rectangle(320 - 64, 0, 64, 64);
	touchPoint = new Vector3();
	helpImage = Assets.loadTexture("data/help5.png");
	helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}
 
Example #21
Source File: TriangleTest.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
@Test //Width Zero Rectangle InterSect
public void rectangleIntersectsTriangleTrueWidthZeroTest(){
    
    tri = new Triangle(new Vector2f(2, 2), new Vector2f(2, 15), new Vector2f(10, 2));
    seventh.math.Rectangle rectangle = new seventh.math.Rectangle(new Vector2f(1, 3),15,0);
    assertTrue(true == tri.rectangleIntersectsTriangle(rectangle,tri));
}
 
Example #22
Source File: GameStage.java    From martianrun with Apache License 2.0 5 votes vote down vote up
private void setUpAchievements() {
    Rectangle achievementsButtonBounds = new Rectangle(getCamera().viewportWidth * 23 / 25,
            getCamera().viewportHeight / 2, getCamera().viewportHeight / 10,
            getCamera().viewportHeight / 10);
    achievementsButton = new AchievementsButton(achievementsButtonBounds,
            new GameAchievementsButtonListener());
    addActor(achievementsButton);
}
 
Example #23
Source File: LR2ResultSkinLoader.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public void execute(LR2ResultSkinLoader loader, String[] str) {
	int[] values = loader.parseInt(str);
	loader.noteobj = new SkinNoteDistributionGraph(values[1], values[15], values[16], values[17], values[18]);
	loader.gauge = new Rectangle(0, 0, values[11], values[12]);
	loader.skin.add(loader.noteobj);

}
 
Example #24
Source File: LR2ResultSkinLoader.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(LR2ResultSkinLoader loader, String[] str) {
	int[] values = loader.parseInt(str);
	loader.gaugeobj = new SkinGaugeGraphObject();
	loader.gaugeobj.setLineWidth(values[6]);
	loader.gaugeobj.setDelay(values[14] - values[13]);
	loader.gauge = new Rectangle(0, 0, values[11], values[12]);
	loader.skin.add(loader.gaugeobj);
}
 
Example #25
Source File: EffectCard.java    From Klooni1010 with GNU General Public License v3.0 5 votes vote down vote up
public EffectCard(final Klooni game, final GameLayout layout, final IEffectFactory effect) {
    super(game, layout, effect.getDisplay(), Klooni.theme.background);
    background = Theme.getBlankTexture();
    this.effect = effect;

    // Let the board have room for 3 cells, so cellSize * 3
    board = new Board(new Rectangle(0, 0, cellSize * 3, cellSize * 3), 3);

    setRandomPiece();
    usedItemUpdated();
}
 
Example #26
Source File: Asteroids.java    From JavaExercises with GNU General Public License v2.0 5 votes vote down vote up
Asteroid() {
    position = new Vector2(
            MathUtils.random(Gdx.graphics.getWidth(), Gdx.graphics.getWidth() * 2),
            MathUtils.random(0, Gdx.graphics.getHeight()));
    speed = MathUtils.random(3.0f, 6.0f);
    hitBox = new Rectangle(position.x, position.y,
            imgAsteroid.getWidth(), imgAsteroid.getHeight());
}
 
Example #27
Source File: TriangleTest.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
@Test  //width =0
public void rectangleIntersectsTriangleFalseHeighZeroTest(){
    
    tri = new Triangle(new Vector2f(2, 2), new Vector2f(2, 15), new Vector2f(10, 2));
    seventh.math.Rectangle rectangle = new seventh.math.Rectangle(new Vector2f(0, 2),(int)0,(int)13);
    
    assertTrue(false == tri.rectangleIntersectsTriangle(rectangle,tri));
}
 
Example #28
Source File: PracticeConfiguration.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public void draw(Rectangle r, SkinObjectRenderer sprite, long time, MainState state) {
	float x = r.x + r.width / 8;
	float y = r.y + r.height * 7 / 8;
	sprite.draw(titlefont, String.format("START TIME : %2d:%02d.%1d", property.starttime / 60000,
			(property.starttime / 1000) % 60, (property.starttime / 100) % 10), x, y, cursorpos == 0 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, String.format("END TIME : %2d:%02d.%1d", property.endtime / 60000,
			(property.endtime / 1000) % 60, (property.endtime / 100) % 10), x, y - 22,cursorpos == 1 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, "GAUGE TYPE : " + GAUGE[property.gaugetype], x, y - 44,cursorpos == 2 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, "GAUGE CATEGORY : " + property.gaugecategory.name(), x, y - 66,cursorpos == 3 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, "GAUGE VALUE : " + property.startgauge, x, y - 88, cursorpos == 4 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, "JUDGERANK : " + property.judgerank, x, y - 110, cursorpos == 5 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, "TOTAL : " + (int)property.total, x, y - 132, cursorpos == 6 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, "FREQUENCY : " + property.freq, x, y - 154, cursorpos == 7 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, "GRAPHTYPE : " + GRAPHTYPE[property.graphtype], x, y - 176, cursorpos == 8 ? Color.YELLOW : Color.CYAN);
	sprite.draw(titlefont, "OPTION-1P : " + RANDOM[property.random], x, y - 198, cursorpos == 9 ? Color.YELLOW : Color.CYAN);
	if (model.getMode().player == 2) {
		sprite.draw(titlefont, "OPTION-2P : " + RANDOM[property.random2], x, y - 220, cursorpos == 10 ? Color.YELLOW : Color.CYAN);
		sprite.draw(titlefont, "OPTION-DP : " + DPRANDOM[property.doubleop], x, y - 242, cursorpos == 11 ? Color.YELLOW : Color.CYAN);
	}

	if (state.main.getPlayerResource().mediaLoadFinished()) {
		sprite.draw(titlefont, "PRESS 1KEY TO PLAY", x, y - 276, Color.ORANGE);
	}
	
	String[] judge = {"PGREAT :","GREAT  :","GOOD   :", "BAD    :", "POOR   :", "KPOOR  :"};
	for(int i = 0; i < 6; i++) {
		sprite.draw(titlefont, String.format("%s %d %d %d",judge[i], state.getJudgeCount(i, true) + state.getJudgeCount(i, false), state.getJudgeCount(i, true), state.getJudgeCount(i, false)), x + 250, y - (i * 22), Color.WHITE);
	}

	graph[property.graphtype].draw(sprite, time, state, new Rectangle(r.x, r.y, r.width, r.height / 4), property.starttime,
			property.endtime, property.freq / 100f);
}
 
Example #29
Source File: PongState.java    From Entitas-Java with MIT License 5 votes vote down vote up
@Override
public void initialize() {
    // Input
    Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
    Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
    BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
    context.core.createEntity()
            .addBall(false)
            .addView(new Circle(0, 0, 8))
            .addMotion(MathUtils.clamp(1, 230, 300), 300);

    context.core.createEntity()
            .addPlayer(Player.ID.PLAYER1)
            .addScore("Player 1: ", 180, 470)
            .addView(new Rectangle(-350, 0, Pong.PLAYER_WIDTH, Pong.PLAYER_HEIGHT))
            .addMotion(0, 0);

    context.core.createEntity()
            .addPlayer(Player.ID.PLAYER2)
            .addScore("Player 2: ", 480, 470)
            .addView(new Rectangle(350, 0, Pong.PLAYER_WIDTH, Pong.PLAYER_HEIGHT))
            .addMotion(0, 0);

    systems.add(new InputSystem(context.core))
            .add(new ContactSystem(context.core))
            .add(new BoundsSystem(context.core))
            .add(new MoveSystem(context.core))
            .add(new RendererSystem(context.core, engine.sr, camera, batch, font));
}
 
Example #30
Source File: SkinNote.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public void setLaneRegion(Rectangle[] region, float[] scale, int[] dstnote2, Skin skin) {
	for(int i = 0;i < lanes.length;i++) {
		lanes[i].setDestination(0,region[i].x, region[i].y, region[i].width, region[i].height, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
		lanes[i].scale =  scale[i];
		lanes[i].dstnote2 =  dstnote2[i];
	}
}