Skip to content

Commit

Permalink
Added proper Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePotatoChronicler committed Apr 29, 2022
1 parent 09476c8 commit 2d6d934
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2048
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
build: release
release: main.c
gcc main.c -o 2048 -Wall -Wextra -lcurses -lm -Ofast
CFLAGS := -Wall -Wextra -Werror -O2
LDFLAGS := -lcurses -lm

debug: main.c
gcc main.c -o 2048_debug -Wall -Wextra -lcurses -lm -Og -g
all: 2048

run: build
./2048
2048: main.c
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)

.PHONY: all
3 changes: 2 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void draw_board() {
else { sprintf(text, "%i", (int)(pow(2, board[i]))); }
if ( strlen(text) > size_x ) { sprintf(text, "2^%i", board[i]); }

mvprintw(off_y + letter_y, off_x + letter_x + (strlen(text) + 1) % 2 - strlen(text) / 2, text);
mvaddstr(off_y + letter_y, off_x + letter_x + (strlen(text) + 1) % 2 - strlen(text) / 2, text);

attroff(COLOR_PAIR((board[i] != 0) * ((board[i] - 1) % (color_amount - 1) + 2) + (board[i] == 0)));

Expand Down Expand Up @@ -287,6 +287,7 @@ int main(int argc, char** argv) {
initscr();
clear();
start_color();
use_default_colors();

// Color Init
color(50, 50, 50, FALSE); // First color is for 0 tiles
Expand Down

0 comments on commit 2d6d934

Please sign in to comment.