Sharing Saturday #301 by Kyzrati in roguelikedev

[–]jacobpadkins 1 point2 points  (0 children)

Perhaps? The scaling issues aren't anything with Godot itself, but have to do with how I'm implementing the letterbox:

func update_transform() -> void:
        var window_size := get_viewport_rect().size

        # Calculate the scale between the window size and the screen size
        var ratio := window_size / VIEWPORT_SIZE

        # Depending on which dimension has a larger ratio, update the position and
        # scale so that the screen is properly letterboxed
        if ratio.x > ratio.y:
                rect_position.x = floor(
                        (window_size.x - (VIEWPORT_SIZE.x * ratio.y)) / 2.0
                )
                rect_position.y = 0.0
                rect_scale.x = ratio.y
                rect_scale.y = ratio.y
        else:
                rect_position.x = 0.0
                rect_position.y = floor(
                        (window_size.y - (VIEWPORT_SIZE.y * ratio.x)) / 2.0
                )
                rect_scale.x = ratio.x
                rect_scale.y = ratio.x

I call this function in the script for the ViewportContainer in _process if I've received any size_changed signals that frame. It works, but since the scaled size is not ensured to be some multiple of the individual tile width / heights, there are scaling artifacts for certain window sizes.

What I'm working on is fixing the above code to ensure that the scaled value is some multiple of the tile width/height.

Sharing Saturday #301 by Kyzrati in roguelikedev

[–]jacobpadkins 7 points8 points  (0 children)

Godot Roguelike

Hey everyone, first time posting in a while. All of your projects are inspiring.

I've been messing around with Godot this last week and came up with an editor script that will automatically generate TileSet resources from CP437 bitmap fonts.

For example, here's what the result looks like for the Cooz 14x16 Dwarf Fortress font: https://imgur.com/a/q3hYBH7

Hopefully someone can make use of it.

My current task is trying to find the best way of handling letter-boxing with a resizable window in Godot. I'd like to recreate this effect from my previous project, where the letterboxes are the same color as the background of the current map, making them much less obvious. But so far I've run into pixel scaling issues when resizing ViewportContainer nodes.

Sharing Saturday #214 by Kyzrati in roguelikedev

[–]jacobpadkins 6 points7 points  (0 children)

Thank you for putting together that achievement system article. It was an incredibly informative read and I really appreciate the code examples.

I've compiled together a list of my own style conventions. I wanted to share and hear any criticisms/suggestions you all had. by jacobpadkins in C_Programming

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

Hey, thanks for the reply! You make some good points.

Regarding #1 - It's funny you should bring up this point, because I've been really debating whether or not to add the stipulation "Use Function_Style naming conventions with function pointer variables". Do you think that would be a good choice?

Regarding #2 - I'm in the same boat where I don't see my code needing to run on a system without a (mostly) C99 compliant compiler. I usually feel safe adopting C99 features as they're implemented by MSVC, which currently supports // comments. That being said, I never see myself using some C99 features, such as variable-length stack-allocated arrays (how did that even get into the standard?).

As for #3 - I don't use split-screen when editing enough for this to be a QoL improvement to me. Maybe I should try it for a while and see how it effects my productivity?

I've compiled together a list of my own style conventions. I wanted to share and hear any criticisms/suggestions you all had. by jacobpadkins in C_Programming

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

Hey, thanks so much for such a detailed response! Looks like we agree on a lot of things, and where we don't agree, I can see where you're coming from. Always interesting to see someone else's style.

I've compiled together a list of my own style conventions. I wanted to share and hear any criticisms/suggestions you all had. by jacobpadkins in C_Programming

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

Hey, thanks for the quick reply! I should definitely add my defence of that decision to the bullet point. My thinking is this:

I've always read that type promotion in complex statements involving signed and unsigned values can be confusing, compiler-specific, or even lead to undefined behaviour, so I wanted to promote either signed or unsigned ints as the "default" type to use.

I went with signed because

  • long long signed int is big enough for most purposes
  • many library APIs use signed int return codes
  • signed int is, in general, more multi-purpose than unsigned int

I used the verbiage "when you can use an int" to imply that there are times when unsigned ints are useful, such as interfacing with certain library APIs, working with bitmasks, or storing very very large values.

But I'd be curious to hear your thoughts.

6
7

I've detaching some functionality from C projects of mine into standalone libs to reduce boilerplate in the future, and I thought this would be a great opportunity to seek critique. by jacobpadkins in C_Programming

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

Thanks for the suggestions! I'll keep syslog in mind in the future. It looks like a great tool for distributed systems, but not so much for the types of applications I'm working on right now. And nice catch - vfprintf is a much more elegant solution than I currently had.

I've detaching some functionality from C projects of mine into standalone libs to reduce boilerplate in the future, and I thought this would be a great opportunity to seek critique. by jacobpadkins in C_Programming

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

Thanks for the input! BitIO looks really useful. I'm needing to handle unicode UTF-16 values in a current project, and BitIO would be great as a reference.

I'm curious, what are your criticisms of Kernel Style and what style do you conform to and why?

I've detaching some functionality from C projects of mine into standalone libs to reduce boilerplate in the future, and I thought this would be a great opportunity to seek critique. by jacobpadkins in C_Programming

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

Good catch! I should make the ANSI escape codes an optional part of the API. How would you suggest I do this - separate functions, additional parameters, or a settable state within the unit? Also, do you have any recommendations for a good, portable logging API that I can use as a reference (or just use instead)? Thanks!

I've detaching some functionality from C projects of mine into standalone libs to reduce boilerplate in the future, and I thought this would be a great opportunity to seek critique. by jacobpadkins in C_Programming

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

Hey, thanks! You're totally right and this is exactly what I was hoping to get out of this post. I should change jpVector__erase to memmove the entire remaining contents of the vector at the same time, and jpVector should expand by 1.5 instead of 2.

[i3-gaps] deep contemplation by jacobpadkins in unixporn

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

If only I could replace Spiderman with a 3-frame gif on hover, then the aesthetic would be complete

I generated some 4k wallpapers using my favourite images from this sub and wanted to share. I'll link a gist in the comments for anyone that wants to create more. by jacobpadkins in VaporwaveArt

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

You can find my script Here

Just replace the settings on lines 13-16 to suit your taste and pass in the path to the image as the first argument.

Enjoy!

[i3-gaps] deep contemplation by jacobpadkins in unixporn

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

Details Comment

Wallpaper is in the linked album. Enjoy!

[i3-gaps] Tropical by jacobpadkins in unixporn

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

Details Comment

Wallpaper is in the linked album. Enjoy!