0
2038
petrol_sniff_king

@lemmy.blahaj.zone

petrol_sniff_king 3 points 4 hours ago

I have never had an ingrown hair in my life.

I'm sure people get them, but I can't imagine it's that common.

path: 0 24388628 24390192, hotness: undefined, score: 3, children: 4
petrol_sniff_king 1 point 3 hours ago

That sucks :p

I wish I knew what I was doing differently. Maybe I just have an X-men outer carapace for skin.

path: 0 24388628 24390192 24390256 24390289, hotness: undefined, score: 1, children: 0
petrol_sniff_king 2 points a day ago

porn in america is hyper-aggressive and focused on penetration. there's no eroticism to it. it's crass and disgusting.

Truuue.

what a boneheaded take out of the OP.

Well, the guy they're talking to is almost certainly a Sargon of Akkad-lite who is upset that feminism is ruining his disney movies. I would tell him to go watch porn too, but that's because I like zingers.

path: 0 24365702 24367680 24372452, hotness: undefined, score: 2, children: 0
petrol_sniff_king 12 points 3 days ago

There is a trick I learned from Firebelley Games (a youtube channel) that is just as simple to spin up and use as the Enum + match strategy but without sacrificing any versatility.

I actually like it better than the Node-based pattern because you don't have to set up much boilerplate, and you really don't need to think about how different state classes might share data. Plus, none of it will clog up your scene tree or need to be pointlessly instantiated by the engine.

Tap for code

If you're on mobile, I would recommend reading this in horizontal view.

This is all it takes to spin one up:

class_name Player2D extends Node2D

var _state_machine := CallableStateMachine.new();

func _ready() -> void:
  _state_machine.add_state(
    _state_idle_update,
    Callable(),
    Callable()
  );
  _state_machine.add_state(
    _state_jump_update,
    _state_jump_enter,
    Callable()
  );
  # Set first state
  _state_machine.switch_to(_state_idle_update);

func _process(_delta: float) -> void:
  _state_machine.update();

# These are your state functions.
func _state_idle_update() -> void;
func _state_jump_update() -> void;
func _state_jump_enter() -> void;

The only thing your state machine actually needs to know is which functions are paired together. You can use Callable() to fill in any steps you're not actually using.

func _ready() -> void:
  _state_machine.add_state(
    _state_idle_update, # update
    _state_idle_enter,  # enter
    Callable(),         # exit
  );

You call update() yourself, so its timing is completely under your control.

func _process(delta: float) -> void:
  velocity.y += 9.8 * delta;
  _state_machine.update();
  move_and_slide();

States are keyed by their own update step, so there's no extra overhead for string names or Enums or the like, and you still get your IDE's tab autocomplete to help you with 'em.

func _state_idle_update() -> void:
  if Input.is_action_pressed('jump'):
    _state_machine.switch_to(_state_jump_update);

All state functions exist within the Player2D script, so you have complete access to any shared data or component that Player2D does.

var _anim: AnimatedSprite2D = $An...;
var _jump_times := 0;

func _state_idle_enter() -> void:
  _anim.play('idle');
  _jump_times = 0;

func _state_jump_enter() -> void:
  _anim.play('jump');
  _jump_times += 1;

A basic implementation of CallableStateMachine is none too complicated, and you can reuse it anywhere.

class_name CallableStateMachine extends RefCounted

var _states_map := {} as Dictionary[Callable, CallableState];
var _current_state: CallableState = null;

func add_state(update: Callable, enter: Callable, exit: Callable) -> void:
  _states_map.set(update, CallableState.new(update, enter, exit));

func switch_to(update: Callable) -> void:
  if not _states_map.has(update):
    return;
  exit();
  _current_state = _states_map.get(update);
  enter();

func update() -> void:
  if _current_state:
    _current_state.update.call();

func enter() -> void:
  if _current_state:
    _current_state.enter.call();

func exit() -> void:
  if _current_state:
    _current_state.exit.call();

# This is just a struct to package the set of functions.
class CallableState extends RefCounted:
  var update: Callable;
  var enter: Callable;
  var exit: Callable;
  func _init(update: Callable, enter: Callable, exit: Callable) -> void:
    self.update = update;
    self.enter = enter;
    self.exit = exit;

You can do a lot from this base setup, too. I have mine setup such that if I name my functions like this:

func _state_idle() -> void;
func _state_idle__update(delta: float) -> void;
func _state_idle__unhandled_input(event: InputEvent) -> void;
func _state_idle__exit() -> void;

My state machine automatically knows which step each function is for by the keyword after the double-unders (e.g. '__update'), as well as that the nameless _state_idle() is the enter step and the key that I use to switch_to().

path: 0 24347079, hotness: undefined, score: 12, children: 1
petrol_sniff_king 1 point 2 days ago path: 0 24360718, hotness: undefined, score: 1, children: 0
petrol_sniff_king 46 points 4 days ago

This happened to me once.

I was playing some old game on my dad's ps1 when out of nowhere there was a loud flash of light outside, and then some rubber suit wearing guy on the TV just said "Look what I can do! Put your controller on the floor" and then just made it vibrate a bunch. I was about to pick the controller back up, but then, while I was watching, he made it like vibrate walk out of the room over to my mom's purse to dig out her credit card information, and then used it to purchase Digimon Rumble Arena off of some website I've never seen before. I was so mad because my mom was totally gonna blame me for this.

path: 0 24328605, hotness: undefined, score: 46, children: 0
petrol_sniff_king 3 points 3 days ago

By himself?

path: 0 24344281 24344742, hotness: undefined, score: 3, children: 0
petrol_sniff_king 2 points 3 days ago

I remember doing this for halloween and nobody got what I was.

path: 0 24346123, hotness: undefined, score: 2, children: 0
petrol_sniff_king 2 points 3 days ago

Hey! Stop putting ranch in your carry-ons! That ranch belongs in your checked bags only unless it's under 3.5 ozs, or about 13.5 sucks worth. You're allowed to suckle, but only a little bit.

path: 0 24342352 24344501 24344819, hotness: undefined, score: 2, children: 0
petrol_sniff_king 9 points 4 days ago

I came here to say this exact same thing! Thank you for saving me the trouble.

Cravings for Mexican food and for taco bell will not satisfy each other because they're not the same thing.

path: 0 24322782 24327228 24328244, hotness: undefined, score: 9, children: 1
petrol_sniff_king 3 points 4 days ago

I'm playing it right now and I'm having such a great time with it.

There was a secret cubbyhole inside a cavern that it took me like 6 tries to get up to without falling and I felt sooo cool for doing it. Used up like half of my items, but oh well. :p

path: 0 24298975 24303216 24306447 24324534, hotness: undefined, score: 3, children: 0
petrol_sniff_king 1 point 4 days ago

It's a necessary evil,

I don't understand why it is that we all have to pretend that society is supposed to be this anti-social.

Mate, that bus-stop story some lady has about how proud she is of her son for getting into the college he wanted is a story I want to hear, and you're making that more difficult for me.

path: 0 24177444 24184246 24196506 24322015 24324118, hotness: undefined, score: 1, children: 0
petrol_sniff_king 8 points 7 days ago

Yeah, I reread that sentence like 6 times 'cause I thought I was fucking it up

path: 0 24281364 24281544 24281636, hotness: undefined, score: 8, children: 0
petrol_sniff_king 73 points a year ago

Elon actually hands these out to people who don't want them because they were unpopular and an easy means of telling chuds apart from... uh, chads? There's a good chance hers is a forced advertisement and not something she's actually paying for.

path: 0 15215221 15217142, hotness: undefined, score: 73, children: 32
petrol_sniff_king 68 points 2 months ago

Flat earth would be so cool if it was just sci-fantasy authors and not weird, return to christandom, anti-modernity types.

path: 0 23580710, hotness: undefined, score: 68, children: 8
petrol_sniff_king 65 points a year ago

I... what tips and tricks does this person think they're going to get? You either sell the car, or you stop bringing it with you. There's no third option. Is disguising it a third option? Wrap it in a little rubber chicken costume?

People would ask questions like this in reddit AMAs all the time, too, and I just don't understand the impulse to ask strangers online before you've thought about it yourself even a little bit.

path: 0 16248379, hotness: undefined, score: 65, children: 6
petrol_sniff_king 62 points a year ago

I think if they only advertised the post-tax number, there wouldn't really be a problem. Like, "hey, the jackpot is some amount, and after tax you could win 400 million"—that would be fine. As it is, they're kinda just building resentment for taxes in general by making your final winnings seem so disappointing, even though it's still 400 million.

path: 0 14222981 14223105, hotness: undefined, score: 62, children: 6
petrol_sniff_king 60 points 2 years ago path: 0 10033229 10033517, hotness: undefined, score: 60, children: 2
petrol_sniff_king 53 points 24 days ago

The future is dying of thirst in the world's 59th consecutive "hottest summer on record"

path: 0 24003247 24003503 24003642, hotness: undefined, score: 53, children: 0
petrol_sniff_king 53 points 2 years ago

Jesus. That was an uncomfortable read. I hope somebody gave anon a hug.

path: 0 11269456, hotness: undefined, score: 53, children: 0

thanks for using Leebra!

go to feed...