- How do I properly rotate sprites
- 24 Jan 2021 11:23:23 pm
- Last edited by Alvajoy123 on 26 Jan 2021 09:06:04 pm; edited 5 times in total
I know how to rotate sprite "lol". I just need to help an issue.
I have been recently working on a library/engine. But I've been having issues rotating sprites.
I have a struct with "gfx_sprite_t" sprite ... it's best if I show you:
gfx3.h
Code:
gfx3.c
Code:
I want the rotation to be optimized. The code obviously doesn't work ... I need help
I have been recently working on a library/engine. But I've been having issues rotating sprites.
I have a struct with "gfx_sprite_t" sprite ... it's best if I show you:
gfx3.h
Code:
#ifndef GFX3_H
#define GFX3_H
struct gfx3_object_t{
bool active;
gfx_sprite_t *layers[50];
int offset[2]; // [x, y]
uint8_t scale[2]; // [xs, ys]
uint8_t Max_Layers;
}gfx3_object[30];
// extern struct gfx3_object_t gfx3_object[30];
... // removed other functions odd reasons <_<
// Object rotation
void gfx3_RotateObjectCC(uint8_t index);
void gfx3_RotateObjectC(uint8_t index);
void gfx3_SetObjectAngle(uint8_t angle, uint8_t index);
...
#endif
}
gfx3.c
Code:
// By: Alvajoy"Alvajoy"123
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>
// Standard headers
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Graphic libs
#include <graphx.h>
// My Headers
#include "gfx3/gfx3.h"
// gfx_sprite_t *temp_layer;
gfx_UninitedSprite(temp_layer, 70, 70);
.... // other fuction not needed
void gfx3_RotateObjectC(uint8_t index){
int i;
for (i = 0; i > gfx3_object[index].Max_Layers; i++){
// gfx_UninitedSprite(layer_buffer, gfx3_object[index].layers[i]->width, gfx3_object[index].layers[i]->);
gfx3_object[index].layers[i] = gfx_RotateSpriteCC(gfx3_object[index].layers[i], temp_layer);
}
return;
}
I want the rotation to be optimized. The code obviously doesn't work ... I need help