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 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;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "PlayerStates.h"
|
||||
#include "Player.h"
|
||||
#include "Layers.h"
|
||||
#include "physics_world.h"
|
||||
|
||||
static inline
|
||||
|
@ -53,7 +54,7 @@ void PlayerAttackEnter(Player* self) {
|
|||
static
|
||||
void PlayerAttackTrigger(Player* self) {
|
||||
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) {
|
||||
PhysicsEntity entity = collider_get_owner(found);
|
||||
entity.message_receiver->handle_message(entity.data, 1, (void*)1u);
|
||||
|
|
|
@ -9,10 +9,10 @@ void play() {
|
|||
SpawnProp(MakeVector(2.f, 0.f),
|
||||
sprite_from_spritesheet(spritesheet_load("assets/bag.png", IVectorFrom(512)), 0),
|
||||
shape_new((Vector[]){
|
||||
MakeVector(-0.2, -0.075),
|
||||
MakeVector( 0.2, -0.075),
|
||||
MakeVector( 0.2, 0.075),
|
||||
MakeVector(-0.2, 0.075)
|
||||
MakeVector(-0.2f, -0.075f),
|
||||
MakeVector( 0.2f, -0.075f),
|
||||
MakeVector( 0.2f, 0.075f),
|
||||
MakeVector(-0.2f, 0.075f)
|
||||
}, 4),
|
||||
MakeVector(0.5f, .93f)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue