diff options
author | Logan Hunt <loganthebean222@gmail.com> | 2020-08-10 14:04:44 -0600 |
---|---|---|
committer | Logan Hunt <loganthebean222@gmail.com> | 2020-08-10 14:04:44 -0600 |
commit | e09a23f0a4f342aa83854ce8cc11aacc09e350fd (patch) | |
tree | 07e8b8365705d9df134e59fa2a0215ba1d902c35 /include | |
parent | 7f856467a086ec9a3ebd1ccdf12e578dffb9c98b (diff) | |
download | geometry-dash-gba-e09a23f0a4f342aa83854ce8cc11aacc09e350fd.tar.gz geometry-dash-gba-e09a23f0a4f342aa83854ce8cc11aacc09e350fd.zip |
Added rotation
Diffstat (limited to 'include')
-rw-r--r-- | include/.playerObject.h.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | include/playerObject.h | 56 | ||||
-rw-r--r-- | include/sinlut.h | 15 | ||||
-rw-r--r-- | include/toolbox.h | 2 |
4 files changed, 24 insertions, 49 deletions
diff --git a/include/.playerObject.h.swp b/include/.playerObject.h.swp Binary files differdeleted file mode 100644 index 00a18a7..0000000 --- a/include/.playerObject.h.swp +++ /dev/null diff --git a/include/playerObject.h b/include/playerObject.h index 9394c4f..7feb894 100644 --- a/include/playerObject.h +++ b/include/playerObject.h @@ -3,6 +3,7 @@ #include "velocity.h" #include "toolbox.h" #include "fixed.h" +#include "sinlut.h" #ifndef PLAYEROBJECT_H #define PLAYEROBJECT_H @@ -14,60 +15,17 @@ typedef struct playerObject { POINT pt; u32 rotation; // Rotation amount OBJ_ATTR *obj; // Attributes of the object for GBA + OBJ_AFFINE *affine; // Affine transformations int pallete_bank; // Index of pallete int tile_id; // Index of player tile int isJumping; } ALIGN(4) playerObject; // Word-align to ensure corruption doesn't occur -static inline void initializePlayerObject (playerObject *object) { - // Initialize the point and velocity of an object - object->vel = createVelocity(0, 0); - object->pt = createPoint(20 << FIX_SHIFT, 100 << FIX_SHIFT); -} +void initializePlayerObject(); +playerObject createPlayerObject(); +void applyGravity(); +void scalePlayer(); +void updatePlayer(); -static inline playerObject createPlayerObject (OBJ_ATTR *obj_buffer, int pallete_bank, int tile_id) { - // Create a player object from data - playerObject temp; - initializePlayerObject(&temp); - temp.rotation = 0; - temp.obj = obj_buffer; - temp.pallete_bank = pallete_bank; - temp.tile_id = tile_id; - temp.isJumping = 0; - obj_set_attr(temp.obj, - ATTR0_SQUARE, // Set attribute 1 to be a square - ATTR1_SIZE_16, // Set size to 16 x 16 - ATTR2_PALBANK(pallete_bank) | tile_id // Which pallete to use, as we are in - // 16-color mode - ); - obj_set_pos(temp.obj, temp.pt.x >> FIX_SHIFT, temp.pt.y >> FIX_SHIFT); - return temp; -} - -static inline void applyGravity (playerObject *object) { - // Apply a gravity constant to a player - object->vel.dy += float_to_fixed(GRAVITY); - // This is a weird convention to have gravity in the positive direction, - // but I don't want to deal with coordinate changing. Too lazy -} - -static inline void updatePlayer (playerObject *object, u32 GROUND_LEVEL) { - // Update the position of a player object - updatePoint(&object->pt, &object->vel); - if (object->pt.y >> FIX_SHIFT >= GROUND_LEVEL) { - // Only apply gravity if player is not touching the ground - object->isJumping = 0; - object->pt.y = GROUND_LEVEL << FIX_SHIFT; // Don't go through ground - object->vel.dy = 0; - } - else { - object->isJumping = 1; - applyGravity(object); - } - // Update the player object's attributes' position - obj_set_pos(object->obj, object->pt.x >> FIX_SHIFT, object->pt.y >> FIX_SHIFT); - // Update the player's second attribute (tile and pallete bank) - object->obj->attr2 = ATTR2_BUILD(object->tile_id, object->pallete_bank, 0); -} #endif // PLAYEROBJECT_H diff --git a/include/sinlut.h b/include/sinlut.h new file mode 100644 index 0000000..126679f --- /dev/null +++ b/include/sinlut.h @@ -0,0 +1,15 @@ +#include "types.h" + +#ifndef SINLUT_H +#define SINLUT_H + +extern const short sin_lut[512]; + +static inline s32 lu_sin(u32 theta) +{ return sin_lut[(theta>>7)&0x1FF]; } + +//! Look-up a cosine value +static inline s32 lu_cos(u32 theta) +{ return sin_lut[((theta>>7)+128)&0x1FF]; } + +#endif //SINLUT_H diff --git a/include/toolbox.h b/include/toolbox.h index 064f0a3..b233374 100644 --- a/include/toolbox.h +++ b/include/toolbox.h @@ -69,6 +69,8 @@ INLINE void obj_set_pos(OBJ_ATTR *obj, int x, int y); INLINE void obj_hide(OBJ_ATTR *oatr); INLINE void obj_unhide(OBJ_ATTR *obj, u16 mode); void obj_copy(OBJ_ATTR *dst, const OBJ_ATTR *src, u32 count); +void obj_affine_copy(OBJ_AFFINE *dst, const OBJ_AFFINE *src, u32 count); +void obj_affine_identity(OBJ_AFFINE *aff); // === INLINES ======================================================== |