janet-lang / jaylib

Janet bindings to Raylib
MIT License
137 stars 36 forks source link

add get and put functions for camera2d abstract type #39

Closed AlecTroemel closed 1 year ago

AlecTroemel commented 2 years ago

able to do stuff like this

(my-camera2d :offset) 
(put my-camera2d :offset [2 3])
pepe commented 2 years ago

It seems to me (without any deeper knowledge) that the camera is Janet's abstract, so you can define get and set methods. I am on the phone now, but I will try to look at it tomorrow morning

AlecTroemel commented 2 years ago

I believe cameras are a raylib type, at least it shows up in the core examples https://github.com/raysan5/raylib/blob/master/examples/core/core_smooth_pixelperfect.c#L38

pepe commented 2 years ago

I mean this https://github.com/janet-lang/jaylib/blob/8cf87d8c80a10478fd0a9f2b7142dd68304868b2/src/types.h#L473. There, as you can see, the AT_Camera2D has only its name defined on abstract type. But you can register other methods, as seen in https://github.com/janet-lang/janet/blob/master/examples/numarray/numarray.c#L29, one of them setter and another getter.

AlecTroemel commented 2 years ago

:exploding_head: yep that's what I've been looking for how to do! Hopefully I'll have time to explore it later today

AlecTroemel commented 2 years ago

changes made!

AlecTroemel commented 1 year ago

@pepe I believe I've addressed all the feedback, a re-review would be greatly appreciated!

pepe commented 1 year ago

I will try to check it soon. But from what I see it looks fine.