ClarusPlusPlus , Englisch

Don't you just love game development? Somehow, some way, in implementing one enemy, I completely fucked up how one of the bosses works

Their code has nothing to do with each other

ClarusPlusPlus OP ,

Seriously WTF

ClarusPlusPlus OP ,

unrelated: I was proud of this sprite when I drew it. Now I kinda hate it

ClarusPlusPlus OP ,

I think it's the shoulders. Too narrow. He looks goofy, and not in the fun, "this game is silly" way

ClarusPlusPlus OP ,

Found the bug, at least.

This is in the function that chooses sprites for enemies. That's supposed to read "|| subType == ADANI_C)"

As written, that second condition always evaluates as true, meaning this now acts as a default case, ignoring everything else that comes after it -- including Rykar.

[EDIT: image description, since I forgot to add it: A line of C++ code that reads, "else if (subType is equal to ADANI_B, or else ADANI_C)"]

ClarusPlusPlus OP ,

I make this mistake a lot, but I always catch it the instant I type it. Not this time, apparently 👀

Thing is, if you read it as if it's English, it feels natural: "if the subType is Adani_B or Adani_C..."

I'm probably not the only person who's done this

foone ,
@foone@digipres.club avatar

@ClarusPlusPlus I've often thought someone should design a language to make this natural grammar work.

Python lets you do "if X in (optionA, optionB)" but it would be nice to write that as "if X = optionA or optionB"

timotimo ,
@timotimo@peoplemaking.games avatar

@foone @ClarusPlusPlus yes! Raku (nee Perl 6) has this, it's called junctions and it works in some pretty wild combinations if you really want.

for <-1 0 -2 0 1 1 2 2 3 0 4 0> -> $x, $y { if all($x, $y) == any(-1, 0, 1) { say "($x $y) inside" } }

gives

(-1 0) inside
(1 1) inside

rdnlsmith ,
@rdnlsmith@mastodon.social avatar

@foone @ClarusPlusPlus C# has this as of 2020ish:

if (x is y or z)

The inverse is a little awkward, though:

if (x is not y and not z)

You can’t just say “not y or z”.

“C# pattern matching” will find the relevant documentation if you’re interested.

  • Alle
  • Abonniert
  • Moderiert
  • Favoriten
  • random
  • haupteingang
  • Alle Magazine