The title may not make sense, nor may the question - I'll try nevertheless.
I'm attempting to make a game similar to The Powder Toy.
Essentially, this is a physics simulation game, where the users create various structures using the provided materials.
As of now, I've created the grid, and given the user the ability to draw with grey cells (or, Stone).
Of course, this may seem like what I would want - however, all the cells are stored in a two dimensional array. When the user clicks on the screen, the program round the x and y of the cursor to the grid, and adds to the array like that.
What I want to happen is for the cell to change in the place of the cursor, instead of rounding it to the nearest cell.
I've attempted to explain it in this image:
In this image, the green large dots are the mouse position, and the place at which the arrows are pointing are examples of where the cell could be.
Green represents what I want to happen but in most cases doesn't, and red is what does happen, but what I don't want.
Here's part of my function to set the cells:
public void handleInput () {
if (Gdx.input.isButtonPressed(Buttons.LEFT)) {
mouse_x = Gdx.input.getX();
mouse_y = Gdx.input.getY();
rou_mouse = new Vector2(round2px(mouse_x), round2px(mouse_y));
set_px (rou_mouse, new Element_stone());
}
Where set_px
sets a certain item, this is used to draw to the screen.
I hope this is enough information, but if you would need anymore to solve it, I'd be happy to update the post to include more code.
Oh, and I should probable mention I'm using LibGDX.
round2px
? Is it a LibGDX function or your own? If it's your own, could you post it? \$\endgroup\$