From 4f8a7dcf0b9912df20cebc01b4e364845471aed7 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Sat, 17 Apr 2004 15:21:50 +0000 Subject: [PATCH] Added inverse functions for speed. Might be usefull for someone that wants to make enemies to change directions when colliding with each other. SVN-Revision: 545 --- src/physic.cpp | 10 ++++++++++ src/physic.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/physic.cpp b/src/physic.cpp index 232475d69..243e8cf1b 100644 --- a/src/physic.cpp +++ b/src/physic.cpp @@ -41,6 +41,16 @@ Physic::set_velocity(float nvx, float nvy) vy = -nvy; } +void Physic::inverse_velocity_x() +{ +vx = -vx; +} + +void Physic::inverse_velocity_y() +{ +vy = -vy; +} + float Physic::get_velocity_x() { diff --git a/src/physic.h b/src/physic.h index 37b6302ff..81e44518f 100644 --- a/src/physic.h +++ b/src/physic.h @@ -28,6 +28,10 @@ public: /** sets velocity to a fixed value */ void set_velocity(float vx, float vy); + /** velocities invertion */ + void inverse_velocity_x(); + void inverse_velocity_y(); + float get_velocity_x(); float get_velocity_y(); -- 2.11.0