dragging works. introducing connectors maybe
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "interactable.h"
|
||||
#include "moveable.h"
|
||||
#include "vmath.h"
|
||||
|
||||
namespace VISEQ::BASE {
|
||||
class Draggable : public Movable, public Interactable{
|
||||
public:
|
||||
Draggable() {}
|
||||
Draggable(float x, float y) : Movable(Vec2Df(x, y), 960.0f) {}
|
||||
Draggable(Vec2Df p) : Movable(p, 960.0f) {}
|
||||
virtual ~Draggable() {}
|
||||
|
||||
Vec2Df drag_offset;
|
||||
|
||||
bool picked_up = false;
|
||||
|
||||
virtual bool pickedUp() {
|
||||
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
|
||||
if(clicked() && held()) {
|
||||
picked_up = true;
|
||||
drag_offset = position - mp;
|
||||
}
|
||||
return picked_up;
|
||||
}
|
||||
|
||||
virtual void drag() {
|
||||
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
|
||||
position = mp + drag_offset;
|
||||
}
|
||||
|
||||
virtual void putDown(){
|
||||
picked_up = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user