-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
313dfca
commit cf1aaf3
Showing
19 changed files
with
969 additions
and
18 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* This program uses the Allegro game library to display a blank window. | ||
* | ||
* It initializes the display and starts up the main game loop. The | ||
* game loop only checks for two events: timer (determined by the FPS) | ||
* and display close (when the user tries to close the window). | ||
* | ||
* http://www.damienradtke.org/building-a-mario-clone-with-allegro | ||
*/ | ||
|
||
// https://gist.github.com/dradtke/2494024 | ||
|
||
#include <stdio.h> | ||
#include <allegro5/allegro.h> | ||
//#include <allegro/allegro.h> | ||
|
||
const float FPS = 60; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
ALLEGRO_DISPLAY *display = NULL; | ||
ALLEGRO_EVENT_QUEUE *event_queue = NULL; | ||
ALLEGRO_TIMER *timer = NULL; | ||
|
||
bool running = true; | ||
bool redraw = true; | ||
|
||
// Initialize allegro | ||
if (!al_init()) { | ||
fprintf(stderr, "Failed to initialize allegro.\n"); | ||
return 1; | ||
} | ||
|
||
// Initialize the timer | ||
timer = al_create_timer(1.0 / FPS); | ||
if (!timer) { | ||
fprintf(stderr, "Failed to create timer.\n"); | ||
return 1; | ||
} | ||
|
||
// Create the display | ||
display = al_create_display(640, 480); | ||
if (!display) { | ||
fprintf(stderr, "Failed to create display.\n"); | ||
return 1; | ||
} | ||
|
||
// Create the event queue | ||
event_queue = al_create_event_queue(); | ||
if (!event_queue) { | ||
fprintf(stderr, "Failed to create event queue."); | ||
return 1; | ||
} | ||
|
||
// Register event sources | ||
al_register_event_source(event_queue, al_get_display_event_source(display)); | ||
al_register_event_source(event_queue, al_get_timer_event_source(timer)); | ||
|
||
// Display a black screen | ||
al_clear_to_color(al_map_rgb(0, 0, 0)); | ||
al_flip_display(); | ||
|
||
// Start the timer | ||
al_start_timer(timer); | ||
|
||
// Game loop | ||
while (running) { | ||
ALLEGRO_EVENT event; | ||
ALLEGRO_TIMEOUT timeout; | ||
|
||
// Initialize timeout | ||
al_init_timeout(&timeout, 0.06); | ||
|
||
// Fetch the event (if one exists) | ||
bool get_event = al_wait_for_event_until(event_queue, &event, &timeout); | ||
|
||
// Handle the event | ||
if (get_event) { | ||
switch (event.type) { | ||
case ALLEGRO_EVENT_TIMER: | ||
redraw = true; | ||
break; | ||
case ALLEGRO_EVENT_DISPLAY_CLOSE: | ||
running = false; | ||
break; | ||
default: | ||
fprintf(stderr, "Unsupported event received: %d\n", event.type); | ||
break; | ||
} | ||
} | ||
|
||
// Check if we need to redraw | ||
if (redraw && al_is_event_queue_empty(event_queue)) { | ||
// Redraw | ||
al_clear_to_color(al_map_rgb(0, 255, 0)); | ||
al_flip_display(); | ||
redraw = false; | ||
} | ||
} | ||
|
||
// Clean up | ||
al_destroy_display(display); | ||
al_destroy_event_queue(event_queue); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
https://liballeg.org/ | ||
|
||
#Allegro 5 | ||
Download: | ||
[https://github.com/liballeg/allegro5] | ||
|
||
```bash | ||
cmake -S . -B build && cmake --build build | ||
su | ||
cmake --install build --prefix=/usr | ||
``` | ||
oder | ||
```bash | ||
mkdir build | ||
cd build | ||
cmake .. | ||
``` | ||
## Kompilieren | ||
|
||
```bash | ||
gcc allegro.c -lallegro | ||
gcc allegro.c `pkg-config allegro-5 --libs --cflags` | ||
` | ||
``` | ||
|
||
#Allegro 4.x | ||
```bash | ||
apt install liballegro4-dev | ||
``` | ||
|
||
## Kompilieren | ||
```bash | ||
gcc allegro.c -I/usr/local/include -L/usr/local/lib -lallegro | ||
``` | ||
|
||
|
||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="Allegro" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/Allegro" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Debug/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-g" /> | ||
</Compiler> | ||
</Target> | ||
<Target title="Release"> | ||
<Option output="bin/Release/Allegro" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="0" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<Compiler> | ||
<Add option="-Wall" /> | ||
<Add option="`pkg-config allegro-5 --cflags`" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="`pkg-config allegro-5 --libs`" /> | ||
</Linker> | ||
<Unit filename="main.c"> | ||
<Option compilerVar="CC" /> | ||
</Unit> | ||
<Extensions /> | ||
</Project> | ||
</CodeBlocks_project_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* This program uses the Allegro game library to display a blank window. | ||
* | ||
* It initializes the display and starts up the main game loop. The | ||
* game loop only checks for two events: timer (determined by the FPS) | ||
* and display close (when the user tries to close the window). | ||
* | ||
* http://www.damienradtke.org/building-a-mario-clone-with-allegro | ||
*/ | ||
|
||
// https://gist.github.com/dradtke/2494024 | ||
|
||
#include <stdio.h> | ||
#include <allegro5/allegro.h> | ||
//#include <allegro/allegro.h> | ||
|
||
const float FPS = 60; | ||
char col=0; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
ALLEGRO_DISPLAY *display = NULL; | ||
ALLEGRO_EVENT_QUEUE *event_queue = NULL; | ||
ALLEGRO_TIMER *timer = NULL; | ||
|
||
bool running = true; | ||
bool redraw = true; | ||
|
||
// Initialize allegro | ||
if (!al_init()) { | ||
fprintf(stderr, "Failed to initialize allegro.\n"); | ||
return 1; | ||
} | ||
|
||
// Initialize the timer | ||
timer = al_create_timer(1.0 / FPS); | ||
if (!timer) { | ||
fprintf(stderr, "Failed to create timer.\n"); | ||
return 1; | ||
} | ||
|
||
// Create the display | ||
display = al_create_display(640, 480); | ||
if (!display) { | ||
fprintf(stderr, "Failed to create display.\n"); | ||
return 1; | ||
} | ||
|
||
// Create the event queue | ||
event_queue = al_create_event_queue(); | ||
if (!event_queue) { | ||
fprintf(stderr, "Failed to create event queue."); | ||
return 1; | ||
} | ||
|
||
// Register event sources | ||
al_register_event_source(event_queue, al_get_display_event_source(display)); | ||
al_register_event_source(event_queue, al_get_timer_event_source(timer)); | ||
|
||
// Display a black screen | ||
al_clear_to_color(al_map_rgb(0, 0, 0)); | ||
al_flip_display(); | ||
|
||
// Start the timer | ||
al_start_timer(timer); | ||
|
||
// Game loop | ||
while (running) { | ||
ALLEGRO_EVENT event; | ||
ALLEGRO_TIMEOUT timeout; | ||
|
||
// Initialize timeout | ||
al_init_timeout(&timeout, 0.06); | ||
|
||
// Fetch the event (if one exists) | ||
bool get_event = al_wait_for_event_until(event_queue, &event, &timeout); | ||
|
||
// Handle the event | ||
if (get_event) { | ||
switch (event.type) { | ||
case ALLEGRO_EVENT_TIMER: | ||
redraw = true; | ||
break; | ||
case ALLEGRO_EVENT_DISPLAY_CLOSE: | ||
running = false; | ||
break; | ||
default: | ||
fprintf(stderr, "Unsupported event received: %d\n", event.type); | ||
break; | ||
} | ||
} | ||
|
||
// Check if we need to redraw | ||
if (redraw && al_is_event_queue_empty(event_queue)) { | ||
// Redraw | ||
al_clear_to_color(al_map_rgb(0, col, 0)); | ||
col++; | ||
al_flip_display(); | ||
redraw = false; | ||
} | ||
} | ||
|
||
// Clean up | ||
al_destroy_display(display); | ||
al_destroy_event_queue(event_queue); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://allegro-pas.sourceforge.net/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.