Add quickslots
This commit is contained in:
parent
ccdb63fb1e
commit
a35610d9a0
6 changed files with 48 additions and 7 deletions
Binary file not shown.
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.5 KiB |
|
@ -192,12 +192,31 @@ void tickTouchMap(){
|
|||
}
|
||||
} else {
|
||||
// touch minimap to bring up zoomed map.
|
||||
if(k_touch.py > 100 && k_touch.py < 228 && k_touch.px > 96 && k_touch.px < 228){
|
||||
if(k_touch.py > 100 && k_touch.py < 228 && k_touch.px > 10 && k_touch.px < 142){
|
||||
shouldRenderMap = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tickTouchQuickSelect() {
|
||||
if (currentMenu == 0) {
|
||||
int i = 0;
|
||||
Inventory * inv = player.p.inv;
|
||||
Item * item;
|
||||
|
||||
for (i = 0; i < 8; ++i) {
|
||||
if((inv->lastSlot) > i) {
|
||||
int xip = i % 4;
|
||||
int yip = i / 4;
|
||||
|
||||
if(k_touch.py > 72*2+yip*21*2 && k_touch.py < 72*2+yip*21*2+21*2 && k_touch.px > 76*2+xip*21*2 && k_touch.px < 76*2+xip*21*2+21*2) {
|
||||
playerSetActiveItem(&inv->items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hurtEntity(Entity* e, int damage, int dir, u32 hurtColor){
|
||||
if (e->hurtTime > 0) return;
|
||||
int xd = player.x - e->x;
|
||||
|
@ -1461,6 +1480,12 @@ bool isSwimming(){
|
|||
return getTile(player.x>>4,player.y>>4)==TILE_WATER;
|
||||
}
|
||||
|
||||
void playerSetActiveItem(Item * item) {
|
||||
player.p.activeItem = item;
|
||||
if(player.p.activeItem->id > 27 && player.p.activeItem->id < 34) player.p.isCarrying = true;
|
||||
else player.p.isCarrying = false;
|
||||
}
|
||||
|
||||
void reloadColors() {
|
||||
dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0));
|
||||
dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1));
|
||||
|
|
|
@ -105,6 +105,7 @@ s8 itemTileInteract(int tile, Item* item, int x, int y, int px, int py, int dir)
|
|||
void tickEntity(Entity* e);
|
||||
|
||||
void tickTouchMap();
|
||||
void tickTouchQuickSelect();
|
||||
|
||||
void trySpawn(int count, int level);
|
||||
|
||||
|
@ -128,5 +129,6 @@ bool playerUseEnergy(int amount);
|
|||
void playerHurtTile(int tile, int xt, int yt, int damage, int dir);
|
||||
bool playerIntersectsEntity(Entity* e);
|
||||
void playerEntityInteract(Entity* e);
|
||||
void playerSetActiveItem(Item * item);
|
||||
|
||||
void reloadColors();
|
|
@ -409,9 +409,7 @@ void tickMenu(int menu){
|
|||
median = player.p.inv->items[curInvSel]; // create copy of item.
|
||||
removeItemFromInventory(curInvSel, player.p.inv); // remove original
|
||||
pushItemToInventoryFront(median, player.p.inv); // add copy to front
|
||||
player.p.activeItem = &player.p.inv->items[0]; // active item = copy.
|
||||
if(player.p.activeItem->id > 27 && player.p.activeItem->id < 34) player.p.isCarrying = true;
|
||||
else player.p.isCarrying = false;
|
||||
playerSetActiveItem(&player.p.inv->items[0]); // active item = copy.
|
||||
}
|
||||
currentMenu = MENU_NONE;
|
||||
}
|
||||
|
|
|
@ -626,15 +626,30 @@ void renderGui() {
|
|||
else
|
||||
render(i * 8 + 6, 14, 191, 152, 0);
|
||||
}
|
||||
sf2d_draw_texture(minimap[currentLevel], 96, 102);
|
||||
sf2d_draw_texture(minimap[currentLevel], 10, 102);
|
||||
renderItemWithTextCentered(player.p.activeItem, 320, 66);
|
||||
itoa(player.p.score, scoreT, 10); // integer to base10 string
|
||||
drawText("Score:",214,12);
|
||||
drawText(scoreT,(140-(strlen(scoreT)*12))/2 + 180,29);
|
||||
if(currentLevel == 0){
|
||||
renderc(44 + (awX/32), 47 + (awY/32), 88, 216, 8, 8, 0); // Mini-AWizard head.
|
||||
renderc(1 + (awX/32), 47 + (awY/32), 88, 216, 8, 8, 0); // Mini-AWizard head.
|
||||
}
|
||||
renderc(1 + (player.x/32), 47 + (player.y/32), 88, 208, 8, 8, 0); // Mini-Player head.
|
||||
|
||||
//quick select
|
||||
drawText("Quickselect:",164,118);
|
||||
|
||||
Inventory * inv = player.p.inv;
|
||||
Item * item;
|
||||
for (i = 0; i < 8; ++i) {
|
||||
if((inv->lastSlot) > i) {
|
||||
int xip = i % 4;
|
||||
int yip = i / 4;
|
||||
|
||||
item = &inv->items[i];
|
||||
renderItemIcon(item->id, item->countLevel, 81+xip*21, 77+yip*21);
|
||||
}
|
||||
}
|
||||
renderc(44 + (player.x/32), 47 + (player.y/32), 88, 208, 8, 8, 0); // Mini-Player head.
|
||||
}
|
||||
|
||||
void renderPlayer() {
|
||||
|
|
|
@ -110,6 +110,7 @@ void tick() {
|
|||
}
|
||||
|
||||
tickTouchMap();
|
||||
tickTouchQuickSelect();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 324; ++i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue