fix(types): removed implicit type casts
This commit is contained in:
parent
f76cb2d57b
commit
2bf6bea14f
|
@ -39,7 +39,7 @@ void animation_sprite_draw(AnimationSprite* self, Transform* transform) {
|
||||||
const size_t frame_count = spritesheet_get_tile_count(self->sheet);
|
const size_t frame_count = spritesheet_get_tile_count(self->sheet);
|
||||||
const float time = game_time() - self->start_time;
|
const float time = game_time() - self->start_time;
|
||||||
|
|
||||||
size_t frame = time / self->frame_interval;
|
size_t frame = (size_t)(time / self->frame_interval);
|
||||||
|
|
||||||
switch(self->loop_mode) {
|
switch(self->loop_mode) {
|
||||||
case LoopMode_Hide:
|
case LoopMode_Hide:
|
||||||
|
|
|
@ -20,8 +20,9 @@ void _internal_open_keyboard() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
void _internal_open_controller(size_t id) {
|
void _internal_open_controller(int id) {
|
||||||
InputDevice* device = malloc(sizeof(InputDevice));
|
InputDevice* device = malloc(sizeof(InputDevice));
|
||||||
|
ASSERT_RETURN(device != NULL, , "Failed to allocate space for gamecontroller input device");
|
||||||
*device = (InputDevice) {
|
*device = (InputDevice) {
|
||||||
.listeners = NULL,
|
.listeners = NULL,
|
||||||
.type = InputDevice_Gamepad,
|
.type = InputDevice_Gamepad,
|
||||||
|
@ -42,8 +43,8 @@ void input_init() {
|
||||||
_internal_open_keyboard();
|
_internal_open_keyboard();
|
||||||
|
|
||||||
// open any controllers already available
|
// open any controllers already available
|
||||||
const size_t joystick_count = SDL_NumJoysticks();
|
const int joystick_count = SDL_NumJoysticks();
|
||||||
for(size_t i = 0; i < joystick_count; ++i) {
|
for(int i = 0; i < joystick_count; ++i) {
|
||||||
_internal_open_controller(i);
|
_internal_open_controller(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ int controlleraxis_is_changed_by(ControllerAxis* self, SDL_Event event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
InputEvent controlleraxis_evaluate(ControllerAxis* self, SDL_Event event) {
|
InputEvent controlleraxis_evaluate(ControllerAxis* self, SDL_Event event) {
|
||||||
float result = (float)event.caxis.value / 32767.0;
|
float result = (float)event.caxis.value / 32767.0f;
|
||||||
return (InputEvent) {
|
return (InputEvent) {
|
||||||
.type = InputEvent_Float,
|
.type = InputEvent_Float,
|
||||||
.as_float = result
|
.as_float = result
|
||||||
|
@ -116,19 +116,19 @@ InputEvent _internal_event_to_type(InputEventType type, InputEvent event) {
|
||||||
LOG_ERROR("No (1)");
|
LOG_ERROR("No (1)");
|
||||||
break;
|
break;
|
||||||
case InputEvent_Bool:
|
case InputEvent_Bool:
|
||||||
as_float = event.as_bool;
|
as_float = (float)event.as_bool;
|
||||||
break;
|
break;
|
||||||
case InputEvent_Float:
|
case InputEvent_Float:
|
||||||
as_float = event.as_float;
|
as_float = event.as_float;
|
||||||
break;
|
break;
|
||||||
case InputEvent_Int:
|
case InputEvent_Int:
|
||||||
as_float = event.as_int;
|
as_float = (float)event.as_int;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
event.type = type;
|
event.type = type;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case InputEvent_Int:
|
case InputEvent_Int:
|
||||||
event.as_int = round(as_float);
|
event.as_int = (int)round(as_float);
|
||||||
return event;
|
return event;
|
||||||
case InputEvent_Float:
|
case InputEvent_Float:
|
||||||
event.as_float = as_float;
|
event.as_float = as_float;
|
||||||
|
|
|
@ -72,7 +72,7 @@ void physics_entity_solve_contacts(PhysicsEntity self, List* contacts) {
|
||||||
float dot = vdotf(dir, vel);
|
float dot = vdotf(dir, vel);
|
||||||
|
|
||||||
if(dot < 0)
|
if(dot < 0)
|
||||||
vel = vsubf(vel, vmulff(dir, dot * (1.0 + rigidbody_get_bounce(body))));
|
vel = vsubf(vel, vmulff(dir, dot * (1.0f + rigidbody_get_bounce(body))));
|
||||||
|
|
||||||
rigidbody_set_velocity(body, vel);
|
rigidbody_set_velocity(body, vel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,10 @@ void render_calculate_render_area() {
|
||||||
// calculate the largest area that will fit the entire rendertexture into the window space
|
// calculate the largest area that will fit the entire rendertexture into the window space
|
||||||
g_render_area = (SDL_Rect) {0, 0, window_resolution.x, window_resolution.y};
|
g_render_area = (SDL_Rect) {0, 0, window_resolution.x, window_resolution.y};
|
||||||
if(window_aspect <= target_aspect) {
|
if(window_aspect <= target_aspect) {
|
||||||
g_render_area.h = window_resolution.x / target_aspect;
|
g_render_area.h = (int)((float)window_resolution.x / target_aspect);
|
||||||
g_render_area.y = (window_resolution.y - g_render_area.h) / 2;
|
g_render_area.y = (window_resolution.y - g_render_area.h) / 2;
|
||||||
} else {
|
} else {
|
||||||
g_render_area.w = window_resolution.y * target_aspect;
|
g_render_area.w = (int)((float)window_resolution.y * target_aspect);
|
||||||
g_render_area.x += (window_resolution.x - g_render_area.w) / 2;
|
g_render_area.x += (window_resolution.x - g_render_area.w) / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,11 +84,11 @@ void _internal_debug_draw_collision_edge(RigidBody* self, Contact* contact) {
|
||||||
Vector b = camera_world_to_pixel_point(&g_camera, right);
|
Vector b = camera_world_to_pixel_point(&g_camera, right);
|
||||||
Vector n = transform_direction(&g_camera.transform, contact->hit.normal);
|
Vector n = transform_direction(&g_camera.transform, contact->hit.normal);
|
||||||
SDL_SetRenderDrawColor(g_renderer, 255, 2, 255, 255);
|
SDL_SetRenderDrawColor(g_renderer, 255, 2, 255, 255);
|
||||||
SDL_RenderDrawLine(g_renderer, a.x, a.y, b.x, b.y);
|
SDL_RenderDrawLineF(g_renderer, a.x, a.y, b.x, b.y);
|
||||||
a = camera_world_to_pixel_point(&g_camera, point);
|
a = camera_world_to_pixel_point(&g_camera, point);
|
||||||
b = vaddf(a, vmulff(n, 100.f));
|
b = vaddf(a, vmulff(n, 100.f));
|
||||||
SDL_SetRenderDrawColor(g_renderer, 255, 0, 0, 255);
|
SDL_SetRenderDrawColor(g_renderer, 255, 0, 0, 255);
|
||||||
SDL_RenderDrawLine(g_renderer, a.x, a.y, b.x, b.y);
|
SDL_RenderDrawLineF(g_renderer, a.x, a.y, b.x, b.y);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ Vector _shape_calculate_mean(Shape* self) {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
list_foreach(Vector*, point, &self->points) {
|
list_foreach(Vector*, point, &self->points) {
|
||||||
++count;
|
++count;
|
||||||
avg = vaddf(avg, vmulff(*point, 1.0/count));
|
avg = vaddf(avg, vmulff(*point, 1.f/count));
|
||||||
}
|
}
|
||||||
|
|
||||||
return avg;
|
return avg;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "PlayerStates.h"
|
#include "PlayerStates.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "Layers.h"
|
||||||
#include "physics_world.h"
|
#include "physics_world.h"
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
|
@ -53,7 +54,7 @@ void PlayerAttackEnter(Player* self) {
|
||||||
static
|
static
|
||||||
void PlayerAttackTrigger(Player* self) {
|
void PlayerAttackTrigger(Player* self) {
|
||||||
Collider* found = physics_world_box_query(vaddf(self->transform.position, MakeVector(self->facing * (0.2f + 0.1f), 0.f)),
|
Collider* found = physics_world_box_query(vaddf(self->transform.position, MakeVector(self->facing * (0.2f + 0.1f), 0.f)),
|
||||||
MakeVector(0.1f, 0.06f), PHYSICS_LAYER_DEFAULT, self->rigidbody);
|
MakeVector(0.1f, 0.06f), PHYSICS_LAYER_COMBAT, self->rigidbody);
|
||||||
if(found != NULL) {
|
if(found != NULL) {
|
||||||
PhysicsEntity entity = collider_get_owner(found);
|
PhysicsEntity entity = collider_get_owner(found);
|
||||||
entity.message_receiver->handle_message(entity.data, 1, (void*)1u);
|
entity.message_receiver->handle_message(entity.data, 1, (void*)1u);
|
||||||
|
|
|
@ -9,10 +9,10 @@ void play() {
|
||||||
SpawnProp(MakeVector(2.f, 0.f),
|
SpawnProp(MakeVector(2.f, 0.f),
|
||||||
sprite_from_spritesheet(spritesheet_load("assets/bag.png", IVectorFrom(512)), 0),
|
sprite_from_spritesheet(spritesheet_load("assets/bag.png", IVectorFrom(512)), 0),
|
||||||
shape_new((Vector[]){
|
shape_new((Vector[]){
|
||||||
MakeVector(-0.2, -0.075),
|
MakeVector(-0.2f, -0.075f),
|
||||||
MakeVector( 0.2, -0.075),
|
MakeVector( 0.2f, -0.075f),
|
||||||
MakeVector( 0.2, 0.075),
|
MakeVector( 0.2f, 0.075f),
|
||||||
MakeVector(-0.2, 0.075)
|
MakeVector(-0.2f, 0.075f)
|
||||||
}, 4),
|
}, 4),
|
||||||
MakeVector(0.5f, .93f)
|
MakeVector(0.5f, .93f)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue