diff --git a/Makefile b/Makefile index 95fd776..1fdb041 100644 --- a/Makefile +++ b/Makefile @@ -8,18 +8,18 @@ LDLIBS := -lraylib -lasound -llibremidi -pthread LDFLAGS := -Llib -L/usr/lib -L/usr/local/lib SRCS := $(wildcard src/*.cpp) -HDRS := $(wildcard src/*.h) OBJECTS := $(patsubst src/%.cpp,build/%.o, $(SRCS)) +DEPENDS := $(patsubst src/%.cpp,build/%.d, $(SRCS)) viseq: $(OBJECTS) $(CXX) $(OBJECTS) -o $@ $(LDFLAGS) $(LDLIBS) -$(OBJECTS): build/%.o : src/%.cpp - @mkdir -p build - $(CXX) -c $< -o $@ $(CXXFLAGS) $(CXXINC) +-include $(DEPENDS) -src/%.cpp: $HDRS - touch $@ +#$(OBJECTS): build/%.o : src/%.cpp +build/%.o: src/%.cpp Makefile + @mkdir -p build + $(CXX) -c $< -o $@ $(CXXFLAGS) $(CXXINC) -MMD -MP clean: rm -f build/* diff --git a/src/button.h b/src/button.h index 2201441..a135e0d 100644 --- a/src/button.h +++ b/src/button.h @@ -14,8 +14,9 @@ inline bool ViButton(Vec2Df mp, float x, float y, float radius, Color color){ inline bool ViTexButton(Vec2Df mp, Vec2Df position, float rotation, float radius, Texture2D tex, Color color){ float scale = (radius*2.0f) / (float)tex.width; - Vec2Df center_pos = position - Vec2Df((tex.width*scale)/1.0f * sin(rotation), (tex.height*scale)/1.0f * cos(rotation)); + Vec2Df center_pos = position - Vec2Df((tex.width*scale) / 2.0f, (tex.height*scale) / 2.0f).rotate(rotation); DrawTextureEx(tex, center_pos, rotation, scale, color); + return (Vector2Distance(mp, position) < radius && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)); } diff --git a/src/vmath.h b/src/vmath.h index bad5018..ffabb80 100644 --- a/src/vmath.h +++ b/src/vmath.h @@ -57,6 +57,10 @@ namespace VISEQ::VMATH{ return Vec2D(-y, x); }; + Vec2D rotate(float deg){ + return Vec2D(cos(deg*DEG2RAD) * x, sin(deg*DEG2RAD) * y); + }; + Vec2D norm() { return *this / length();}; Vec2D center(Vec2D v){