Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add EXIT event if physical button is pressed + basic Linux Makefile #6

Merged
merged 3 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

BUILDTIME=$(shell date +'\"%Y-%m-%d %H:%M\"')

CC = gcc
CXX = g++
STRIP = strip
SDL_CFLAGS := `sdl-config --cflags`

OUTPUTNAME = boot-logo

DEFINES = -DHAVE_STDINT_H -DVERSION_BITTBOY
INCLUDES = -Iinclude $(SDL_CFLAGS)
EXTRA_LDFLAGS = -lmpg123 -Wl,--as-needed -Wl,--gc-sections -flto -s

CFLAGS = $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -std=gnu11
CXXFLAGS = $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -std=gnu++11
LDFLAGS = -Wl,--start-group -lSDL -lSDL_image -lpng -ljpeg -lSDL_mixer -lfreetype -lSDL_ttf -logg -lm -pthread -lz -lstdc++ $(EXTRA_LDFLAGS) -Wl,--end-group

# Redream (main engine)
OBJS = \
main.o

.c.o:
$(CC) $(CFLAGS) -c -o $@ $<

.cpp.o:
$(CXX) $(CXXFLAGS) -c -o $@ $<

all: executable

executable : $(OBJS)
$(CC) -o $(OUTPUTNAME) $(OBJS) $(CFLAGS) $(LDFLAGS)

clean:
rm $(OBJS) $(OUTPUTNAME)
17 changes: 17 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ int main(int argc, char* argv[]) {
uint32_t color = SDL_MapRGB(screen->format, R, G, B);
SDL_Rect rect;
SDL_Rect dstrect;
SDL_Event event;
for (int i = 0 - logoimg->h - ANIMDELAY; i <= dest_y; i = i + ANIMSPEED) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
exit(0);
break;
}
}
rect.x = 0;
rect.y = 0;
rect.w = screen->w;
Expand All @@ -86,6 +94,15 @@ int main(int argc, char* argv[]) {
SDL_BlitSurface(logoimg, NULL, screen, &dstrect);
if (i == dest_y) {
Mix_PlayChannel(-1, logosound, 0);
while(1) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
exit(0);
break;
}
}
}
}
while (curr_time < old_time + 16) {
curr_time = SDL_GetTicks();
Expand Down