summaryrefslogtreecommitdiff
path: root/Cursor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Cursor.cpp')
-rw-r--r--Cursor.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/Cursor.cpp b/Cursor.cpp
index cacc62e..95ccd4e 100644
--- a/Cursor.cpp
+++ b/Cursor.cpp
@@ -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);
+ }
}