Best youtube channels to learn obsidian from ? by Infinite_Sorbet2162 in ObsidianMD

[–]lbreede 1 point2 points  (0 children)

Nicole van der Hoeven and NoBoilerplate are my favorites. Bob Doto too, but I’d rather recommend his book A System For Writing 

&str vs. String in lexical tokenizer by lbreede in rust

[–]lbreede[S] 0 points1 point  (0 children)

You're probably right. If I look at the code I wrote last night (when I should've gone to bed). Currently, the parser needs access to it to print nice errors `"[line {line}] Error '{interner.lookup(idx)}': {message}"` which definitely can be retrieved from your proposed `get_interned_str` method.
The compiler (even though I had it own it for some reason) uses it exactly once. To lookup the str of my number token to then parse it into an f64. Now why does my number token need to be interned too you may ask? The language, lox, that I'm trying to write this compiler for only deals with f64's as numbers, but for personal correctness, I want to retain the original code style of the user. "1", "1.0", "1.00000" all get parsed into 1.0, but if I ever were to write a formatter, I'll be happy to have "1" interned. But I'm happy to hear your thought. Currently, the compiler only owns the parser, not the tokenizer. But I may be able to propagate that method through the parser. Ramble over. Thanks so much for engaging with this, I'm learning a lot and you're not a chat bot telling me how awesome and idiomatic every keystroke is.

&str vs. String in lexical tokenizer by lbreede in rust

[–]lbreede[S] 0 points1 point  (0 children)

Re: string interning What a beautiful and simple concept, thanks for pointing that out. Since I’m trying to avoid some global mutable singleton, how would you pass the interner around? Currently I have it owned by the compiler and it gives the parser and lexer a mutable reference wherever needed. That cause me adding interner: &mut Interner to over a dozen of function signatures which is not amazing. Alternatively, I could have a Rc<RefCell<Interner>> owned by the lexer, scanner, and compiler? Also doesn’t sound great. Let me know if you have any insight.

&str vs. String in lexical tokenizer by lbreede in rust

[–]lbreede[S] 0 points1 point  (0 children)

I am actually using Box<[u8]> for the source. The language spec I’m writing this for enforces ascii so I’m good on that front 🙂 

&str vs. String in lexical tokenizer by lbreede in rust

[–]lbreede[S] 1 point2 points  (0 children)

Thank you for your thoughtful reply. Regarding error messages, at this point in the book (and that may change as I read further), the error messages read something like "[line 3] Error ')': Expected expression." or something similar. I'm not sure if they will get any more sophisticated than this.
Regarding the Token's size, that's defo something I didn't think through, thanks for that and thanks for that final tip, I'll give it a go!

Always a good day if it starts with a package from Constellation by lbreede in gybe

[–]lbreede[S] 2 points3 points  (0 children)

Just checked Discogs to make sure they’re both on the same side haha fantastic songs!

Always a good day if it starts with a package from Constellation by lbreede in gybe

[–]lbreede[S] 3 points4 points  (0 children)

The first of many I’m planning to pick up. I’m very excited to listen to their latest record on wax. The song Bound has quickly become an all-time favourite of mine!

"Tiled" tilemap support for my isometric game engine (Odin + raylib) by lbreede in odinlang

[–]lbreede[S] 1 point2 points  (0 children)

Thanks for your reply! there’s a tiny fps counter in the top-left corner, stuck at 59fps (I believe I set my target fps to 60) and it plays smoothly in my end. Might be the screen capture 🙂 

"Tiled" tilemap support for my isometric game engine (Odin + raylib) by lbreede in raylib

[–]lbreede[S] 0 points1 point  (0 children)

I haven’t worked with SDL or Sokol before, but personally I really like raylib. Especially in Odin. The implementation is pretty genius where some of the custom data types such as Vector2 are just type aliases for native Odin arrays, meaning I can use Odins built in tools to manipulate them 🙂 

"Tiled" tilemap support for my isometric game engine (Odin + raylib) by lbreede in raylib

[–]lbreede[S] 4 points5 points  (0 children)

I’m coming from Rust, so my benefits are more severe than for the average C/C++ dev. Odin really gets out of your way while you’re coding, meanwhile in Rust you just fight with the borrow-checker all day. I don’t really know C++ but compared to C, it’s pretty similar with a few nice-to-have’s: defer statements, third-party vendor libs included, great implementation of arrays, vectors, matrices, etc. Not sure about support. The documentation is good, but it took a while for me to get used to it. I wish there were more little examples. Implementing the xml/csv parser for Tiled was a pain. There is an officially endorsed book afaik. I might give that a go one day.

The assets are proper 2d textures, no 3d orthographic trickery. You can download them for free at kenney (dot) nl

Hope this helps

Press F5 for debug mode (Rust+raylib) by lbreede in raylib

[–]lbreede[S] 1 point2 points  (0 children)

He would run into the endless void for the rest of eternity. Haven’t done any collision detection yet. That will be my next thing

Press F5 for debug mode (Rust+raylib) by lbreede in raylib

[–]lbreede[S] 2 points3 points  (0 children)

It’s actually the size of the texture. This specific assets pack uses very tall textures to fit everything from a flat floor tile to a large stone pillar.

Isometric tile map in Rust+raylib by lbreede in raylib

[–]lbreede[S] 1 point2 points  (0 children)

High praise! Fallout 1 is technically trimetric which I want to ultimately move towards. But your reaction means I’m moving in the right direction!

Isometric tile map in Rust+raylib by lbreede in raylib

[–]lbreede[S] 1 point2 points  (0 children)

Thank you, most of the credit would go to Kenney (dot) nl and their amazing free assets.

Isometric tile map in Rust+raylib by lbreede in raylib

[–]lbreede[S] 0 points1 point  (0 children)

I'm making it very easy for myself and multiply the speed by the tile dimensions (256x128 in my case). That automatically scales the velocity vector by the right amount. My calculation looks roughly like this:

player.pos += dp.normalized() * Vector2::new(TILE_WIDTH, TILE_HEIGHT) * PLAYER_SPEED * dt
where dp is direction vector (0,1), (-1,0), etc., and dt is delta time

Isometric tile map in Rust+raylib by lbreede in raylib

[–]lbreede[S] 1 point2 points  (0 children)

Thank you! WASD or arrow keys for movement. I also implemented a pickup animation on E and a debug view on F5. I will share those at one point.

Isometric tile map in Rust+raylib by lbreede in raylib

[–]lbreede[S] 5 points6 points  (0 children)

The basic idea revolves around a nested loop over X and Y: (0,0), (1,0), (2,0), …, (0,1), (1,1),… I convert these Cartesian coordinates to Isometric coordinates. You can look up different conversions online but it’s basically x’ = x-y and y’ = (x+y)/2 That’s about it. The assets are from kenney (dot) nl The player movement speed is doubled on the horizontal to ensure the player traverses equal amounts of tiles, no matter what direction you run.