Minor code cleanup.
This commit is contained in:
-37
@@ -22,31 +22,16 @@ typedef struct {
|
||||
int right;
|
||||
} App;
|
||||
|
||||
typedef struct {
|
||||
int x;
|
||||
int y;
|
||||
SDL_Texture *texture;
|
||||
} Entity;
|
||||
|
||||
App app;
|
||||
|
||||
Entity player;
|
||||
|
||||
void handleInput(void);
|
||||
void cleanup(void);
|
||||
void prepareScene(void);
|
||||
void presentScene(void);
|
||||
SDL_Texture *loadTexture(char *);
|
||||
void blit(SDL_Texture *, int, int);
|
||||
int getIndex(int, int, int);
|
||||
|
||||
int main(int argc, char* args[]) {
|
||||
memset(&app, 0, sizeof(app));
|
||||
memset(&player, 0, sizeof(player));
|
||||
|
||||
player.x = 100;
|
||||
player.y = 100;
|
||||
player.texture = loadTexture("text.jpg");
|
||||
|
||||
IMG_Init(IMG_INIT_JPG);
|
||||
|
||||
@@ -86,25 +71,6 @@ int main(int argc, char* args[]) {
|
||||
}
|
||||
}
|
||||
|
||||
void blit(SDL_Texture *texture, int x, int y)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
|
||||
dest.x = x;
|
||||
dest.y = y;
|
||||
SDL_QueryTexture(texture, NULL, NULL, &dest.w, &dest.h);
|
||||
|
||||
SDL_RenderCopy(app.renderer, texture, NULL, &dest);
|
||||
}
|
||||
|
||||
SDL_Texture* loadTexture(char *filePath) {
|
||||
SDL_Texture *texture;
|
||||
|
||||
texture = IMG_LoadTexture(app.renderer, filePath);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
void cleanup(void) {
|
||||
SDL_DestroyWindow(app.window);
|
||||
SDL_DestroyRenderer(app.renderer);
|
||||
@@ -120,9 +86,6 @@ void handleInput(void) {
|
||||
exit(0);
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
player.x += 1;
|
||||
player.y += 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user