From a615f52b8465adf0e180fa64dec6b297bd6bc234 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Sat, 4 Feb 2017 17:12:16 -0500 Subject: [PATCH] Made the shop more horizontally compact. This has the effect of making it work with screen widths as low as 640 pixels. --- gfx/buyIcon.png | Bin 331 -> 349 bytes gfx/sellIcon.png | Bin 344 -> 391 bytes src/shop.cpp | 127 ++++++++++++++++++++++++----------------------- 3 files changed, 66 insertions(+), 61 deletions(-) diff --git a/gfx/buyIcon.png b/gfx/buyIcon.png index 64c854929e7d67ca49defaffd89b46dbf21d6840..0a2ff2e3c8f2a837c202e1057a0ad951cfa32802 100644 GIT binary patch delta 333 zcmV-T0kZzf0^I_T8Gi!+006{fkFEd!0Gv=vR7C&)836$S2L}fW3kwYm4HXp?7#J8J zARsL*EiNuDGBPqdJ3Bl)JV8N0LPA1LPEJrzP*G7)S65eASy^CUU}9ooWMpJ(YioIV zd5DOJjg5_!m6e#7n3|fJpP!$kq@=2(-e=yO9x#lOb;~ fn|jbtYvwuvV(b}fW5yT)00000NkvXXu0mjf&3T>^ literal 331 zcmeAS@N?(olHy`uVBq!ia0vp^azM<_0VEi%T~u%YQcOwS?k)`f+xyS#2l6-zJR*x3 z7`TN&n2}-D90{OcucwP+h{WaOh*tg*gEdJ9m^&u_`~Uy{;;U{IOC)9f%O6+I{anx9 z!SwKSx}?Oqd5)%k{@29KD0ynn`TD=+ie1Y8&o_8#|M8ynf1-5gtndGe6^@?Z3o0u4 zK7D0I8T-HZvjso*2QztC{r+EXYtnBUvFNlw!MnRU6SlmV|G1*5_2T<_3%Qs7<*Pe+ zukh_*V3=>-9L8HI;sbP0l+XkKK+SeK diff --git a/gfx/sellIcon.png b/gfx/sellIcon.png index 3350596eb4e1d65121bd774f7d88e56640b7f71c..91350ec8f8887df420f7bff06d5fde7b4b2a8bba 100644 GIT binary patch delta 375 zcmV--0f_$C0*3>T8Gi!+006{fkFEd!0Jl&~R7C&)83qOh3JMAg3=9qq4j3318X6iK z8yg%P93LMaB_$;00EMZ2g)`k&j9`0qVC^+ea zfdsc$GL9E#`u^e-o@9b0_EBLk{PGW3_={J#Fh8z4G5D*~>#JjGbRoXN>r)%1JOK`z V9n~2^fEoY*002ovPDHLkV1h_wvCIGf literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^azM<_0VEi%T~u%YQcOwS?k)`f+xyS#2l6-zJR*x3 z7`TN&n2}-D90{P{EKe855Q)pl5v}|s25XWIFndh>$IrsSrJ{SW`rTnha}`z~+xBxk z%lxxtb1w1!w{H4j!}|Q4&y<5x&i(wEzgv;n`C&c(^8c3&mP#(Ew*PlFWd}piIdPp! zJUqYtzc-%qe?6Dj|6lWY{Ti2)-}vPEZ~plSU+d?Ic+_03=eJ;;^v&YW%S$|!Z0qLC zwRcd9%Kyt}B<>R^wL-Rnk)gGtql0BqGsuUkC9V-ADTyViR>?)FK#IZ0z|c_Fz(Uu^ yJjBq{%GAKh#8TV9$jZQgeWvkV6b-rgDVb@NxHXg=>1G6KVDNPHb6Mw<&;$Uk;B-L% diff --git a/src/shop.cpp b/src/shop.cpp index ccdb3ee..91c31c7 100644 --- a/src/shop.cpp +++ b/src/shop.cpp @@ -42,6 +42,9 @@ typedef struct ShopItem_ { } ShopItem; +static const int shop_w = 600; +static const int shop_x = SCREEN_WIDTH / 2 - shop_w / 2; + static ShopItem shopItems[SHOP_MAX]; static int shopSelectedItem; @@ -56,31 +59,31 @@ static void drawSecondaryWeaponSurface() switch (player.weaponType[1]) { case W_NONE: - strcpy(description, "Type : None"); + strcpy(description, "None"); break; case W_ROCKETS: - strcpy(description, "Type : Rockets"); + strcpy(description, "Rockets"); break; case W_DOUBLE_ROCKETS: - strcpy(description, "Type : Dbl Rockets"); + strcpy(description, "Dbl Rockets"); break; case W_MICRO_ROCKETS: - strcpy(description, "Type : Micro Rockets"); + strcpy(description, "Micro Rockets"); break; case W_LASER: - strcpy(description, "Type : Laser"); + strcpy(description, "Laser"); break; case W_CHARGER: - strcpy(description, "Type : Charger"); + strcpy(description, "Charger"); break; case W_HOMING_MISSILE: - strcpy(description, "Type : Homing Missile"); + strcpy(description, "Homing Missile"); break; case W_DOUBLE_HOMING_MISSILES: - strcpy(description, "Type : Dbl Homing Missiles"); + strcpy(description, "Dbl Homing Missiles"); break; case W_MICRO_HOMING_MISSILES: - strcpy(description, "Type : Mcr Homing Missiles"); + strcpy(description, "Mcr Homing Missiles"); break; } gfx_renderString(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[2]); @@ -166,16 +169,16 @@ static void drawShop() } } - gfx_shopSprites[SHOP_S_PRIMARY] = gfx_createSurface(246, 91); - gfx_shopSprites[SHOP_S_POWERUP] = gfx_createSurface(246, 91); - gfx_shopSprites[SHOP_S_SECONDARY] = gfx_createSurface(246, 91); + gfx_shopSprites[SHOP_S_PRIMARY] = gfx_createSurface(190, 91); + gfx_shopSprites[SHOP_S_POWERUP] = gfx_createSurface(190, 91); + gfx_shopSprites[SHOP_S_SECONDARY] = gfx_createSurface(190, 91); - gfx_drawRect(gfx_shopSprites[SHOP_S_PRIMARY], 0, 0, 245, 90, 0x00, 0x00, 0x55); - gfx_drawRect(gfx_shopSprites[SHOP_S_PRIMARY], 0, 0, 245, 20, 0x00, 0x00, 0x99); - gfx_drawRect(gfx_shopSprites[SHOP_S_POWERUP], 0, 0, 245, 90, 0x00, 0x00, 0x55); - gfx_drawRect(gfx_shopSprites[SHOP_S_POWERUP], 0, 0, 245, 20, 0x00, 0x00, 0x99); - gfx_drawRect(gfx_shopSprites[SHOP_S_SECONDARY], 0, 0, 245, 90, 0x00, 0x00, 0x55); - gfx_drawRect(gfx_shopSprites[SHOP_S_SECONDARY], 0, 0, 245, 20, 0x00, 0x00, 0x99); + gfx_drawRect(gfx_shopSprites[SHOP_S_PRIMARY], 0, 0, 189, 90, 0x00, 0x00, 0x55); + gfx_drawRect(gfx_shopSprites[SHOP_S_PRIMARY], 0, 0, 189, 20, 0x00, 0x00, 0x99); + gfx_drawRect(gfx_shopSprites[SHOP_S_POWERUP], 0, 0, 189, 90, 0x00, 0x00, 0x55); + gfx_drawRect(gfx_shopSprites[SHOP_S_POWERUP], 0, 0, 189, 20, 0x00, 0x00, 0x99); + gfx_drawRect(gfx_shopSprites[SHOP_S_SECONDARY], 0, 0, 189, 90, 0x00, 0x00, 0x55); + gfx_drawRect(gfx_shopSprites[SHOP_S_SECONDARY], 0, 0, 189, 20, 0x00, 0x00, 0x99); gfx_shopSprites[SHOP_S_SHIP_INFO] = gfx_createAlphaRect(601, 101, 0x00, 0x00, 0x00); gfx_drawRect(gfx_shopSprites[SHOP_S_SHIP_INFO], 0, 0, 600, 100, 0x00, 0x00, 0x33); @@ -193,48 +196,48 @@ static void drawShop() case SHOP_PLASMA_MAX_DAMAGE: case SHOP_PLASMA_MAX_RATE: case SHOP_PLASMA_MAX_AMMO: - gfx_drawRect(gfx_shopSprites[SHOP_S_POWERUP], 0, 0, 245, 90, 0x55, 0x00, 0x00); - gfx_drawRect(gfx_shopSprites[SHOP_S_POWERUP], 0, 0, 245, 20, 0x99, 0x00, 0x00); + gfx_drawRect(gfx_shopSprites[SHOP_S_POWERUP], 0, 0, 189, 90, 0x55, 0x00, 0x00); + gfx_drawRect(gfx_shopSprites[SHOP_S_POWERUP], 0, 0, 189, 20, 0x99, 0x00, 0x00); break; case SHOP_PLASMA_MIN_OUTPUT: case SHOP_PLASMA_MIN_DAMAGE: case SHOP_PLASMA_MIN_RATE: - gfx_drawRect(gfx_shopSprites[SHOP_S_PRIMARY], 0, 0, 245, 90, 0x55, 0x00, 0x00); - gfx_drawRect(gfx_shopSprites[SHOP_S_PRIMARY], 0, 0, 245, 20, 0x99, 0x00, 0x00); + gfx_drawRect(gfx_shopSprites[SHOP_S_PRIMARY], 0, 0, 189, 90, 0x55, 0x00, 0x00); + gfx_drawRect(gfx_shopSprites[SHOP_S_PRIMARY], 0, 0, 189, 20, 0x99, 0x00, 0x00); break; case SHOP_PLASMA_AMMO: case SHOP_ROCKET_AMMO: gfx_drawRect(gfx_shopSprites[SHOP_S_SHIP_INFO], 0, 0, 600, 100, 0x33, 0x00, 0x00); break; default: - gfx_drawRect(gfx_shopSprites[SHOP_S_SECONDARY], 0, 0, 245, 90, 0x55, 0x00, 0x00); - gfx_drawRect(gfx_shopSprites[SHOP_S_SECONDARY], 0, 0, 245, 20, 0x99, 0x00, 0x00); + gfx_drawRect(gfx_shopSprites[SHOP_S_SECONDARY], 0, 0, 189, 90, 0x55, 0x00, 0x00); + gfx_drawRect(gfx_shopSprites[SHOP_S_SECONDARY], 0, 0, 189, 20, 0x99, 0x00, 0x00); break; } strcpy(description, ""); gfx_renderString("Primary Weapon", 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); - sprintf(description, "Plasma Cannons : %d", game.minPlasmaOutput); + sprintf(description, "Cannons : %d", game.minPlasmaOutput); gfx_renderString(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); - sprintf(description, "Plasma Power : Stage %d", + sprintf(description, "Power : Stage %d", game.minPlasmaDamage); gfx_renderString(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); - sprintf(description, "Cooler : Stage %d", + sprintf(description, "Cooler : Stage %d", game.minPlasmaRate); gfx_renderString(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); gfx_renderString("Powerup Weapon", 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); - sprintf(description, "Plasma Output : Stage %d", + sprintf(description, "Output : Stage %d", game.maxPlasmaOutput); gfx_renderString(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); - sprintf(description, "Plasma Condensor : Stage %d", + sprintf(description, "Condensor : Stage %d", game.maxPlasmaDamage); gfx_renderString(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); - sprintf(description, "Liquid Nitrogen : Stage %d", + sprintf(description, "L.Nitrogen: Stage %d", game.maxPlasmaRate); gfx_renderString(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); - sprintf(description, "Plasma Capacity : %d", game.maxPlasmaAmmo); + sprintf(description, "Capacity : %d", game.maxPlasmaAmmo); gfx_renderString(description, 10, 67, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); drawSecondaryWeaponSurface(); @@ -259,7 +262,7 @@ static void drawShop() for (int i = 0 ; i < icons ; i++) { - gfx_blit(gfx_sprites[shopItems[i].image], shopItems[i].x - 90, + gfx_blit(gfx_sprites[shopItems[i].image], shopItems[i].x + 10 - shop_x, shopItems[i].y - 178, gfx_shopSprites[SHOP_S_CATALOG]); } @@ -275,7 +278,7 @@ static void drawShop() gfx_shopSprites[SHOP_S_ITEM_INFO] = gfx_createSurface(601, 56); gfx_drawRect(gfx_shopSprites[SHOP_S_ITEM_INFO], 0, 0, 600, 35, 0x00, 0x99, 0x00); gfx_drawRect(gfx_shopSprites[SHOP_S_ITEM_INFO], 0, 20, 600, 35, 0x00, 0x33, 0x00); - gfx_renderString("Information", 5, 4, FONT_WHITE, 0, gfx_shopSprites[5]); + gfx_renderString("Information", 5, 4, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); switch (shopSelectedItem) { @@ -453,55 +456,55 @@ void shop_init() "Fires several small homing missiles (max %i missiles)", maxMicroHoming); shopItems[SHOP_MICRO_HOMING_MISSILES].image = 25; - shopItems[SHOP_PLASMA_MAX_OUTPUT].x = 100; + shopItems[SHOP_PLASMA_MAX_OUTPUT].x = shop_x; shopItems[SHOP_PLASMA_MAX_OUTPUT].y = 200; - shopItems[SHOP_PLASMA_MAX_DAMAGE].x = 150; + shopItems[SHOP_PLASMA_MAX_DAMAGE].x = shop_x + 50; shopItems[SHOP_PLASMA_MAX_DAMAGE].y = 200; - shopItems[SHOP_PLASMA_MAX_RATE].x = 200; + shopItems[SHOP_PLASMA_MAX_RATE].x = shop_x + 100; shopItems[SHOP_PLASMA_MAX_RATE].y = 200; - shopItems[SHOP_PLASMA_MIN_OUTPUT].x = 100; + shopItems[SHOP_PLASMA_MIN_OUTPUT].x = shop_x; shopItems[SHOP_PLASMA_MIN_OUTPUT].y = 260; - shopItems[SHOP_PLASMA_MIN_DAMAGE].x = 150; + shopItems[SHOP_PLASMA_MIN_DAMAGE].x = shop_x + 50; shopItems[SHOP_PLASMA_MIN_DAMAGE].y = 260; - shopItems[SHOP_PLASMA_MIN_RATE].x = 200; + shopItems[SHOP_PLASMA_MIN_RATE].x = shop_x + 100; shopItems[SHOP_PLASMA_MIN_RATE].y = 260; - shopItems[SHOP_PLASMA_AMMO].x = 350; + shopItems[SHOP_PLASMA_AMMO].x = shop_x + 250; shopItems[SHOP_PLASMA_AMMO].y = 200; - shopItems[SHOP_ROCKET_AMMO].x = 400; + shopItems[SHOP_ROCKET_AMMO].x = shop_x + 300; shopItems[SHOP_ROCKET_AMMO].y = 200; - shopItems[SHOP_PLASMA_MAX_AMMO].x = 450; + shopItems[SHOP_PLASMA_MAX_AMMO].x = shop_x + 350; shopItems[SHOP_PLASMA_MAX_AMMO].y = 200; - shopItems[SHOP_ROCKET_MAX_AMMO].x = 500; + shopItems[SHOP_ROCKET_MAX_AMMO].x = shop_x + 400; shopItems[SHOP_ROCKET_MAX_AMMO].y = 200; - shopItems[SHOP_DOUBLE_ROCKETS].x = 350; + shopItems[SHOP_DOUBLE_ROCKETS].x = shop_x + 250; shopItems[SHOP_DOUBLE_ROCKETS].y = 260; - shopItems[SHOP_MICRO_ROCKETS].x = 400; + shopItems[SHOP_MICRO_ROCKETS].x = shop_x + 300; shopItems[SHOP_MICRO_ROCKETS].y = 260; - shopItems[SHOP_LASER].x = 450; + shopItems[SHOP_LASER].x = shop_x + 350; shopItems[SHOP_LASER].y = 260; - shopItems[SHOP_HOMING_MISSILE].x = 500; + shopItems[SHOP_HOMING_MISSILE].x = shop_x + 400; shopItems[SHOP_HOMING_MISSILE].y = 260; - shopItems[SHOP_CHARGER].x = 550; + shopItems[SHOP_CHARGER].x = shop_x + 450; shopItems[SHOP_CHARGER].y = 260; - shopItems[SHOP_DOUBLE_HOMING_MISSILES].x = 600; + shopItems[SHOP_DOUBLE_HOMING_MISSILES].x = shop_x + 500; shopItems[SHOP_DOUBLE_HOMING_MISSILES].y = 260; - shopItems[SHOP_MICRO_HOMING_MISSILES].x = 650; + shopItems[SHOP_MICRO_HOMING_MISSILES].x = shop_x + 550; shopItems[SHOP_MICRO_HOMING_MISSILES].y = 260; shopSelectedItem = -1; @@ -1041,19 +1044,21 @@ static void sell(int i) void shop_show() { - int icons = SHOP_MAX; + int icons = SHOP_MAX; + int sell_x = shop_x + shop_w - gfx_sprites[SP_SELL]->w - 2; + int buy_x = sell_x - gfx_sprites[SP_BUY]->w - 5; - screen_blit(gfx_shopSprites[SHOP_S_PRIMARY], 20, 395); - screen_blit(gfx_shopSprites[SHOP_S_POWERUP], 275, 395); - screen_blit(gfx_shopSprites[SHOP_S_SECONDARY], 530, 395); - screen_blit(gfx_shopSprites[SHOP_S_CATALOG], 100, 180); - screen_blit(gfx_shopSprites[SHOP_S_SHIP_INFO], 100, 50); - screen_blit(gfx_shopSprites[SHOP_S_ITEM_INFO], 100, 320); + screen_blit(gfx_shopSprites[SHOP_S_PRIMARY], shop_x, 395); + screen_blit(gfx_shopSprites[SHOP_S_POWERUP], shop_x + 203, 395); + screen_blit(gfx_shopSprites[SHOP_S_SECONDARY], shop_x + 406, 395); + screen_blit(gfx_shopSprites[SHOP_S_CATALOG], shop_x, 180); + screen_blit(gfx_shopSprites[SHOP_S_SHIP_INFO], shop_x, 50); + screen_blit(gfx_shopSprites[SHOP_S_ITEM_INFO], shop_x, 320); if (shopSelectedItem > -1) { - screen_blit(gfx_sprites[SP_BUY], 60, 350); - screen_blit(gfx_sprites[SP_SELL], 710, 350); + screen_blit(gfx_sprites[SP_BUY], buy_x, 323); + screen_blit(gfx_sprites[SP_SELL], sell_x, 323); } screen_blit(gfx_sprites[SP_FIREFLY], 380, 95); @@ -1080,14 +1085,14 @@ void shop_show() if (shopSelectedItem > -1) { - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 60, 350, 24, 16)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, buy_x, 323, 24, 16)) { buy(shopSelectedItem); engine.keyState[KEY_FIRE] = 0; drawShop(); } - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 700, 350, 24, 16)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, sell_x, 323, 24, 16)) { sell(shopSelectedItem); engine.keyState[KEY_FIRE] = 0;