fix(types): removed implicit type casts
This commit is contained in:
parent
f76cb2d57b
commit
2bf6bea14f
9 changed files with 21 additions and 19 deletions
|
|
@ -39,7 +39,7 @@ void animation_sprite_draw(AnimationSprite* self, Transform* transform) {
|
|||
const size_t frame_count = spritesheet_get_tile_count(self->sheet);
|
||||
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) {
|
||||
case LoopMode_Hide:
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ void _internal_open_keyboard() {
|
|||
}
|
||||
|
||||
static inline
|
||||
void _internal_open_controller(size_t id) {
|
||||
void _internal_open_controller(int id) {
|
||||
InputDevice* device = malloc(sizeof(InputDevice));
|
||||
ASSERT_RETURN(device != NULL, , "Failed to allocate space for gamecontroller input device");
|
||||
*device = (InputDevice) {
|
||||
.listeners = NULL,
|
||||
.type = InputDevice_Gamepad,
|
||||
|
|
@ -42,8 +43,8 @@ void input_init() {
|
|||
_internal_open_keyboard();
|
||||
|
||||
// open any controllers already available
|
||||
const size_t joystick_count = SDL_NumJoysticks();
|
||||
for(size_t i = 0; i < joystick_count; ++i) {
|
||||
const int joystick_count = SDL_NumJoysticks();
|
||||
for(int i = 0; i < joystick_count; ++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) {
|
||||
float result = (float)event.caxis.value / 32767.0;
|
||||
float result = (float)event.caxis.value / 32767.0f;
|
||||
return (InputEvent) {
|
||||
.type = InputEvent_Float,
|
||||
.as_float = result
|
||||
|
|
@ -116,19 +116,19 @@ InputEvent _internal_event_to_type(InputEventType type, InputEvent event) {
|
|||
LOG_ERROR("No (1)");
|
||||
break;
|
||||
case InputEvent_Bool:
|
||||
as_float = event.as_bool;
|
||||
as_float = (float)event.as_bool;
|
||||
break;
|
||||
case InputEvent_Float:
|
||||
as_float = event.as_float;
|
||||
break;
|
||||
case InputEvent_Int:
|
||||
as_float = event.as_int;
|
||||
as_float = (float)event.as_int;
|
||||
break;
|
||||
}
|
||||
event.type = type;
|
||||
switch(type) {
|
||||
case InputEvent_Int:
|
||||
event.as_int = round(as_float);
|
||||
event.as_int = (int)round(as_float);
|
||||
return event;
|
||||
case InputEvent_Float:
|
||||
event.as_float = as_float;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ void physics_entity_solve_contacts(PhysicsEntity self, List* contacts) {
|
|||
float dot = vdotf(dir, vel);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,10 +62,10 @@ void render_calculate_render_area() {
|
|||
// 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};
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 n = transform_direction(&g_camera.transform, contact->hit.normal);
|
||||
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);
|
||||
b = vaddf(a, vmulff(n, 100.f));
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ Vector _shape_calculate_mean(Shape* self) {
|
|||
size_t count = 0;
|
||||
list_foreach(Vector*, point, &self->points) {
|
||||
++count;
|
||||
avg = vaddf(avg, vmulff(*point, 1.0/count));
|
||||
avg = vaddf(avg, vmulff(*point, 1.f/count));
|
||||
}
|
||||
|
||||
return avg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue