mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
little cleanup
This commit is contained in:
parent
35e3ad3738
commit
163efc05e8
6 changed files with 14 additions and 29 deletions
1
TODO
1
TODO
|
@ -1,4 +1,3 @@
|
|||
- check if every gamestate is stable on every platform
|
||||
- moar documentation
|
||||
- rewrite music handling into mixers
|
||||
- control settings
|
||||
|
|
|
@ -116,7 +116,7 @@ void About_Preload(struct Game *game) {
|
|||
game->about.letter_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
|
||||
al_set_target_bitmap(game->about.letter_bitmap);
|
||||
ScaleBitmap(game->about.letter, al_get_display_width(game->display), al_get_display_height(game->display), 0.75);
|
||||
ScaleBitmap(game->about.letter, al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
al_destroy_bitmap(game->about.letter);
|
||||
|
||||
al_set_target_bitmap(game->about.fade_bitmap);
|
||||
|
|
22
src/main.c
22
src/main.c
|
@ -147,7 +147,7 @@ void DrawGameState(struct Game *game) {
|
|||
}
|
||||
}
|
||||
|
||||
void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height, float val) {
|
||||
void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height) {
|
||||
if ((al_get_bitmap_width(source)==width) && (al_get_bitmap_height(source)==height)) {
|
||||
al_draw_bitmap(source, 0, 0, 0);
|
||||
return;
|
||||
|
@ -156,6 +156,8 @@ void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height, float val) {
|
|||
al_lock_bitmap(al_get_target_bitmap(), ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY);
|
||||
al_lock_bitmap(source, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
|
||||
|
||||
//linear filtering code written by SiegeLord
|
||||
|
||||
ALLEGRO_COLOR interpolate(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) {
|
||||
return al_map_rgba_f(c1.r + frac * (c2.r - c1.r),
|
||||
c1.g + frac * (c2.g - c1.g),
|
||||
|
@ -181,22 +183,6 @@ void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height, float val) {
|
|||
|
||||
al_put_pixel(x, y, result);
|
||||
}
|
||||
/*
|
||||
float pixy = ((float)y / height) * al_get_bitmap_height(source);
|
||||
for (x = 0; x < width; x++) {
|
||||
float pixx = ((float)x / width) * al_get_bitmap_width(source);
|
||||
ALLEGRO_COLOR a = al_get_pixel(source, pixx-val, pixy-val);
|
||||
ALLEGRO_COLOR b = al_get_pixel(source, pixx+val, pixy-val);
|
||||
ALLEGRO_COLOR c = al_get_pixel(source, pixx-val, pixy+val);
|
||||
ALLEGRO_COLOR d = al_get_pixel(source, pixx+val, pixy+val);
|
||||
ALLEGRO_COLOR result = al_map_rgba_f(
|
||||
(a.r+b.r+c.r+d.r) / 4,
|
||||
(a.g+b.b+c.g+d.g) / 4,
|
||||
(a.b+b.g+c.b+d.b) / 4,
|
||||
(a.a+b.a+c.a+d.a) / 4
|
||||
);
|
||||
al_put_pixel(x, y, result);
|
||||
}*/
|
||||
}
|
||||
al_unlock_bitmap(al_get_target_bitmap());
|
||||
al_unlock_bitmap(source);
|
||||
|
@ -216,7 +202,7 @@ ALLEGRO_BITMAP* LoadFromCache(struct Game *game, char* filename, int width, int
|
|||
source = al_load_bitmap( origfn );
|
||||
al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR);
|
||||
|
||||
ScaleBitmap(source, width, height, 0.35);
|
||||
ScaleBitmap(source, width, height);
|
||||
al_save_bitmap(cachefn, target);
|
||||
PrintConsole(game, "Cache bitmap %s generated.", filename);
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ void PrintConsole(struct Game *game, char* format, ...);
|
|||
/*! \brief Draws console bitmap on screen. */
|
||||
void DrawConsole(struct Game *game);
|
||||
|
||||
void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height, float val);
|
||||
void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height);
|
||||
ALLEGRO_BITMAP* LoadFromCache(struct Game *game, char* filename, int width, int height);
|
||||
float tps(struct Game *game, float t);
|
||||
|
||||
|
|
|
@ -112,13 +112,13 @@ void Map_Preload(struct Game *game) {
|
|||
ALLEGRO_BITMAP *scaled =LoadFromCache(game, "table.png", al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
al_set_target_bitmap(game->map.map);
|
||||
al_draw_bitmap(scaled, 0, 0 ,0);
|
||||
//ScaleBitmap(game->map.background, al_get_display_width(game->display), al_get_display_height(game->display), 0.5);
|
||||
//ScaleBitmap(game->map.background, al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
al_set_target_bitmap(scaled);
|
||||
ScaleBitmap(game->map.map_bg, al_get_display_width(game->display), al_get_display_height(game->display), 0.5);
|
||||
ScaleBitmap(game->map.map_bg, al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
al_set_target_bitmap(game->map.map);
|
||||
al_draw_bitmap(scaled, 0, 0 ,0);
|
||||
al_set_target_bitmap(scaled);
|
||||
ScaleBitmap(game->map.highlight, al_get_display_width(game->display), al_get_display_height(game->display), 0.5);
|
||||
ScaleBitmap(game->map.highlight, al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
al_set_target_bitmap(game->map.map);
|
||||
al_draw_bitmap(scaled, 0, 0 ,0);
|
||||
al_destroy_bitmap(scaled);
|
||||
|
|
10
src/menu.c
10
src/menu.c
|
@ -112,7 +112,7 @@ void Menu_Preload(struct Game *game) {
|
|||
game->menu.menu_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)*0.45);
|
||||
al_set_target_bitmap(game->menu.menu_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
ScaleBitmap(game->menu.image, al_get_display_width(game->display), al_get_display_height(game->display)*0.45, 0.75);
|
||||
ScaleBitmap(game->menu.image, al_get_display_width(game->display), al_get_display_height(game->display)*0.45);
|
||||
//al_draw_scaled_bitmap(game->menu.image,0, 0, al_get_bitmap_width(game->menu.image), al_get_bitmap_height(game->menu.image), 0, 0, al_get_display_width(game->display), al_get_display_height(game->display),0);
|
||||
al_destroy_bitmap(game->menu.image);
|
||||
|
||||
|
@ -120,21 +120,21 @@ void Menu_Preload(struct Game *game) {
|
|||
game->menu.cloud_bitmap = al_create_bitmap(al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.25);
|
||||
al_set_target_bitmap(game->menu.cloud_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
ScaleBitmap(game->menu.cloud, al_get_bitmap_width(game->menu.cloud_bitmap), al_get_bitmap_height(game->menu.cloud_bitmap), 0.75);
|
||||
ScaleBitmap(game->menu.cloud, al_get_bitmap_width(game->menu.cloud_bitmap), al_get_bitmap_height(game->menu.cloud_bitmap));
|
||||
//al_draw_scaled_bitmap(game->menu.cloud,0, 0, al_get_bitmap_width(game->menu.cloud), al_get_bitmap_height(game->menu.cloud), 0, 0, al_get_bitmap_width(game->menu.cloud_bitmap), al_get_bitmap_height(game->menu.cloud_bitmap),0);
|
||||
al_destroy_bitmap(game->menu.cloud);
|
||||
|
||||
game->menu.cloud2_bitmap = al_create_bitmap(al_get_display_width(game->display)*0.2, al_get_display_height(game->display)*0.1);
|
||||
al_set_target_bitmap(game->menu.cloud2_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
ScaleBitmap(game->menu.cloud2, al_get_bitmap_width(game->menu.cloud2_bitmap), al_get_bitmap_height(game->menu.cloud2_bitmap), 0.75);
|
||||
ScaleBitmap(game->menu.cloud2, al_get_bitmap_width(game->menu.cloud2_bitmap), al_get_bitmap_height(game->menu.cloud2_bitmap));
|
||||
//al_draw_scaled_bitmap(game->menu.cloud2,0, 0, al_get_bitmap_width(game->menu.cloud2), al_get_bitmap_height(game->menu.cloud2), 0, 0, al_get_bitmap_width(game->menu.cloud2_bitmap), al_get_bitmap_height(game->menu.cloud2_bitmap),0);
|
||||
al_destroy_bitmap(game->menu.cloud2);
|
||||
|
||||
game->menu.pinkcloud_bitmap = al_create_bitmap(al_get_display_width(game->display)*0.33125, al_get_display_height(game->display)); //*0.8122);
|
||||
game->menu.pinkcloud_scaled = al_create_bitmap(al_get_bitmap_width(game->menu.pinkcloud_bitmap), al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.8122);
|
||||
al_set_target_bitmap(game->menu.pinkcloud_scaled);
|
||||
ScaleBitmap(game->menu.pinkcloud, al_get_bitmap_width(game->menu.pinkcloud_scaled), al_get_bitmap_height(game->menu.pinkcloud_scaled), 0.75);
|
||||
ScaleBitmap(game->menu.pinkcloud, al_get_bitmap_width(game->menu.pinkcloud_scaled), al_get_bitmap_height(game->menu.pinkcloud_scaled));
|
||||
//al_draw_scaled_bitmap(game->menu.pinkcloud,0, 0, al_get_bitmap_width(game->menu.pinkcloud), al_get_bitmap_height(game->menu.pinkcloud), 0, 0, al_get_bitmap_width(game->menu.pinkcloud_scaled), al_get_bitmap_height(game->menu.pinkcloud_scaled),0);
|
||||
al_destroy_bitmap(game->menu.pinkcloud);
|
||||
|
||||
|
@ -149,7 +149,7 @@ void Menu_Preload(struct Game *game) {
|
|||
game->menu.mountain_bitmap = al_create_bitmap(al_get_display_width(game->display)*0.055, al_get_display_height(game->display)/9);
|
||||
al_set_target_bitmap(game->menu.mountain_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
ScaleBitmap(game->menu.mountain, al_get_bitmap_width(game->menu.mountain_bitmap), al_get_bitmap_height(game->menu.mountain_bitmap), 0.75);
|
||||
ScaleBitmap(game->menu.mountain, al_get_bitmap_width(game->menu.mountain_bitmap), al_get_bitmap_height(game->menu.mountain_bitmap));
|
||||
//al_draw_scaled_bitmap(game->menu.mountain,0, 0, al_get_bitmap_width(game->menu.mountain), al_get_bitmap_height(game->menu.mountain), 0, 0, al_get_bitmap_width(game->menu.mountain_bitmap), al_get_bitmap_height(game->menu.mountain_bitmap),0);
|
||||
al_destroy_bitmap(game->menu.mountain);
|
||||
|
||||
|
|
Loading…
Reference in a new issue