<commit_before>#include <stdio.h>
#include <sys/time.h>
#include <math.h>
#include <getopt.h>

#include <SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>

#include "util.h"
#include "entity.h"
#include "level.h"
#include "main.h"
#include "input.h"

SDL_Renderer *renderer;

Entity *ents[512];
int entsC = 0;

int WIDTH;
int HEIGHT;
int FIRSTLEVEL = 1;
Entity *ply;
int quit = 0;

void initVariables(int w, int h) {

}

int main(int argc, char *argv[]) {
	
	static SDL_Window *window;
	if(initWindow(&window, &renderer, argc, argv)) return 1;
	initVariables(WIDTH, HEIGHT);
	initTextures();
	//initHUD();

	generateLevel(FIRSTLEVEL);

	ply = new Entity(TextureDataCreate("res/plank.png"), TYPE_PLAYER, WIDTH/2 - 50, HEIGHT - 36);
	
	int lastFrame = curtime_u() - 1;
	double dt;
	while(!quit) {
		if(DEBUG) fpsCounter();

		// Calculate dt
		int curFrame = curtime_u();
		if(lastFrame > curFrame) {dt = ((1000000 - lastFrame) + curFrame) / 1000000.0;}
		else {dt = (curFrame - lastFrame) / 1000000.0;}
		lastFrame = curFrame;

		// ===================
		// Update
		handleKeyboard(dt, ply);
		for(int enti=0; enti<entsC; enti++) {
			if(ents[enti] == NULL) continue;
			ents[enti]->Update(dt);
		}
		
		// ====================
		// Win/Loss conditions
		checkWinLoss();
		
		// ====================
		// Drawing
		drawBackground(renderer, dt);
		for(int enti=0; enti<entsC; enti++) {
			if(ents[enti] == NULL) continue;
			ents[enti]->Draw(dt);
		}
		//drawHUD();

		// Flip render buffer
		SDL_RenderPresent(renderer);
		
		// Frame limiting, not needed if we're using vsync
		//SDL_Delay((1000 / 66) - (curtime_u() - lastFrame)/1000);
	}
	printf("\nShutting down...\n");

	// Destroy old textures
	for(int enti=0; enti<entsC; enti++) {
		if(ents[enti] == NULL) continue;
		delete ents[enti];
	}

	SDL_DestroyRenderer(renderer);
	SDL_DestroyWindow(window);
	
 	#ifndef __arm__
	Mix_CloseAudio();
	Mix_Quit();
	#endif

	IMG_Quit();
	SDL_Quit();
	return 0;
}


int initWindow(SDL_Window **window, SDL_Renderer **renderer, int argc, char *argv[]) {
	if(SDL_Init(SDL_INIT_EVERYTHING) == -1) {
		fprintf(stderr, "SDL Init failed: %s\n", SDL_GetError());
		return 1;
	}

	/*SDL_DisplayMode displayInfo;
	SDL_GetCurrentDisplayMode(0, &displayInfo); 
	WIDTH = displayInfo.w;
	HEIGHT = displayInfo.h;*/
	WIDTH = 800;
	HEIGHT = 600;
	
	int flags=IMG_INIT_JPG|IMG_INIT_PNG;
	if(IMG_Init(flags) != flags) {
		fprintf(stderr, "IMG_Init failed: %s\n", IMG_GetError());
		return 1;
	}

	#ifndef __arm__
	if(Mix_OpenAudio( MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024 ) == -1) {
		fprintf(stderr, "Audio Init failed: %s\n", Mix_GetError());
		return 1;
	}
	int mixFlags = MIX_INIT_MP3|MIX_INIT_OGG;
	if(Mix_Init(mixFlags) != mixFlags) {
		fprintf(stderr, "Audio Init2 failed: %s\n", Mix_GetError());
		return 1;
	}
	#endif

	int useSoftwareAccel = 0;
	int optionIndex = 0;
	int c;<commit_msg>Removed reference to mp3's, since they are not used<commit_after>#include <stdio.h>
#include <sys/time.h>
#include <math.h>
#include <getopt.h>

#include <SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>

#include "util.h"
#include "entity.h"
#include "level.h"
#include "main.h"
#include "input.h"

SDL_Renderer *renderer;

Entity *ents[512];
int entsC = 0;

int WIDTH;
int HEIGHT;
int FIRSTLEVEL = 1;
Entity *ply;
int quit = 0;

void initVariables(int w, int h) {

}

int main(int argc, char *argv[]) {
	
	static SDL_Window *window;
	if(initWindow(&window, &renderer, argc, argv)) return 1;
	initVariables(WIDTH, HEIGHT);
	initTextures();
	//initHUD();

	generateLevel(FIRSTLEVEL);

	ply = new Entity(TextureDataCreate("res/plank.png"), TYPE_PLAYER, WIDTH/2 - 50, HEIGHT - 36);
	
	int lastFrame = curtime_u() - 1;
	double dt;
	while(!quit) {
		if(DEBUG) fpsCounter();

		// Calculate dt
		int curFrame = curtime_u();
		if(lastFrame > curFrame) {dt = ((1000000 - lastFrame) + curFrame) / 1000000.0;}
		else {dt = (curFrame - lastFrame) / 1000000.0;}
		lastFrame = curFrame;

		// ===================
		// Update
		handleKeyboard(dt, ply);
		for(int enti=0; enti<entsC; enti++) {
			if(ents[enti] == NULL) continue;
			ents[enti]->Update(dt);
		}
		
		// ====================
		// Win/Loss conditions
		checkWinLoss();
		
		// ====================
		// Drawing
		drawBackground(renderer, dt);
		for(int enti=0; enti<entsC; enti++) {
			if(ents[enti] == NULL) continue;
			ents[enti]->Draw(dt);
		}
		//drawHUD();

		// Flip render buffer
		SDL_RenderPresent(renderer);
		
		// Frame limiting, not needed if we're using vsync
		//SDL_Delay((1000 / 66) - (curtime_u() - lastFrame)/1000);
	}
	printf("\nShutting down...\n");

	// Destroy old textures
	for(int enti=0; enti<entsC; enti++) {
		if(ents[enti] == NULL) continue;
		delete ents[enti];
	}

	SDL_DestroyRenderer(renderer);
	SDL_DestroyWindow(window);
	
 	#ifndef __arm__
	Mix_CloseAudio();
	Mix_Quit();
	#endif

	IMG_Quit();
	SDL_Quit();
	return 0;
}


int initWindow(SDL_Window **window, SDL_Renderer **renderer, int argc, char *argv[]) {
	if(SDL_Init(SDL_INIT_EVERYTHING) == -1) {
		fprintf(stderr, "SDL Init failed: %s\n", SDL_GetError());
		return 1;
	}

	/*SDL_DisplayMode displayInfo;
	SDL_GetCurrentDisplayMode(0, &displayInfo); 
	WIDTH = displayInfo.w;
	HEIGHT = displayInfo.h;*/
	WIDTH = 800;
	HEIGHT = 600;
	
	int flags=IMG_INIT_JPG|IMG_INIT_PNG;
	if(IMG_Init(flags) != flags) {
		fprintf(stderr, "IMG_Init failed: %s\n", IMG_GetError());
		return 1;
	}

	#ifndef __arm__
	if(Mix_OpenAudio( MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024 ) == -1) {
		fprintf(stderr, "Audio Init failed: %s\n", Mix_GetError());
		return 1;
	}
	int mixFlags = MIX_INIT_OGG;
	if(Mix_Init(mixFlags) != mixFlags) {
		fprintf(stderr, "Audio Init2 failed: %s\n", Mix_GetError());
		return 1;
	}
	#endif

	int useSoftwareAccel = 0;
	int optionIndex = 0;
	int c;
{'fraction_non_alphanumeric': 0.17964586556644319, 'fraction_numerical': 0.02544266804194602, 'mean_word_length': 4.162377994676131, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5951961', 'n_tokens_mistral': 2556, 'n_tokens_neox': 2246, 'n_words': 507}