Spyke

Posts

Help with my first ever Shader in Godot

Preamble: I've been trying to write my first shader and have been stuck for several days now. I chose this shader because I thought it would be an easy first, but I've been down a few rabbit holes and I'm no longer sure what is the best approach.

I did my best to organize what I've tried and the problems/questions I have with each approach. Sorry if this is a long one...


I'm building a 2D platformer game and have made some really simple blank white tiles with black/gray borders to start off with and test my game. 32x32 px tiles, viewable [here](https://imgur.com/a/Y9pPH3c.

I wanted to build a shader on my TileMapLayer so that on the bottom and left sides they have a bit more grey. My thinking is for any white pixel, if there is a black pixel 1 or 2 pixels left or below the current one, make COLOR be grey.


Attempt 1: My first approach was following this post: https://forum.godotengine.org/t/how-to-check-color-of-adjacent-pixels-in-fragment-shader/27296/2 I got pretty close with this code:

shader_type canvas_item;

const vec4 BLACK = vec4(0, 0, 0, 1);
const vec4 WHITE = vec4(1, 1, 1, 1);

const vec2 LEFT_ONE = vec2(-1, 0);
const vec2 LEFT_TWO = vec2(-2, 0);
const vec2 DOWN_ONE = vec2(0, 1);
const vec2 DOWN_TWO = vec2(0, 2);

void fragment() {
    vec2 pixel_size = 1.0 / vec2(textureSize(TEXTURE, 0));
    if (texture(TEXTURE, UV).rgba == WHITE) {
        if (texture(TEXTURE, UV + LEFT_ONE * pixel_size).rgba == BLACK
            || texture(TEXTURE, UV + LEFT_TWO * pixel_size).rgba == BLACK
            || texture(TEXTURE, UV + DOWN_ONE * pixel_size).rgba == BLACK
            || texture(TEXTURE, UV + DOWN_TWO * pixel_size).rgba == BLACK) {
            COLOR = vec4(0.0, 1.0, 0.0, 1.0); // currently green for debugging
        }
    }
}

but the issue is that TEXTURE isn't my TileMapLayer, it's the tileset image itself (as in, the one linked above). This led to some weird issues, ex: https://imgur.com/a/WNlGpJe.

My first question: This approach could work, if only I could just have the texture of the TileMapLayer itself. Is there any way that's possible?


Attempt 2: It was suggested in the Godot Discord for me to try a Screen-Reading Shader. No matter what I try here, my screen_texture is always from before my TileMapLayer is drawn. This means I can't detect the colors of pixels on the TileMapLayer since screen_texture doesn't have it yet.

I can verify it with this code:

shader_type canvas_item;

const vec4 WHITE = vec4(1, 1, 1, 1);
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;

void fragment() {
	if (COLOR.rgba == WHITE) { // This is done to leave my borders alone and only draw on the white. This works.
		COLOR = texture(screen_texture, SCREEN_UV);
    }
}

This makes all the white pixels effectively transparent. If screen_texture had my TileMapLayer, I'd expect the pixels to remain white.

I've tried various attempts at converting my above code to use screen_texture and SCREEN_UV but I figure if I cannot get screen_texture to see the TileMapLayer, none of that code will work.

2a: I've read online about BackBorderCopy, but I've been unable to get any good results with one. I've tried it as a parent, child, and before/after sibling of my TileMapLayer, with Rect mode and Viewport mode, and while it does make some things happen, it never makes it so screen_texture gets my TileMapLayer's pixels.

Questions: Is BackBorderCopy what I need? Am I using it wrong? I think it needs to be a parent of my TileMapLayer, but I've had no luck no matter what. It seems to give the same results .

2b: I've tried adding my TileMapLayer as a child of a CanvasGroup, and putting the shader on the CanvasGroup. Somehow this has the same issue where it doesn't have the pixels from the TileMapLayer, but with an added bonus of making everything a big white square. Is there any validity in this approach?

2c: I've tried putting my TileMapLayer in a SubViewport and adding a Sprite2D with a ViewportTexture and putting the shader on the Sprite2D. Maybe this will work, I don't know, but I have way too many issues trying to line things up so that my tiles all show on screen and also are in the same place that they are supposed to be that I gave up.] This approach seems too heavy-handed. If anyone thinks it will work I'd be happy to elaborate on how I had problems making things fit.

View original on lemmy.world

First Godot project, I'd love some pointers about project/scene structure

I'm building a 2d platformer in Godot, and it's my first time with the engine.

I've followed the First 2D Game tutorial as well as a few others (Brackey's videos and some others) and have a decent grasp on building out a level as well as decent physics for how I want my player character to control.

So far, everything was made underneath one main Scene called "Game" and I'm at the step where I want to start having a Main Menu, a Level Select Menu, and logic on starting/completing a level rather than just one big "Game" Scene with a bunch of stuff I slapped together to test out the platforming.

I'd love some input on how I should be structuring my project and changing scenes around. I've found examples in tutorials but they all differ on some details and I'm not sure what is best. I've built a simple Main Menu and Level Select Menu and am able to go in and start the "Game" scene from it.

This is a big ask, I admit :).


  1. I've created a new main Scene titled "Main". It's jsut a plain Node with this script so far:
class_name Main extends Node


var main_menu_scene: PackedScene = preload("res://scenes/main_menu.tscn")

func _ready() -> void:
	add_child(main_menu_scene.instantiate())

func exit() -> void:
	get_tree().quit()

I've done this partly to follow an example that I found, but also due to how I want the background to work. In some Valve games, the Main Menu background is based upon the level you're at in the campaign. I want that. If you start the game up the first time, I want the background to be the 1st level background. If you're on world 10, I want it to remember and show that background. When the level launches, the background can stay the same as it was on the Main Menu.

I don't have backgrounds started in at all, yet.

  1. My Main Menu scene is a PanelContainer. Above, Main loads the MainMenu scene and adds it as a child. This works but I don't know if it's the best way. Script:
class_name MainMenu extends PanelContainer

@onready var main_scene: Main = get_parent()
var level_select_menu_scene: PackedScene = load("res://scenes/level_select_menu.tscn")
var options_menu_scene: PackedScene = load("res://scenes/options_menu.tscn")

func _on_play_button_pressed() -> void:
	main_scene.remove_child(self)
	main_scene.add_child(level_select_menu_scene.instantiate())

func _on_options_button_pressed() -> void:
	main_scene.remove_child(self)
	main_scene.add_child(options_menu_scene.instantiate())

func _on_exit_button_pressed() -> void:
	main_scene.exit()

This lets you exit (works by calling the Main scene function) go to Options, and go to the Level Select scene as well.

  1. Next is the Level Select Menu. It's similar to the MainMenu. Script:
class_name LevelSelectMenu extends PanelContainer


@onready var main_scene: Main = get_parent()
var main_menu_scene: PackedScene = load("res://scenes/main_menu.tscn")

func _on_back_button_pressed() -> void:
	main_scene.remove_child(self)
	main_scene.add_child(main_menu_scene.instantiate())

func _on_level_1_button_pressed() -> void:
	main_scene.remove_child(self)
	main_scene.add_child(load("res://scenes/game.tscn").instantiate())

func _on_level_2_button_pressed() -> void:
	# main_scene.remove_child(self)
	pass

Here you can go back (works) to the MainMenu, or move forward and start the "Game" scene I mentioned above. I intend to build a few levels and stick them in here in a similar fashion, replacing game.tscn. That will get me to the pre-pre-pre-alpha stage of my game and I hope to get feedback on how the platforming "feels" from there.

My thought is that the Main scene would handle the backgrounds, and always be the main parent Node in the Scene Tree. The Menus and Levels get swapped out as the child node of Main.


Questions:

Does this look ok to any of you Godot veterans?

Any code smells?

All of my scenes are in a /scenes directory. All of my scripts are in a /scripts directory. No sub-directories in either. This is quickly getting messy and I'd also love tips on folder structure.

View original on lemmy.world

Help w/ Area2D and multiple on_body_entered()'s being triggered

Essentially, I have some Area2Ds in which I'm changing the direction of gravity. I only want this to happen if the player has enough speed. So, I was checking for that condition and setting gravity_space_override = Area2D.SPACE_OVERRIDE_DISABLED when the player was too slow. That's when I ran in to this issue...

Here is a minimal amount of code to reproduce my issue. On an Area2D, when my player enters it:

func _on_body_entered(body: Node2D) -> void:
    if body is Player:
        print('enter')
        gravity_space_override = Area2D.SPACE_OVERRIDE_DISABLED
        gravity_space_override = Area2D.SPACE_OVERRIDE_REPLACE

I see "enter" printed multiple times. If I comment out the last two lines, "enter" is printed once, as I'd expect.

How might I modify gravity_space_override without having the body_entered signal firing off again?


Edit: Solved by instead of toggling the gravity on/off with gravity_space_override, I'm storing these

var default_gravity: float = 980
var default_gravity_direction: Vector2 = Vector2.DOWN
var default_gravity_point: bool = false

and toggling between the default/downward gravity and the alternate gravity that I want in the Area2D.

View original on lemmy.world
counterstrike·Counter-Strikebyspacemanspiffy

So I'm trying out CS2 and having fun and all, but where are all the maps?

I've been playing CS2 a bit lately and I admit I am having a lot of fun, to the point where I'm remembering some of the good old days when I was playing entirely too much CS: Source.

But, where are some of my favorite maps, though? Notably: cs_assault, de_dust, de_aztec, de_cache

I'm really missing these. I love cs_assault and its what I think of when I think of Counter Strike.

Does anyone know if these are returning?

View original on lemmy.world

I built a simple game engine for Point and Click Adventure Games, plus 3 games to go with it

Introducing Pacab - the Point and Click Adventure Builder!

Pacab is an idea I had one day at work that I decided to take way too far.

A lot of the apps I build at my work transform metadata about form questions from JSON/XML/database/whatever into HTML forms.

It occurred to me that simple point and click games aren’t that different. A screen in the game is like a webpage, and the areas you can click/interact on screen are like the textboxes/dropdown controls that we build web forms with.

Another way to think of Pacab is like an interactive slideshow. Each slide is a picture file, and each picture has an accompanying TOML file to describe the clickable areas.

It’s built on top of pygame-ce and a small number of other Python libraries.


The games:

  1. Alt-Escape

Alt-Escape is a thrilling adventure in which you must escape from a room, or else risk still being stuck in that same room.

The title is a reference to the fact that there are alternative ways to escape (4 or 5 depending how you count).

I’ll admit that I didn’t have a huge plan going in to this and made it up as I went along. Still, I think the short and sweet appeal of this one may actually make it the best of the three. The cool kids find every possible exit.

  1. Jungle Gem

Jungle Gem puts you on an adventure going into a temple in the jungle to retrieve a magical stone.

This is way longer and admittedly the puzzles are much more obtuse and reminiscent of early 90’s puzzle/adventure game difficulty.

If you can get past all the Water Chamber stuff, I promise it gets easier from that point.

Now look, I am not a good writer (sorry for the lousy stories) and I an not a good artist, either. I intentionally kept these looking simple to keep constraints on myself. Both games are 100% drawn by me in KDE Kolour Paint. GIMP for the animations. The sound effects and music are all mostly me, with a couple one-offs found online to help me out. You can even hear my voice acting debut in Alt-Escape :).

  1. Active Radio

This one is a bit different. Active Radio is set in an abandoned theme park not far from where I live. The “graphics” are all photos that I took.

Active Radio pits you in a radioactive wasteland where you must find parts to assemble a radio and call for help before becoming food for the “Horde”.

This game has far fewer puzzles and is big on exploration.

(While playing, just imagine what someone with actual skills in photography could have done with this idea :)).


None of these games are revolutionary or anything, but I hope they at least get a chuckle from some people. They are simple by design, and thus have a lot of shortcomings. I’d love constructive feedback.

View original on lemmy.world

New to Godot, I have some quick questions on the editor

Hello, as the title says, I am very new to Godot. I just finished following the 2D Game Tutorial, and I have a question on this part: https://github.com/godotengine/godot-demo-projects/blob/bf4d1038d623c355f3b49e613a2c9b686eebb312/2d/dodge_the_creeps/main.gd#L44

Basically, I had the idea to play around and try to give the mob a curved path, so I tried mob. in Godot's script editor looking for the completion engine to find me things similar to .linear_velocity only to find nothing, and also that linear_velocity didn't even show up as an autocomplete suggestion. No errors or warnings, and the code runs fine.

Question 1: Why does linear_velocity not get suggested? How can I change that, so I can have the editor help me learn the language and APIs?


Question 2: Unrelated to the above. I like Vim motions. Any suggestions on either:

  • Installing a Godot plugin to get Vim bindings?
  • Setting up Godot to use Neovim as my external editor?
  • Just using Neovim externally to edit my GD scripts?

Just looking for thoughts on what people use and like.

View original on lemmy.world
nostupidquestions·No Stupid Questionsbyspacemanspiffy

Is it possible to get access to files in an old/inactive S3 bucket?

Many moons ago I was in a band, and we had a website with our songs stored in Amazon AWS. I recently found that our site was archived on the Way Back Machine. But unfortunately, the audio was in S3 and those URLs don't work.

<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>

WBM did not archive these URLs (understandably).

I no longer have any AWS account because Amazon is poopy.

Are these files lost to time, or is there some magic way to retrieve them?

View original on lemmy.world

Cannot detect eMMC during install on Chrombook

Hello! I am trying to install Mint on an Acer C720P Chromebook that previously was running GalliumOS.

I cannot for the life of me get the Linux Mint Live USB to recognize the internal eMMC storage so I can install to it.

I have an Arch live iso that has no issue seeing the device or formatting it, so I don't believe it's a BIOS or hardware issue.

I have tried both GPT and MBR, and I have also tried LMDE, all to no avail.

Please, are there any tips or things I can try to get Mint to recognize the eMMC? I want to install this to give to a friend and I really feel that Mint is a good choice for her if I can just get it to install. If it matters, the BIOS is https://docs.mrchromebox.tech/docs/fwscript.html

View original on lemmy.world

How important are translations in a game?

I'm working on a small project that I hope to be able to share soon. I created a game engine for point-and-click adventure games and I'm working on three different games for it. Two are near completion, the final one is just getting started. I plan on sharing this (on Lemmy and elsewhere) once the last game is ready.

Now, I am an English speaker and have little insight from the outside world. The game engine does not support translation/localization at all.

  • I'm somewhat interested in adding this as it means more people could potentially play these games.
  • I'm worried that adding it will open up a can of worms in my code (long story short, I'm worried translated text will have issues in the menu/UI, overflow, look bad, etc.).

So for the non-native English speakers especially, how important is this to you? Do you expect smaller indie games to play in English or in your native language?

View original on lemmy.world
nostupidquestions·No Stupid Questionsbyspacemanspiffy

Why don't these code-writing AIs just output straight up machine code?

For background, I am a programmer, but have largely ignored everything having to do with AI (re: LLMs) for the past few years.

I just got to wondering, though. Why are these LLMs generating high level programming language code instead skipping the middle man and spitting out raw 1s and 0s for x86 to execute?

Is it that they aren't trained on this sort of thing? Is it for the human code reviewers to be able to make their own edits on top of the AI-generated code? Are there AIs doing this that I'm just not aware of?

I just feel like there might be some level of optimization that could be made by something that understands the code and the machine at this level.

View original on lemmy.world

What are people usong as thei music player app nowadays?

I have been using Lollypop on my phone for about 2 years now. I have tried a few other apps but nothing worked quite as well for me as Lollypop.

That said, I still have a lot of gripes with Lollypop. Rather than complain about it, though, I'd rather hear about something new.

The last time I went looking for a new app was in 2023. Is there anything new in 2025 worth checking out?


My wants:

  • Large-ish local library (350gb) and I want it to load/scroll through fast. Lollypop is quite slow here.
  • I really prefer the UI to list artists, open one, then list albums, open one, then list songs. Too many apps list all your albums, or all your individual songs, and I hate this.

Edit: I guess I need to specify, I am looking for Linux-native apps. A few of the suggestions so far have been Android, and I am not seeking to run anything in Waydroid for this.

View original on lemmy.world
nostupidquestions·No Stupid Questionsbyspacemanspiffy

What to name these Conversation objects in my code

I'm normally pretty ok at naming things in code, but I'm struggling here and would love some new ideas.

I'm building part of a game for the dialog with NPCs. It functions just like Fallout:

  • Player initiates dialog with NPC.
  • NPC says a few sentences.
  • Player gets a list of replies and can pick one.
  • Depending what the player picks, either the conversation will end, or the NPC will say some new stuff and start this over.

Here's the names of objects that I have so far that I'm not exactly in love with. I'd love suggestions on any of these.

  1. Dialog: This is a "container" object. Clicking on an NPC will start the Dialog. This contains many Chats.
  2. Chat: This is the name I dislike most. A Chat contains the text the NPC will say, and a list of ChatReply objects.
  3. ChatReply: This contains the text of the reply (what the player is saying back to the NPC), as well as a pointer to either a new Chat, or to end the Dialog.

Any suggestions?


Update: From the replies, I think I like Dialog / Prompt / Reply.

View original on lemmy.world
ergomechkeyboards·ErgoMechKeyboardsbyspacemanspiffy

Does the keyboard I want exist?

This is admittedly a lazy post where I show that I haven't done much research.

Whenever I start searching around online, I find tons of smaller companies selling ergo keyboards or parts for keyboards, but they are always very pricey and don't match the layout I want. I quickly give up since it can take long to search store-by-store online.

The keyboard of my dreams has:

  1. All (104) the keys. This means arrow keys and as numpad. I like the layout of my current keyboard (below). I guess this is called a "full keyboard"?
  2. Mechanical and with plenty of clackedy clack in the keys.
  3. Corded with USB (I still miss PS/2 :))
  4. Is curved, similar to this one.
  5. Has the "Y" key on the left side of the gap! This is my biggest sticking point. I have realized that I type the "Y" key with my left hand 99% of the time and I don't want to change.
  6. I am also willing to investigate split design keyboards if the "Y" is on the left and a numpad can exist separately which I could put to the right of my mouse. But still I'd prefer that to be attached.
  7. I don't care about RGB or lights or much else. Take it or leave it.

For reference, this is my current keyboard and I actually quite love it. I just wish it was curved.

View original on lemmy.world
nostupidquestions·No Stupid Questionsbyspacemanspiffy

(In Python) Can you save an object that is in memory to disk and reload it at a later time?

Background: I am working on a Python project where, given a set of input files (text/image/audio), it generates an executable game. The text files are there to describe the rules of the game.

Currently, the program reads and parses the files upon each startup, and builds a Python class that contains these rules, as well as links to image/audio files. This is fine for now, but I don't want the end executable to have to bundle these files and re-parse them each time it gets run.

My question: Is there a way to persist the instance of my class to disk, as it exists in memory? Kind of like a snapshot of the object. Since this is a Python project, my question is specific to Python. But, I'd be curious if this concept exists anywhere else. I've never heard of it.

My aim is not to serialize/de-serialize the class to a text file, but instead load the 1's and 0's that existed before into an instance of a class.

View original on lemmy.world