[canvas example] fixed movement

This commit is contained in:
Martin Fouilleul 2023-03-13 15:53:35 +01:00
parent 13f025ab21
commit 6da2494c81
1 changed files with 6 additions and 17 deletions

View File

@ -105,35 +105,24 @@ int main()
{
if(event.key.action == MP_KEY_PRESS || event.key.action == MP_KEY_REPEAT)
{
f32 factor = (event.key.mods & MP_KEYMOD_SHIFT) ? 10 : 1;
if(event.key.code == MP_KEY_LEFT)
{
if(x - 200 > 0)
{
x-=0.3;
}
x-=0.3*factor;
}
else if(event.key.code == MP_KEY_RIGHT)
{
if(x + 200 < contentRect.w)
{
x+=0.3;
}
x+=0.3*factor;
}
else if(event.key.code == MP_KEY_UP)
{
if(y + 200 < contentRect.h)
{
y-=0.3;
}
y-=0.3*factor;
}
else if(event.key.code == MP_KEY_DOWN)
{
if(y - 200 > 0)
{
y+=0.3;
}
y+=0.3*factor;
}
//*/
}
} break;