~srivathsan/dave

962ef933cdaae1283f3ab4663904c4f95a3aaeae — Srivathsan Murali 8 months ago 3d98287
intialize tiles as textures
3 files changed, 9 insertions(+), 8 deletions(-)

M assets.c
M assets.h
M dave.c
M assets.c => assets.c +3 -2
@@ 1,14 1,15 @@
#include "assets.h"
#include <stdint.h>

void load_assets(struct game_assets *assets)
void load_assets(struct game_assets *assets, SDL_Renderer *renderer)
{
	// load tiles
	for (uint8_t i = 0; i < 158; i++)
	{
		char filename[24];
		sprintf(&filename[0], "gamedata/tiles/%d.bmp", i);
		assets->tiles[i] = SDL_LoadBMP(filename);
		assets->tiles[i] = SDL_CreateTextureFromSurface(
				renderer, SDL_LoadBMP(filename));
	}
	
	// load game levels

M assets.h => assets.h +2 -2
@@ 6,10 6,10 @@

struct game_assets
{
	SDL_Surface *tiles[158];
	SDL_Texture *tiles[158];
	struct game_level levels[10];
};

void load_assets(struct game_assets *assets);
void load_assets(struct game_assets *assets, SDL_Renderer *renderer);

#endif // __DAVE_ASSETS_H__

M dave.c => dave.c +4 -4
@@ 8,12 8,12 @@ int main(int argc, char* argv[])
	struct dave *game;
	game = malloc(sizeof(struct dave));
	
	// initialize the dave struct
	initialize_dave(game);
	
	// intialize the game graphics
	initialize_graphics(game);
	
	// initialize the dave struct
	initialize_dave(game);
	
	// Run the game loop
	printf("Starting Dave...\n");
	while(!game->state->quit)


@@ 33,7 33,7 @@ void initialize_dave(struct dave *game)
{
	// Load game assets
	game->assets = malloc(sizeof(struct game_assets));
	load_assets(game->assets);
	load_assets(game->assets, game->renderer);
	
	// Initialize the game state
	game->state = malloc(sizeof(struct game_state));