Path: blob/master/SonicMania/Objects/Helpers/DrawHelpers.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: DrawHelpers Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectDrawHelpers *DrawHelpers = NULL;1011void DrawHelpers_Update(void) {}1213void DrawHelpers_LateUpdate(void) {}1415void DrawHelpers_StaticUpdate(void) {}1617void DrawHelpers_Draw(void) {}1819void DrawHelpers_Create(void *data) {}2021void DrawHelpers_StageLoad(void) {}2223void DrawHelpers_DrawHitboxOutline(int32 x, int32 y, Hitbox *hitbox, uint8 direction, uint32 color)24{25int16 left, top, right, bottom;2627if (direction & FLIP_X) {28right = -hitbox->right;29left = -hitbox->left;30}31else {32left = hitbox->left;33right = hitbox->right;34}3536if (direction & FLIP_Y) {37top = -hitbox->top;38bottom = -hitbox->bottom;39}40else {41top = hitbox->top;42bottom = hitbox->bottom;43}4445RSDK.DrawLine(x + (left << 16), y + (top << 16), x + (right << 16), y + (top << 16), color, 0xFF, INK_NONE, false);46RSDK.DrawLine(x + (right << 16), y + (top << 16), x + (right << 16), y + (bottom << 16), color, 0xFF, INK_NONE, false);47RSDK.DrawLine(x + (right << 16), y + (bottom << 16), x + (left << 16), y + (bottom << 16), color, 0xFF, INK_NONE, false);48RSDK.DrawLine(x + (left << 16), y + (bottom << 16), x + (left << 16), y + (top << 16), color, 0xFF, INK_NONE, false);49}5051void DrawHelpers_DrawArrowAdditive(int32 x1, int32 y1, int32 x2, int32 y2, uint32 color)52{53int32 angle = RSDK.ATan2(x1 - x2, y1 - y2);54RSDK.DrawLine(x1, y1, x2, y2, color, 0x7F, INK_ADD, false);55RSDK.DrawLine(x2, y2, x2 + (RSDK.Cos256(angle + 12) << 12), y2 + (RSDK.Sin256(angle + 12) << 12), color, 0x7F, INK_ADD, false);56RSDK.DrawLine(x2, y2, x2 + (RSDK.Cos256(angle - 12) << 12), y2 + (RSDK.Sin256(angle - 12) << 12), color, 0x7F, INK_ADD, false);57}5859void DrawHelpers_DrawIsocelesTriangle(int32 x1, int32 y1, int32 x2, int32 y2, int32 edgeSize, uint32 color, uint32 inkEffect, uint32 alpha)60{61Vector2 verts[3];6263int32 angle = RSDK.ATan2(x2 - x1, y2 - y1);6465verts[0].x = x2;66verts[0].y = y2;67verts[1].x = x1 + (edgeSize << 7) * RSDK.Cos256(angle + 64);68verts[1].y = y1 + (edgeSize << 7) * RSDK.Sin256(angle + 64);69verts[2].x = x1 + (edgeSize << 7) * RSDK.Cos256(angle - 64);70verts[2].y = y1 + (edgeSize << 7) * RSDK.Sin256(angle - 64);7172if (SceneInfo->inEditor) {73RSDK.DrawLine(x2, y2, verts[1].x, verts[1].y, color, 255, INK_NONE, false);74RSDK.DrawLine(verts[1].x, verts[1].y, verts[2].x, verts[2].y, color, 255, INK_NONE, false);75RSDK.DrawLine(verts[2].x, verts[2].y, x2, y2, color, 255, INK_NONE, false);76}77else {78int32 screenX = ScreenInfo->position.x << 16;79int32 screenY = ScreenInfo->position.y << 16;80verts[0].x -= screenX;81verts[0].y -= screenY;82verts[1].x -= screenX;83verts[1].y -= screenY;84verts[2].x -= screenX;85verts[2].y -= screenY;86RSDK.DrawFace(verts, 3, (color >> 16) & 0xFF, (color >> 8) & 0xFF, (color >> 0) & 0xFF, alpha, inkEffect);87}88}8990void DrawHelpers_DrawCross(int32 x, int32 y, int32 sizeX, int32 sizeY, uint32 color)91{92if (x || y) {93RSDK.DrawLine(x - (sizeX >> 1), y - (sizeY >> 1), x + (sizeX >> 1), y + (sizeY >> 1), color, 0x7F, INK_NONE, false);94RSDK.DrawLine(x + (sizeX >> 1), y - (sizeY >> 1), x - (sizeX >> 1), y + (sizeY >> 1), color, 0x7F, INK_NONE, false);95}96}9798// Custom ones!!99100// Adds alpha & ink effect in params for extra customizability101void DrawHelpers_DrawArrow(int32 x1, int32 y1, int32 x2, int32 y2, uint32 color, uint32 inkEffect, uint32 alpha)102{103int32 angle = RSDK.ATan2(x1 - x2, y1 - y2);104RSDK.DrawLine(x1, y1, x2, y2, color, alpha, inkEffect, false);105RSDK.DrawLine(x2, y2, x2 + (RSDK.Cos256(angle + 12) << 12), y2 + (RSDK.Sin256(angle + 12) << 12), color, alpha, inkEffect, false);106RSDK.DrawLine(x2, y2, x2 + (RSDK.Cos256(angle - 12) << 12), y2 + (RSDK.Sin256(angle - 12) << 12), color, alpha, inkEffect, false);107}108109void DrawHelpers_DrawRectOutline(int32 x, int32 y, int32 sizeX, int32 sizeY, uint32 color)110{111Vector2 drawPos;112113drawPos.x = x - (sizeX >> 1);114drawPos.y = y - (sizeY >> 1);115RSDK.DrawLine(drawPos.x - TO_FIXED(1), drawPos.y - TO_FIXED(1), drawPos.x + sizeX, drawPos.y - TO_FIXED(1), color, 0x00, INK_NONE, false);116RSDK.DrawLine(drawPos.x - TO_FIXED(1), drawPos.y + sizeY, drawPos.x + sizeX, drawPos.y + sizeY, color, 0x00, INK_NONE, false);117RSDK.DrawLine(drawPos.x - TO_FIXED(1), drawPos.y - TO_FIXED(1), drawPos.x - TO_FIXED(1), drawPos.y + sizeY, color, 0x00, INK_NONE, false);118RSDK.DrawLine(drawPos.x + sizeX, drawPos.y - TO_FIXED(1), drawPos.x + sizeX, drawPos.y + sizeY, color, 0x00, INK_NONE, false);119}120121void DrawHelpers_DrawArenaBounds(int32 left, int32 top, int32 right, int32 bottom, uint8 sideMasks, uint32 color)122{123RSDK_THIS_GEN();124125left <<= 16;126top <<= 16;127right <<= 16;128bottom <<= 16;129130// left131if (sideMasks & 1) {132RSDK.DrawLine(self->position.x + left, self->position.y + top, self->position.x + left, self->position.y + bottom, color, 0, INK_NONE, false);133}134135// top136if (sideMasks & 2) {137RSDK.DrawLine(self->position.x + left, self->position.y + top, self->position.x + right, self->position.y + top, color, 0, INK_NONE, false);138}139140// right141if (sideMasks & 4) {142RSDK.DrawLine(self->position.x + right, self->position.y + top, self->position.x + right, self->position.y + bottom, color, 0, INK_NONE,143false);144}145146// bottom147if (sideMasks & 8) {148RSDK.DrawLine(self->position.x + left, self->position.y + bottom, self->position.x + right, self->position.y + bottom, color, 0, INK_NONE,149false);150}151}152153#if GAME_INCLUDE_EDITOR154void DrawHelpers_EditorDraw(void) {}155156void DrawHelpers_EditorLoad(void) {}157#endif158159void DrawHelpers_Serialize(void) {}160161162