Compare commits
3 Commits
4a52d509c9
...
5fe59448f6
Author | SHA1 | Date | |
---|---|---|---|
5fe59448f6 | |||
822090b5f5 | |||
7f039aa4f2 |
4
01_text_adventure/.gitignore
vendored
4
01_text_adventure/.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
fatal_text_adventure_linux
|
||||
fatal_text_adventure_windows.exe
|
||||
fatal_text_adventure_windows.exe
|
||||
fatal_text_adventure_linux.zip
|
||||
fatal_text_adventure_windows.zip
|
@ -40,6 +40,14 @@ clean:
|
||||
rm -f ./$(GAME)_windows.exe
|
||||
rm -f ./data/*.c
|
||||
|
||||
butler_upload: $(GAME)_linux $(GAME)_windows
|
||||
$(BUTLER) push ./$(GAME)_linux bassguitarbill/fatal-distractions:$(ITCH_CHANNEL_LINUX)
|
||||
$(BUTLER) push ./$(GAME)_windows.exe bassguitarbill/fatal-distractions:$(ITCH_CHANNEL_WINDOWS)
|
||||
$(GAME)_linux.zip: $(GAME)_linux
|
||||
rm -f ./$(GAME)_linux.zip
|
||||
zip -r $(GAME)_linux.zip $(GAME)_linux img/*.png
|
||||
|
||||
$(GAME)_windows.zip: $(GAME)_windows.exe
|
||||
rm -f ./$(GAME)_windows.zip
|
||||
zip -r $(GAME)_windows.zip $(GAME)_windows.exe img/*.png
|
||||
|
||||
butler_upload: $(GAME)_linux.zip $(GAME)_windows.zip
|
||||
$(BUTLER) push ./$(GAME)_linux.zip bassguitarbill/fatal-distractions:$(ITCH_CHANNEL_LINUX)
|
||||
$(BUTLER) push ./$(GAME)_windows.zip bassguitarbill/fatal-distractions:$(ITCH_CHANNEL_WINDOWS)
|
||||
|
BIN
01_text_adventure/img/made_by_bgb.aseprite
Normal file
BIN
01_text_adventure/img/made_by_bgb.aseprite
Normal file
Binary file not shown.
BIN
01_text_adventure/img/made_by_bgb.png
Normal file
BIN
01_text_adventure/img/made_by_bgb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
BIN
01_text_adventure/img/made_w_raylib.aseprite
Normal file
BIN
01_text_adventure/img/made_w_raylib.aseprite
Normal file
Binary file not shown.
BIN
01_text_adventure/img/made_w_raylib.png
Normal file
BIN
01_text_adventure/img/made_w_raylib.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
54
01_text_adventure/intro.c
Normal file
54
01_text_adventure/intro.c
Normal file
@ -0,0 +1,54 @@
|
||||
#include <stdlib.h>
|
||||
#include "intro.h"
|
||||
|
||||
#define FONT_SIZE 36
|
||||
|
||||
void display_loading(void) {
|
||||
int window_width = GetRenderWidth();
|
||||
int window_height = GetRenderHeight();
|
||||
int loading_width = MeasureText("Loading...", FONT_SIZE);
|
||||
BeginDrawing();
|
||||
DrawText("Loading...", window_width - loading_width, window_height - FONT_SIZE, FONT_SIZE, RAYWHITE);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
Intro *load_intro(void) {
|
||||
Intro *i = malloc(sizeof(Intro));
|
||||
i->textures = malloc(sizeof(Texture) * 2);
|
||||
|
||||
Image bgb = LoadImage("img/made_by_bgb.png");
|
||||
i->textures[0] = LoadTextureFromImage(bgb);
|
||||
UnloadImage(bgb);
|
||||
|
||||
Image ray = LoadImage("img/made_w_raylib.png");
|
||||
i->textures[1] = LoadTextureFromImage(ray);
|
||||
UnloadImage(ray);
|
||||
|
||||
i->texture_count = 2;
|
||||
i->timer = 0.;
|
||||
return i;
|
||||
}
|
||||
|
||||
#define SLIDE_TIME 2.0
|
||||
#define FADE_IN_TIME 0.5
|
||||
#define FADE_OUT_TIME 0.5
|
||||
void intro_display(Intro *intro) {
|
||||
float frame_time, elapsed_time, alpha;
|
||||
for (int i = 0; i < intro->texture_count; i++) {
|
||||
intro->timer = GetTime() + SLIDE_TIME;
|
||||
while((frame_time = GetTime()) < intro->timer) {
|
||||
elapsed_time = SLIDE_TIME - (intro->timer - frame_time);
|
||||
if (elapsed_time < FADE_IN_TIME)
|
||||
alpha = ((FADE_IN_TIME - elapsed_time) / FADE_IN_TIME) * 255.;
|
||||
else if (elapsed_time > SLIDE_TIME - FADE_OUT_TIME)
|
||||
alpha = ((elapsed_time - (SLIDE_TIME - FADE_OUT_TIME)) / FADE_OUT_TIME) * 255.;
|
||||
else
|
||||
alpha = 0;
|
||||
|
||||
BeginDrawing();
|
||||
DrawTexture(intro->textures[i], 0, 0, WHITE);
|
||||
DrawRectangle(0, 0, 800, 450, (Color) { 0, 0, 0, alpha });
|
||||
EndDrawing();
|
||||
}
|
||||
}
|
||||
}
|
18
01_text_adventure/intro.h
Normal file
18
01_text_adventure/intro.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _FD_INTRO_
|
||||
#define _FD_INTRO_
|
||||
|
||||
typedef struct Intro Intro;
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
struct Intro {
|
||||
Texture *textures;
|
||||
int texture_count;
|
||||
double timer;
|
||||
};
|
||||
|
||||
void display_loading(void);
|
||||
Intro *load_intro(void);
|
||||
void intro_display(Intro *i);
|
||||
|
||||
#endif
|
@ -4,12 +4,17 @@
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
#include "intro.h"
|
||||
#include "game.h"
|
||||
|
||||
int main(void) {
|
||||
int main(int argc, char** argv) {
|
||||
InitWindow(800, 450, "Text Adventure");
|
||||
SetTargetFPS(60);
|
||||
|
||||
display_loading();
|
||||
Intro *i = load_intro();
|
||||
intro_display(i);
|
||||
|
||||
Game *g = game_create();
|
||||
|
||||
game_run_until_close(g);
|
||||
|
Loading…
Reference in New Issue
Block a user