| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file movable.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 15th January 2010: Created movable.cpp |
| 10 | * |
| 11 | * @par Licence: |
| 12 | * Copyright (c) 2010-2012 AJ Thomson |
| 13 | * |
| 14 | * OpenJazz is distributed under the terms of |
| 15 | * the GNU General Public License, version 2.0 |
| 16 | * |
| 17 | * @par Description: |
| 18 | * Contains the base class for all movable objects. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | #include "level.h" |
| 24 | #include "movable.h" |
| 25 | |
| 26 | |
| 27 | /** |
| 28 | * Derive the x-coordinate of the Movable relative to the view coordinates for |
| 29 | * the current time. |
| 30 | * |
| 31 | * @param change Time since last step |
| 32 | * |
| 33 | * @return The x-coordinate |
| 34 | */ |
| 35 | fixed Movable::getDrawX (int change) { |
| 36 | |
| 37 | return x + ((dx * change) >> 10) - viewX; |
| 38 | |
| 39 | } |
| 40 | |
| 41 | |
| 42 | /** |
| 43 | * Derive the y-coordinate of the Movable relative to the view coordinates for |
| 44 | * the current time. |
| 45 | * |
| 46 | * @param change Time since last step |
| 47 | * |
| 48 | * @return The y-coordinate |
| 49 | */ |
| 50 | fixed Movable::getDrawY (int change) { |
| 51 | |
| 52 | return y + ((dy * change) >> 10) - viewY; |
| 53 | |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * Get the basic x-coordinate of the Movable. |
| 59 | * |
| 60 | * @return The x-coordinate |
| 61 | */ |
| 62 | fixed Movable::getX () { |
| 63 | |
| 64 | return x; |
| 65 | |
| 66 | } |
| 67 | |
| 68 | |
| 69 | /** |
| 70 | * Get the basic y-coordinate of the Movable. |
| 71 | * |
| 72 | * @return The y-coordinate |
| 73 | */ |
| 74 | fixed Movable::getY () { |
| 75 | |
| 76 | return y; |
| 77 | |
| 78 | } |
| 79 | |
| 80 |