aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xMakefile7
-rw-r--r--README5
-rw-r--r--README.md12
-rwxr-xr-xbuild.sh19
-rwxr-xr-xsrc/main.c (renamed from main.c)10
6 files changed, 36 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore
index 7a89bf6..c86bde1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
paladins.ttf
-ascii
+bin/**
diff --git a/Makefile b/Makefile
deleted file mode 100755
index f8c88d3..0000000
--- a/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-LIB=
-
-main: main.c
- gcc -o ascii main.c -lSDL2 `sdl2-config --cflags --libs` -lSDL2_ttf -lSDL2_image -lm ${LIB}
-
-debug: main.c
- gcc -o ascii main.c -lSDL2 `sdl2-config --cflags --libs` -lSDL2_ttf -lSDL2_image -lm ${LIB} -g -fsanitize=address
diff --git a/README b/README
deleted file mode 100644
index bad87dd..0000000
--- a/README
+++ /dev/null
@@ -1,5 +0,0 @@
-Makes ASCII from text using SDL2. Do --help for help
-
-Just a little project i wanted to make because ascii is cool. No plans to optimize this. It works fine. There're are definitely better terminal only based ones.
-
-You need to download the paladins.ttf font and put it in the same directory as this executable. Yes I'm lazy.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..49d948b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,12 @@
+# ascii
+
+Makes ASCII from text using SDL2. Do `bin/ascii --help` for help
+
+Just a little project i wanted to make because ascii is cool. There are definitely better terminal only based ones.
+
+# requirements
+
+- clang
+- sdl2
+- sdl2_ttf
+- sdl2_image
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..10eeb23
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+DEBUG=""
+LIB="-lSDL2_gfx -lSDL2_ttf -lSDL2_image"
+
+[ ! -d "bin" ] && mkdir bin
+
+while getopts "d" opt; do
+ case "$opt" in
+ d) DEBUG="-Wall -fsanitize=address -g"
+ ;;
+ esac
+done
+
+shift $((OPTIND-1))
+[ "${1:-}" = "--" ] && shift
+
+printf "\n\nmaking project\n"
+clang -o "bin/ascii" src/main.c $LIB `sdl2-config --cflags --libs` -lm $DEBUG
diff --git a/main.c b/src/main.c
index 8eba07f..a8a18b3 100755
--- a/main.c
+++ b/src/main.c
@@ -1,6 +1,3 @@
-#include <SDL2/SDL_pixels.h>
-#include <SDL2/SDL_render.h>
-#include <SDL2/SDL_stdinc.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -12,6 +9,7 @@
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
+#define conf_font "/usr/share/fonts/TTF/Inconsolata-Regular.ttf"
float map(float value, float start1, float stop1, float start2, float stop2){
@@ -199,7 +197,7 @@ void draw(SDL_Renderer* renderer,SDL_Window* window, uint32_t pix_format,TTF_Fon
//textRect2->w = textRect2->h = 10;
-
+
SDL_Texture *textllure;
textllure=IMG_LoadTexture(renderer,parsed_args->file);
@@ -328,7 +326,7 @@ int main(int argc, char *argv[])
- SDL_Window *window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, parsed_args.width, parsed_args.height, SDL_WINDOW_SHOWN);
+ SDL_Window *window = SDL_CreateWindow("SDL Ascii", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, parsed_args.width, parsed_args.height, SDL_WINDOW_SHOWN);
if (!window) {
printf("Failed to create window: %s\n", SDL_GetError());
}
@@ -340,7 +338,7 @@ int main(int argc, char *argv[])
uint32_t wnd_pix_fmt = SDL_GetWindowPixelFormat(window);
- TTF_Font *font = TTF_OpenFont("/usr/share/fonts/TTF/Inconsolata-Regular.ttf",parsed_args.char_size);
+ TTF_Font *font = TTF_OpenFont(conf_font,parsed_args.char_size);
draw(renderer,window,wnd_pix_fmt,font,&parsed_args);