/* Kitsune's Curse Copyright (C) 2020-2023 Juan J. Martinez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "splib.h" #include "plw.h" #include "sound.h" #include "main.h" #include "int.h" #include "maps.h" // generated #include "items.h" #include "tiles.h" #include "entities.h" #include "et_player.h" #include "et_pickups.h" void draw_pickup() { if (!is_invalid_tile2(get_tile_xy(*it_x >> 3, *it_y >> 3))) return; put_sprite4(items[sp_it->type - ET_GEM], *it_x, *it_y, 2, 0); } void draw_gtail() { put_sprite4(items[0], *it_x, *it_y, 2, 0); erase_sprite(*it_ox, *it_oy, 2); } static const int8_t gtail_y[9] = { 0, 0, -1, -1, -2, -3, -2, -1, -1 }; static const int8_t gtails[16] = { -1, 0, -1, -1, 0, -1, 1, -1, 1, 0, 1, 1, 0, 1, -1, 1, }; void _gtail_effect() { uint8_t i; int8_t x, y; for (i = 0; i < 5; ++i) { for (it_k = 0; it_k < 16; it_k += 2) { x = (gtails[it_k] << i); y = (gtails[it_k + 1] << i); put_sprite4(items[0], *it_x + x, *it_y + y, 2, 0); if (i) { x >>= 1; y >>= 1; erase_sprite(*it_x + x, *it_y + y, 2); } } if (i == 2) set_hw_ink(0, 0x4b); update_screen(); wait(); } wait_for(8); set_hw_ink(0, 0x54); draw_map(); } void update_gtail() { if ((*it_delay)++ == 2) { *it_delay = 0; if (++(*it_frame) == 9) { *it_param ^= 128; if (*it_param) *it_frame = 2; else *it_frame = 0; } if (*it_param) *it_y -= gtail_y[*it_frame]; else *it_y += gtail_y[*it_frame]; } if (!check_for_player(16)) return; PLW_PlaySoundEffectP(EFX_MAGIC); PLW_Init(songs, SONG_SPLIT); fill_screen(bgtiles[9]); // extra live ++lives; life = MAX_LIFE; gems = 30; gtail = 1; draw_hud_bg(); draw_hud(); wait(); *it_oy = *it_y; for (it_k = 0; it_k < 60; ++it_k) { if (it_k & 1) { --gems; draw_hud(); } *it_ox = *it_x; *it_x ^= 2; put_sprite4(items[0], *it_x, *it_y, 2, 0); erase_sprite(*it_ox, *it_oy, 2); update_screen(); wait(); } destroy_entity(); update_persistence(sp_it->id); _gtail_effect(); PLW_Init(songs, SONG_INGAME); } void update_pickup() { if (!check_for_player(16)) return; switch (sp_it->type) { case ET_POTION: if (life == MAX_LIFE) return; life = MAX_LIFE; break; case ET_KEY: ++keys; break; case ET_GEM: ++gems; break; } erase_sprite(*it_x, *it_y, 2); destroy_entity(); update_persistence(sp_it->id); PLW_PlaySoundEffectP(EFX_PICKUP); draw_hud(); }