mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-26 13:09:56 +03:00
Small script change and API change.
This commit is contained in:
parent
637879a5b3
commit
80b473965e
5 changed files with 29 additions and 25 deletions
|
@ -20,10 +20,10 @@ bool update(float dt) {
|
|||
// The sprite should be updated every frame, regardless of whether it is running.
|
||||
sprite.update(dt);
|
||||
// Get some basic info about the mouse.
|
||||
auto mouseDistance = sprite.position.distanceTo(mouseScreenPosition);
|
||||
auto mouseDirection = sprite.position.directionTo(mouseScreenPosition);
|
||||
auto mouseDistance = sprite.position.distanceTo(mouse);
|
||||
auto mouseDirection = sprite.position.directionTo(mouse);
|
||||
// Move the sprite around in a smooth way.
|
||||
sprite.followPositionWithSlowdown(mouseScreenPosition, 0.2);
|
||||
sprite.followPositionWithSlowdown(mouse, 0.2);
|
||||
|
||||
// Play the right animation.
|
||||
auto isWaiting = mouseDistance < 0.2;
|
||||
|
@ -55,7 +55,7 @@ bool update(float dt) {
|
|||
|
||||
// Draw the sprite, the mouse position and some info.
|
||||
drawSprite(atlas, sprite, options);
|
||||
drawVec2(mouseScreenPosition, 8, isWaiting ? blank : white.alpha(150));
|
||||
drawVec2(mouse, 8, isWaiting ? blank : white.alpha(150));
|
||||
drawDebugText("Press 1, 2 or 3 to change the character.", Vec2(8));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ bool update(float dt) {
|
|||
if (isWindowResized) viewport.resize(resolutionWidth / 2, resolutionHeight / 2);
|
||||
// Draw the mouse position inside the viewport.
|
||||
auto viewportCenter = viewport.size * Vec2(0.5);
|
||||
auto viewportMousePosition = mouseScreenPosition - Rect(resolution * Vec2(0.5), viewport.size).centerArea.position;
|
||||
auto viewportMousePosition = mouse - Rect(resolution * Vec2(0.5), viewport.size).centerArea.position;
|
||||
viewport.attach();
|
||||
drawVec2(viewportCenter, 20);
|
||||
drawVec2(viewportMousePosition, 20);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue