diff options
author | kdx <kikoodx@paranoici.org> | 2023-01-20 19:11:27 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-01-20 19:11:27 +0100 |
commit | 10b446ddca32b7541db6d25552a0c7e8c395bd03 (patch) | |
tree | 02dc4300e4810020ce65ae3e12836a57fea395c4 | |
parent | b5fe97a97c5debdb8f803efcdaa94e80a2e49953 (diff) | |
download | 005-10b446ddca32b7541db6d25552a0c7e8c395bd03.tar.gz |
perfect
-rw-r--r-- | Cursor.cpp | 37 | ||||
-rw-r--r-- | Cursor.hpp | 1 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | Table.cpp | 10 | ||||
-rw-r--r-- | main.cpp | 6 | ||||
-rw-r--r-- | res/suk.wav | bin | 0 -> 79916 bytes |
6 files changed, 45 insertions, 19 deletions
@@ -13,25 +13,31 @@ Cursor::Cursor() : _angle(0.0), _xscale(1.0), _yscale(1.0), void Cursor::update() { LZR_MousePosition(&x, &y); + const bool _was_down(down || erase); down = LZR_BUTTON(MOUSE_L); erase = LZR_BUTTON(MOUSE_R); + if (!_was_down && (down || erase)) + LZR_PlaySound(3, 1); + else if (_was_down && !(down || erase)) + LZR_StopSound(3); if (erase) { _angle -= 1.0 / 16; _xscale = sin(float(LZR_GetTick()) * 2.0); _yscale = cos(float(LZR_GetTick()) * 3.0); while (_angle < -2.0) _angle += 1.0; + LZR_SetSoundPitch(3, 1.5); } else if (down) { _angle += 1.0 / 16; _xscale = 2.0 * sin(float(LZR_GetTick()) * 2.0); _yscale = 2.0 * cos(float(LZR_GetTick()) * 3.0); while (_angle > 2.0) _angle -= 1.0; + LZR_SetSoundPitch(3, 0.5); } else { - const double target_angle = 0.0; - _angle = target_angle - _angle * 0.1; - _xscale = 1.0 - _xscale * 0.1; - _yscale = 1.0 - _yscale * 0.1; + _angle += 0.003; + _xscale = sin(float(LZR_GetTick()) / 23); + _yscale = sin(float(LZR_GetTick()) / 17); } } @@ -44,8 +50,8 @@ void Cursor::draw() stg.scale_x = _xscale; stg.scale_y = _yscale; set_color(); - LZR_DrawImageEx(down || erase ? LZR_IMAGE("res/cursor_down.bmp") - : LZR_IMAGE("res/cursor_up.bmp"), + LZR_DrawImageEx((down || erase) ? LZR_IMAGE("res/cursor_down.bmp") + : LZR_IMAGE("res/cursor_up.bmp"), x, y, stg); } @@ -55,6 +61,21 @@ void Cursor::set_color() const LZR_DrawSetColor(rand() & 1, 0, rand() & 1, 1); else if (down) LZR_DrawSetColor(rand() & 1, rand() & 1, rand() & 1, 1); - else - LZR_DrawSetColor(1, 1, 1, (rand() & 3) != 0); + else { + float color = (1.0 + fabs(sin((float)LZR_GetTick() / 32))) / 2; + color *= color; + LZR_DrawSetColor(1.0 - color, color, 1.0 - color, 1); + } +} + +void Cursor::set_color(int) const +{ + if (erase) + LZR_DrawSetColor(rand() & 1, 0, rand() & 1, 1); + else if (down) + LZR_DrawSetColor(rand() & 1, rand() & 1, rand() & 1, 1); + else { + float color = rand() & 1; + LZR_DrawSetColor(1.0 - color, color, 1.0 - color, 1); + } } @@ -10,4 +10,5 @@ public: void update(); void draw(); void set_color() const; + void set_color(int) const; }; @@ -26,23 +26,23 @@ LDFLAGS := -lm $(shell $(SDL2-CFG) --libs) -lSDL2_mixer all: $(NAME) $(NAME): $(OBJ) - @printf '[ld] *.o -> %s\n' "$(NAME)" + @printf '[ld] *.o -> %s\n' "$(NAME)" @$(LD) -o $(NAME) $(OBJ) $(LDFLAGS) %.o: %.cpp - @printf '[c++] %s -> %s\n' "$<" "$@" + @printf '[c++] %-10s -> %s\n' "$<" "$@" @$(CCXX) $(CXXFLAGS) -c -o $@ $< %.win.o: %.cpp - @printf '[c++] %s -> %s\n' "$<" "$@" + @printf '[c++] %-10s -> %s\n' "$<" "$@" @$(CCXX) $(CXXFLAGS) -c -o $@ $< %.o: %.c - @printf '[cc] %s -> %s\n' "$<" "$@" + @printf '[cc] %-10s -> %s\n' "$<" "$@" @$(CC) $(CFLAGS) -c -o $@ $< %.win.o: %.c - @printf '[cc] %s -> %s\n' "$<" "$@" + @printf '[cc] %-10s -> %s\n' "$<" "$@" @$(CC) $(CFLAGS) -c -o $@ $< clean: @@ -30,16 +30,16 @@ void Table::update(const Cursor& cursor) const int y = cursor.y / _lane; if (y >= _height) return; - if (cursor.down) { + if (cursor.erase) { + _strength[_layer][y] = 0; + _edited = -1; + } else if (cursor.down) { if (y == _edited) _strength[_layer][y] += 2; else _strength[_layer][y] = 1; _notes[_layer][y] = util::min(CFG_DWIDTH - 1, util::max(0, cursor.x)); _edited = y; - } else if (cursor.erase) { - _strength[_layer][y] = 0; - _edited = -1; } else _edited = -1; _hovered = y; @@ -59,7 +59,7 @@ void Table::draw(const Cursor& cursor) LZR_DrawRectangle(true, 0, t * _lane, CFG_DWIDTH, _lane); } if (i == _hovered) { - cursor.set_color(); + cursor.set_color(int()); if (cursor.erase || (rand() & 3)) LZR_DrawRectangle(true, 0, y, CFG_DWIDTH, _lane); } @@ -19,11 +19,15 @@ int main(int argc, char **argv) char *snd_x = strchr(snd_path, 'x'); for (int i = 0; i < 3; i++) { *snd_x = '0' + i; - if (LZR_SoundLoad(snd_path, 1.0f) < 0) { + if (LZR_SoundLoad(snd_path, (i == 1) ? 0.8f : 1.0f) < 0) { LZR_Quit(); return 1; } } + if (LZR_SoundLoad("res/suk.wav", 0.5f) < 0) { + LZR_Quit(); + return 1; + } Cursor cursor; Table table; Menu menu; diff --git a/res/suk.wav b/res/suk.wav Binary files differnew file mode 100644 index 0000000..eb7d2be --- /dev/null +++ b/res/suk.wav |