Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement brick picking logic #21

Closed
rozniak opened this issue Jan 11, 2021 · 10 comments
Closed

Implement brick picking logic #21

rozniak opened this issue Jan 11, 2021 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@rozniak
Copy link
Owner

rozniak commented Jan 11, 2021

Next step is to implement the brick picking and placement logic. There are some rules on being able to pick bricks, along with which bricks are taken alongside the brick selected. Will need to play the game to do some testing to see what the rules might be.

I am also marking this as wait-submodule because picked bricks need to be rendered semi-transparent which is not yet supported by rzxe.

@rozniak rozniak added enhancement New feature or request wait-submodule This is dependent on a related submodule issue labels Jan 11, 2021
@rozniak rozniak self-assigned this Jan 11, 2021
@rozniak
Copy link
Owner Author

rozniak commented Jan 11, 2021

Waiting on this particular issue: rozniak/rzxe#21

@rozniak rozniak removed the wait-submodule This is dependent on a related submodule issue label Jan 14, 2021
@rozniak
Copy link
Owner Author

rozniak commented Jan 14, 2021

Feature sorted in rzxe, this issue can now go ahead.

@rozniak rozniak added the help wanted Extra attention is needed label Jan 16, 2021
@rozniak
Copy link
Owner Author

rozniak commented Jan 16, 2021

@Aaronlcj I know you had brick picking in your fork... have you a gist or something on what the logic is? I've tried drafting some ideas about how it works, I'm just struggling to think of a good way to do it. The original game seems to know which direction you can pop brick off (indicated by mouse cursor).

I was thinking of building 'trees' of connected bricks but it seems quite complex, I dunno if perhaps I'm overthinking it...

@rozniak rozniak added the blocked Another issue needs fixing before this one can be fixed label Jan 18, 2021
@rozniak
Copy link
Owner Author

rozniak commented Jan 18, 2021

The plan is to develop this by creating a set of tests with expected outcomes and amending the code until all tests are met. I have constructed some cases which need to be tested to make sure the edge cases are covered.

Here are some cases:

  • SImple bridge - top brick is a junction
    Junkbot screenshot showing a bridge between two grey bricks made out of 3 connected bricks
  • Simple stairs, first brick connected upwards and thus blocked from upwards connection
    Junkbot screenshot showing simple left-upwards stairs with first brick connected to underside of grey brick
  • Connected both on top of and underneath grey bricks
    Junkbot screenshot showing connections above and below grey bricks
  • Looped connections with/without gap
    Junkbot screenshot showing looped connections from single bottom brick
  • Ledge connected at a single point with independent brick to the right - Junkbot blocking entire ledge and stem
    Junkbot screenshot showing ledge blocked by Junkbot with the single brick to the right being selectable

My thought is to use a node based system to figure out which paths can be selected. The loop case is to test cyclic references.

@rozniak rozniak removed the blocked Another issue needs fixing before this one can be fixed label Jan 19, 2021
@rozniak
Copy link
Owner Author

rozniak commented Jan 22, 2021

Here's another case:
image

@rozniak
Copy link
Owner Author

rozniak commented Jan 24, 2021

I have put together some logic just now for the brick picking - just writing up some unit tests to check how this performs against the above cases.

@rozniak
Copy link
Owner Author

rozniak commented Jan 25, 2021

First little unit test for checking the direction bricks can be disconnected in the first bridge case is now passing. On the way to writing tests for the other cases and getting this feature finished. 😁

@rozniak rozniak removed the help wanted Extra attention is needed label Jan 31, 2021
@rozniak
Copy link
Owner Author

rozniak commented Feb 1, 2021

All tests are now passing for pickup!

The remainder:

  • Need to implement a 'hand' - detach bricks from scene
  • Write a method + tests for checking placement of the picked up bricks
  • Once all done, implement into game itself - wire up input and rendering

@rozniak
Copy link
Owner Author

rozniak commented Feb 13, 2021

All brick picking logic is now sorted - it's now a matter of wiring up in game.

It's partially working, but needs tuning with the mouse - here's a little screenshot of moved bricks on the demo scene:
image

Things to fix:

  • Need to cast screen/window coordinates into viewport space (to handle scaled window)
  • Clip mouse input to scene within the visible section of the scene (do not send input updates if outside the visible region - but do update via deltaTime)
  • Improve hit registration - currently based on exact cells which isn't helpful in isometric view, should select a range of cells that cover the size of a brick or something
  • Click and drag to detach brings that can go either way isn't working yet

@rozniak
Copy link
Owner Author

rozniak commented Feb 14, 2021

Isometric view code still needs some work - there is a method MouseHitTest() that does a nice hit test based in the isometric view. I think this should be used in DetachAt and PlaceAt as the actual method used to pick up bricks instead of taking an exact grid cell.

Don't know whether to keep the grid cell option as well... or whether to just do this viewport based thing only. Will have a think about it.

EDIT:
This is needed by the way because it's not really feasible to work MouseHitTest() in alongside the current implementation based on grid cells without being bodge-y (since the x-offset thing is partially akin to mouse input as it is).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant