Changed function names to CamelCase

This commit is contained in:
Igor Łempicki 2023-03-24 22:09:18 +01:00
parent 8fa824a7a7
commit 58f1dbad74
3 changed files with 11 additions and 12 deletions

View File

@ -39,7 +39,6 @@ pub fn main() anyerror!void
var player: obj.Player = .{
.box = .{ .x = 20, .y = 300, .width = 20, .height = 20 },
.detection_box = .{ .width = 21, .height = 21 },
.velocity = .{ .x = 0, .y = 0 },
};
@ -67,14 +66,14 @@ pub fn main() anyerror!void
if (fly) {
if (rl.IsKeyDown(rl.KeyboardKey.KEY_UP)) { player.velocity.y += 1.5; }
if (rl.IsKeyDown(rl.KeyboardKey.KEY_DOWN)) { player.velocity.y -= 1.5; }
phs.movement.free_fly(&player);
phs.movement.FreeFly(&player);
} else {
if (rl.IsKeyPressed(rl.KeyboardKey.KEY_UP)) { player.velocity.y = 15; } // jump
phs.apply_forces(&player);
phs.ApplyForces(&player);
}
// run collisions
phs.apply_player_collisions(&player, map);
phs.ApplyPlayerCollisions(&player, map);
// camera setup
camera.target = rl.Vector2 { .x = player.box.x + player.box.width / 2, .y = player.box.y + player.box.height / 2 };

View File

@ -8,7 +8,7 @@ const FRICTION: f32 = 10;
pub fn apply_forces(player: *obj.Player) void {
pub fn ApplyForces(player: *obj.Player) void {
// apply gravity
player.velocity.y += GRAVITY * rl.GetFrameTime();
player.box.y -= player.velocity.y;
@ -25,7 +25,7 @@ pub fn apply_forces(player: *obj.Player) void {
}
pub const movement = struct {
pub fn free_fly(player: *obj.Player) void {
pub fn FreeFly(player: *obj.Player) void {
// apply friction for X
if (player.velocity.x > 0) { player.velocity.x -= FRICTION * rl.GetFrameTime(); }
if (player.velocity.x < 0) { player.velocity.x += FRICTION * rl.GetFrameTime(); }
@ -46,7 +46,7 @@ pub fn apply_forces(player: *obj.Player) void {
pub fn apply_player_collisions(player: *obj.Player, map: obj.Map) void {
pub fn ApplyPlayerCollisions(player: *obj.Player, map: obj.Map) void {
// for every tile
for (map.tiles) |tile| {

View File

@ -7,15 +7,15 @@ pub const Object = struct {
pub const Player = struct {
box: rl.Rectangle,
detection_box: NullOriginBox,
// detection_box: NullOriginBox,
velocity: rl.Vector2,
// max_velocity: f32,
};
const NullOriginBox = struct {
height: f32,
width: f32
};
// const NullOriginBox = struct {
// height: f32,
// width: f32
// };
pub const Map = struct {
tiles: []Object,