Skip to content

Inventory. GH-18#175

Closed
satoshinm wants to merge 13 commits intomasterfrom
inventory
Closed

Inventory. GH-18#175
satoshinm wants to merge 13 commits intomasterfrom
inventory

Conversation

@satoshinm
Copy link
Copy Markdown
Owner

#18

@satoshinm
Copy link
Copy Markdown
Owner Author

CraftNG #25 (comment) has a good start of an inventory system:

screen shot 2017-06-03 at 7 54 20 pm

specifically these commits at least: twetzel59/CraftNG@a604e73 twetzel59/CraftNG@3b44099 and twetzel59/CraftNG@7e7c624. Cherry-picked them and got the beginning of an inventory:

screenshot-netcraft-2017-06-04t02 55 18z

The next/previous E/R keys and 0-9 cycle the available blocks, so the bottommost block is active for placement, the others above serve as previews.

@satoshinm
Copy link
Copy Markdown
Owner Author

The item counts are rendered rightmost but the items, from render_item to set_matrix_item, shift in the wrong place when the window is resized, if wider then not far enough left (and vice versa if narrower then too far left):

screen shot 2017-06-03 at 8 22 44 pm

@satoshinm
Copy link
Copy Markdown
Owner Author

satoshinm commented Jun 4, 2017

I think the offset is caused discrepancy is caused by using direct manipulation of the matrix instead of stacked matrix transformations, e.g. in set_matrix_item:

-    mat_translate(b, -xoffset, -yoffset, 0);
+    mat_translate(b, -xoffset + 1.75f, -yoffset, 0);

and render_item:

        if (!i) {
            set_matrix_item(matrix, g->width, g->height, g->scale);
            matrix[12] += 0.08f;
            matrix[13] += 0.1f;
        }

        matrix[13] += 0.25f;

matrix[12] += 0.08f; is meant to offset the non-active item slightly to the right, and matrix[13] += 0.1f; to move the active item down an offset. But +='ing matrix[12] doesn't take into account the window width, or rather, it mistakingly takes it into account when it shouldn't. Update: actually it is the -xoffset + 1.75f, it should instead be factored into float xoffset = 1 - size / width * 2;?

@satoshinm
Copy link
Copy Markdown
Owner Author

Having the sidebar flush wouldn't be too bad, if the text overlaid it, but even though it is drawn later it is partly clobbered:

screen shot 2017-06-03 at 8 51 39 pm

@satoshinm
Copy link
Copy Markdown
Owner Author

satoshinm commented Jun 4, 2017

Native ok no longer item clobbering text:

screen shot 2017-06-03 at 8 54 38 pm

but web build, partially visible only:

screenshot-netcraft-2017-06-04t03_58_56 460z

@satoshinm
Copy link
Copy Markdown
Owner Author

satoshinm commented Jun 4, 2017

    mat_translate(b, xoffset, -yoffset, 0.6f);

screenshot-netcraft-2017-06-04t04_01_29 058z

At 1.0f, text is fully visible but then the item is clipped (since zfar=-1, znear=1 in mat_ortho call in set_matrix_2d)... maybe there is a better way:

screenshot-netcraft-2017-06-04t04_01_48 399z

@satoshinm
Copy link
Copy Markdown
Owner Author

satoshinm commented Jun 4, 2017

Better:

screenshot-netcraft-2017-06-04t04_07_29 644z

screen shot 2017-06-03 at 9 10 08 pm

@satoshinm
Copy link
Copy Markdown
Owner Author

Reducing scope of this pull request: #177

@satoshinm satoshinm closed this Jun 4, 2017
@satoshinm satoshinm deleted the inventory branch June 4, 2017 05:24
satoshinm added a commit that referenced this pull request Jun 4, 2017
)

* Cherry-pick from "HUD expansion": twetzel59/CraftNG@a604e73

* Decrease item rendering size to 32

* Rename _item to item_hotbar to clarify its purpose

* Revert "Rename _item to item_hotbar to clarify its purpose"

This reverts commit 59f7056.

* Cherry-pick item counts from "Inventory with HUD."

twetzel59/CraftNG@3b44099
twetzel59/CraftNG@7e7c624

* Refactor render_item_count tx/ty

* Move the hotbar flush up against the right edge, fix width shifting

#175 (comment)

* Translate Z of item hotbar slightly to fix text overlap

* Increase clipping plane and z translate to not overlap on web

* Fix unnecessary whitespace after item count text

* Zero-initialize fixed size (not variable) buf in render_item_count

* Increase hotbar size to 9 items

* Remove count labels from hotbar items for now
@satoshinm satoshinm changed the title [WIP] Inventory. GH-18 Inventory. GH-18 Jun 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants