Skip to content

Conversation

GCodergr
Copy link
Contributor

@GCodergr GCodergr commented Sep 7, 2025

Added core_3d_camera_fps.odin example which is based on raylib core_3d_camera_fps.c.
The original c example is playable here .

Checklist before submitting:

  • This example has been added to .github/workflows/check.yml (for automatic testing)
  • This example compiles cleanly with flags -vet -strict-style -vet-tabs -disallow-do -warnings-as-errors
  • This example follows the core naming convention: https://github.com/odin-lang/Odin/wiki/Naming-Convention (exception can be made for ports of examples that need to match 1:1 to the original source).
  • By submitting, I understand that this example is made available under these licenses: Public Domain and Odin's BSD-3 license. Only for third-party dependencies are other licenses allowed.

Copy link
Collaborator

@karl-zylinski karl-zylinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Thanks for the PR.

There are a bunch of unnecessary type specifications that I think came along from the C code. Such as this:
hvelLength: f32 = rl.Vector3Length(hvel)

Just use hvelLength := rl.Vector3Length(hvel)

Also, there is some weird "type double dipping" happening, such as this:
desiredDir: rl.Vector3 = rl.Vector3 {

Just do
desiredDir := rl.Vector3 {

I've only given a comment once for a specific issue, but most of them happen multiple times, so please look through the file.

Also, I've set up a style guide for the examples repository. Future PRs will have it linked in the template: https://github.com/odin-lang/examples/wiki/Naming-and-style-convention

}
}

TOWER_SIZE: rl.Vector3 : rl.Vector3{16.0, 32.0, 16.0}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TOWER_SIZE :: rl.Vector3{16.0, 32.0, 16.0}

}
}

delta: f32 = rl.GetFrameTime()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use type inference delta := rl.GetFrameTime()

body.velocity.y -= GRAVITY * delta
}

if (body.isGrounded && jumpPressed) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra parens

// Draw game level
draw_level :: proc() {
FLOOR_EXTENT: int : 25
TILE_SIZE: f32 : 5.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just do TILE_SIZE :: 5. It'll implicitly cast correctly when you use it.

lookRotation.x -= mouseDelta.x * sensitivity.x
lookRotation.y += mouseDelta.y * sensitivity.y

sideway := i8(i8(rl.IsKeyDown(.D)) - i8(rl.IsKeyDown(.A)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are i8. The outer cast does nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants