-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inventory with custom items and item count
- Loading branch information
arbeiter
committed
Aug 17, 2022
1 parent
eb3f15a
commit f8d4e07
Showing
7 changed files
with
81 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
#pragma once | ||
#include "SDL2/SDL.h" | ||
#include "SDL2/SDL_image.h" | ||
#include "SDL2/SDL_ttf.h" | ||
#include <iostream> | ||
#include <ostream> | ||
#include "textureManager.h" | ||
#include <vector> | ||
using namespace std; | ||
|
||
struct ItemStats { | ||
int itemCount; | ||
string itemName; | ||
}; | ||
|
||
class Inventory { | ||
public: | ||
Inventory(SDL_Renderer *renderer) | ||
: mRenderer{renderer}, width(3440), height(1440), num_items(60) | ||
Inventory() = default; | ||
Inventory(SDL_Renderer *renderer, TTF_Font *mFont) | ||
: mRenderer{renderer}, font(mFont), width(3440), height(1440) | ||
{ | ||
texManager = new TextureManager(renderer); | ||
bitmapTex = texManager->LoadTexture("./res/collectable_jam.png"); | ||
|
||
bitmapTex = texManager->LoadTexture("./res/final_collectables_transparent.png"); | ||
loadItemStats(); | ||
int wi, hi; | ||
SDL_QueryTexture(bitmapTex, NULL, NULL, &wi, &hi); | ||
tex_w = wi; | ||
tex_h = hi; | ||
} | ||
|
||
void draw(); | ||
void refreshDisplay(); | ||
void loadItemStats(); | ||
void drawItem(SDL_Rect &srcrect, int width, int item_idx); | ||
void drawCount(SDL_Rect &srcrect, int count); | ||
|
||
private: | ||
void drawChrome(); | ||
void drawItems(int w, int h); | ||
void drawItem(); | ||
SDL_Renderer *mRenderer; | ||
int width; | ||
int height; | ||
int num_items; | ||
TextureManager *texManager; | ||
SDL_Texture *bitmapTex; | ||
int tex_w; | ||
int tex_h; | ||
}; | ||
|
||
class InventoryItem { | ||
public: | ||
InventoryItem(SDL_Renderer *renderer) | ||
: mRenderer{renderer} {} | ||
private: | ||
void drawChrome(); | ||
void drawInterior(); | ||
int padding; | ||
string item_texture; | ||
string item_count; | ||
string border_texture; | ||
SDL_Renderer *mRenderer; | ||
std::vector<ItemStats> itemStats; | ||
TTF_Font* font; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.