|
sorry, too busy reimplementing custom wheels for my game, i'll try out that fancy csc stuff later
|
# ? Jan 11, 2020 00:51 |
|
|
# ? Jun 1, 2024 09:11 |
|
i've always wondered how games are architected, since i figured anything with that much special cases and edge cases and global state and weird interactions must have some fairly decent ways to control complexity turns out they just throw everything into global state and i'm just not cynical enough
|
# ? Jan 11, 2020 00:56 |
|
realtalk UE4 is pretty well designed, they discourage global state though it is of course possible. It's open source so you can check it out, you have to make an epic account to access the repo for some reason
|
# ? Jan 11, 2020 00:58 |
|
redleader posted:i've always wondered how games are architected, since i figured anything with that much special cases and edge cases and global state and weird interactions must have some fairly decent ways to control complexity sometimes yeah but there are much better ways to do it
|
# ? Jan 11, 2020 01:26 |
|
taqueso posted:realtalk UE4 is pretty well designed, they discourage global state though it is of course possible. It's open source so you can check it out, you have to make an epic account to access the repo for some reason Oh nice, that's interesting. I know nothing about games & game development (wrote a few tetris clones in my life) but I wrote an ImGUI based application last year because I needed quite a bit of graphics manipulation and I thought that it will be easier for me to just go full in rather than just use an OpenGL component in an Qt application (for example). Well, yeah, I had to manage all that state by myself, and it was not fun. The application is working, is cool and I'm proud of what I've created, but I wouldn't go this route again. For someone coming from game development though, I presume it's quite straightforward and probably even desirable.
|
# ? Jan 11, 2020 01:31 |
|
https://twitter.com/vamchale/status/1215787244633628672
|
# ? Jan 11, 2020 01:58 |
|
redleader posted:i've always wondered how games are architected, since i figured anything with that much special cases and edge cases and global state and weird interactions must have some fairly decent ways to control complexity Game devs can get by with "good enough" programming until it isn't good enough. But there are very sound patterns for architecting games, the most common of which is "entity-component-system."
|
# ? Jan 11, 2020 03:04 |
|
the standard "modern" way of writing gameplay code involves handling the entire matrix of pairwise interactions explicitly, but having a ton of support / helper code to make standard cases easy, and it tends to be pretty clean
|
# ? Jan 11, 2020 04:04 |
Suspicious Dish posted:the standard "modern" way of writing gameplay code involves handling the entire matrix of pairwise interactions explicitly, but having a ton of support / helper code to make standard cases easy, and it tends to be pretty clean As someone who doesn't know much about games programming, is this effectively what an Entity Component System is?
|
|
# ? Jan 11, 2020 06:06 |
|
ECS is confusing, because it quickly became the name for two different patterns The first should simply be called "component architecture", and it just means having a generic grab bag base actor class, called an "Entity", that you add "Components" to. these components might be tags like "Selectable" or "Enemy" or something which can tell different systems what kind of an actor it is, or it might have components with behavior like "SoundEmitter" or "CatAI" or "PhysicsObject". the idea behind this architecture is to work around the limitations of OOP-style single inheritance by splitting up behavior into a number of different composable things that your object can almost "inherit" from, with each one of those called "Components". this is the architecture behind Unity's GameObject and MonoBehavior. it has nothing to do with ECS ECS is really called "Entity-Component-Systems", and that last one is pluralized for a reason, because System here isn't describing the overall architecture, it's describing an actual object called a System things are almost the same, except that Entity basically becomes nothing more than an integer ID, Components are nothing but data, and Systems are things that run over entities and components and update them. basically, we split up the Component into a bunch of data, and a method that acts on that data. the idea behind this architecture is 1) parallelism, as in theory you can run a bunch of Systems in parallel, 2) performance through cache efficiency. Since Components are just structures in memory, you can have a giant array of them, and when your system runs, it updates each one in order, leading to a very cache efficient system, assuming there's no pointer chasing going on in your Data. It was originally invented by Mike Acton and was part of his "data-oriented programming" push. This is the idea behind Unity's new "DOTS" projects (Data Oriented Technology Stack), like the C# Job System and the Burst compiler. Mike Acton actually works at Unity now, too.
|
# ? Jan 11, 2020 07:18 |
|
ECS is really hot these days because (besides the data driven stuff which is cool on its own and the bigger benefit imo) it has good cache coherency and parallelizes well so performance is good on modern systems. Which I see dish touched on a little.
|
# ? Jan 11, 2020 07:24 |
|
This is not a semicolon, but a Greek question mark or something like that. Programming languages that permit Unicode symbols are pretty much vulnerable to the same kinds of vulnerabilities as typosquatting (Haskell particularly so, since you are allowed to define operators that consist solely of punctuation).
|
# ? Jan 11, 2020 09:16 |
|
So the horror is twitter's display of it?
|
# ? Jan 11, 2020 09:30 |
|
No, a Greek question mark looks visually the same as a semicolon in most fonts (as it's supposed to), but it's a different character with a different encoding and semantic meaning. It's like the difference between А (CYRILLIC CAPITAL LETTER A) and A (LATIN CAPITAL LETTER A).
|
# ? Jan 11, 2020 09:48 |
|
repiv posted:The developer of classic indie game VVVVVV just released its source code to celebrate its 10 year anniversary I've been writing a simple game project for my own amusement in C89 because I like retro computing and I'm keeping the door open to port it for Amiga and/or DOS. I'm not experienced in game programming so I often struggle with keeping the architecture sensible. Reading that code makes me feel like I could cut myself some slack in order to make progress easier. Even if I turn my brain off completely and hack away it would probably turn out more reasonable than that. That's what I miss about my teenage years when I had that similar drive to do make something at any means I could. It's a lot better to have a shittily coded successful game than elegantly coded unfinished one.
|
# ? Jan 11, 2020 11:09 |
|
I know nothing about game programming. How much separation is there between things like the graphics engine and "gameplay" logic (i.e. shootmans = he loses 10hp)? I have to believe that modern graphics engines or physics engines have some decent code behind them and aren't just a load of switch statements. Surely. Please?
|
# ? Jan 11, 2020 12:40 |
|
NtotheTC posted:I know nothing about game programming. How much separation is there between things like the graphics engine and "gameplay" logic (i.e. shootmans = he loses 10hp)? There's a shitload of separation but it's all just as bad
|
# ? Jan 11, 2020 13:22 |
|
Coming to it completely naively I would assume that if you care about writing maintainable code, what you do is to separate concerns like you would in many other types of app. So you have a model of the game world that is responsible for knowing things like how much HP a character has, and responds to events coming from (say) the physics engine to update the model. And then you have the display code that is informed of the current state of the world by the model. But I have no experience with programming of any real-time game.
|
# ? Jan 11, 2020 15:28 |
|
lobsterminator posted:I've been writing a simple game project for my own amusement in C89 because I like retro computing and I'm keeping the door open to port it for Amiga and/or DOS. I'm not experienced in game programming so I often struggle with keeping the architecture sensible. Reading that code makes me feel like I could cut myself some slack in order to make progress easier. Even if I turn my brain off completely and hack away it would probably turn out more reasonable than that. Sometimes there's even value in starting with lovely code first. It can help clarify where the abstractions should be, whereas you might wind up with leaks and anti-patterns if you start building the architecture without understanding the domain.
|
# ? Jan 11, 2020 17:23 |
|
The main problem with bad code is that eventually it becomes extremely difficult to make further changes to. If you're motivated by the compulsion toward artistic expression, and you've got a relatively fixed finishing point, it's entirely possible that the point where you're overwhelmed by technical debt comes after the point where the game is released, even if you're an unsophisticated programmer.
|
# ? Jan 11, 2020 18:43 |
|
NtotheTC posted:I know nothing about game programming. How much separation is there between things like the graphics engine and "gameplay" logic (i.e. shootmans = he loses 10hp)? Yeah, there tends to be a separation between core systems & gameplay. Physics engines are usually pretty terrible code though anyway, but I just have a strong bias against physics systems in general lol
|
# ? Jan 11, 2020 19:29 |
|
DaTroof posted:Sometimes there's even value in starting with lovely code first. It can help clarify where the abstractions should be, whereas you might wind up with leaks and anti-patterns if you start building the architecture without understanding the domain. Yeah, I'd say a good middle ground is to limit your scope, write lovely code for it until it works, then clean it up before it needs to play nice with anything else. If you can then make another implementation of the same feature, that will help you clean up the structure and realize where you've been way too closely tied to the underlying hardware/driver/whatever, which if nothing else, is bad if it ever gets updated in a breaking way.
|
# ? Jan 11, 2020 19:31 |
|
in general i think people have too much of a reaction to jump to "lovely code" when it's either simply unfamiliar code, or solving a problem you don't know all the nuances of as i get more and more familiar with codebases that most people bounce off of, i tend to fall in love with their idiosyncracies and weird conventions and love it all the more. but i think given my posts you guys know i have awful programming opinions anyway like, i've been reverse engineering wind waker's codebase, something i used to think was impossibly miserable. japanese names are all two-letter abbreviations owing to that culture, so you get class names like "dCcD_GAtTgCoCommonBase" but once you figure out what all that stands for, you're over the big psych hurdle and it's mostly smooth sailing
|
# ? Jan 11, 2020 21:09 |
|
Bongo Bill posted:Game devs can get by with "good enough" programming until it isn't good enough. I think this is most software. You start coding and soldier onward until that inevitable day when you realize you made a bad design decision back on day 2 and now it's wrecking the project. At that point one of two things happens: You either rewind and fix the underlying flaw, which takes a lot of time and effort; or you say gently caress it and start bolting on workarounds and hacks.
|
# ? Jan 11, 2020 21:10 |
|
NtotheTC posted:I know nothing about game programming. How much separation is there between things like the graphics engine and "gameplay" logic (i.e. shootmans = he loses 10hp)? The game engine usually doesn't know about bullets, hitpoints, etc. There will be a player entity, and when the player clocks the mouse it will call the player entity's shoot function (or something is registered to listen to the button or whatever). The player entity will have a current weapon, which will have its fire method triggered. That weapon will have some way of doing something. This can be hit scan (draw a vector where the player is pointing, and call damage on whatever it hits first, or register a bullet hole detail etc). Or, instead of a simple vector it might create a new bullet entity, which now has a direction and speed assigned. Every game tick the bullet entity will be moved forward (gravity influence optional, allowing for bullet drop). On every clock tick off the game engine, every entity movement will happen, and if something intersects a collision is registered; the bullet tells the entity it collides with "do -10 health". The entity it applies to may decide to do something as a result, etc. Meanwhile, the entity will have a way to describe to the game engine how it should be rendered. The graphics engine generally doesn't care about the details of the entity, just that it should be drawn a certain way. The older iD engines are open source, you might want to see about picking one up, compiling it, then tinkering to see what happens. I remember learning and internalizing a lot of this with the first half life game making a mod for it
|
# ? Jan 11, 2020 21:42 |
Suspicious Dish posted:it's mostly smooth sailing Ruzihm fucked around with this message at 22:34 on Jan 11, 2020 |
|
# ? Jan 11, 2020 22:32 |
|
Suspicious Dish posted:in general i think people have too much of a reaction to jump to "lovely code" when it's either simply unfamiliar code, or solving a problem you don't know all the nuances of You see "dCcD_GAtTgCoCommonBase" but I just see the lady in a red dress.
|
# ? Jan 12, 2020 05:00 |
|
Suspicious Dish posted:in general i think people have too much of a reaction to jump to "lovely code" when it's either simply unfamiliar code, or solving a problem you don't know all the nuances of The trouble here is that knowing whether what you're seeing is nonsense or simply not something you've learned can only be gleaned after getting your head wrapped around both the code as well as the domain as well as just experience with code in general. Game code tends to be a mess because a lot of what establishes structure - at least to business development - isn't necessarily *fast*.
|
# ? Jan 12, 2020 11:10 |
|
I've seen where someone will do stuff like write out a function that returns a boolean as if ... return ... else ... return ..., and maybe there's some expressions that can be simplified, a variable gets reassigned where it really shouldn't, small things like that; but the overall layout of the project is very thoughtful and understandable. I'd definitely prefer to work with that, than the other way around.
|
# ? Jan 12, 2020 12:58 |
|
The Celeste player class is often thrown around in discussions like these. It's super brancy logic full of manually crafted edge cases, so it makes sense that the code follows that structure. I don't consider it horrific. https://github.com/NoelFB/Celeste/blob/master/Source/Player/Player.cs
|
# ? Jan 13, 2020 11:37 |
|
Yeah, I think that class is actually really good. Maybe some of the animation code could be cleaned up, but the core logic is sound and sane. I wouldn't change much.
|
# ? Jan 13, 2020 20:03 |
|
|
# ? Jan 13, 2020 20:59 |
|
Athas posted:This is not a semicolon, but a Greek question mark or something like that. Programming languages that permit Unicode symbols are pretty much vulnerable to the same kinds of vulnerabilities as typosquatting (Haskell particularly so, since you are allowed to define operators that consist solely of punctuation). When I copy it out of the tweet, it's a semicolon, so did she just write a semicolon because it's easier than typing a Greek question mark on her phone or whatever or has Twitter or Chrome "helpfully" coalesced it into the ASCII code for me?
|
# ? Jan 13, 2020 21:22 |
|
C++ code:
|
# ? Jan 14, 2020 11:07 |
|
Xarn posted:
Never forget: "We realize the world is moving mostly to non-EBCDIC..." (IBM, in the Year of Our Lord 2014)
|
# ? Jan 14, 2020 11:17 |
|
https://twitter.com/jxxf/status/1219009308438024200
|
# ? Jan 20, 2020 07:20 |
|
Volmarias posted:If something looks strange, it's way more helpful to have a quick comment than to have to blame the source and do archaeology. Its all about comments should be why not what.
|
# ? Jan 20, 2020 07:29 |
|
code:
|
# ? Jan 21, 2020 22:47 |
|
a hot gujju bhabhi posted:
Despite working with async code in the past, I often find it difficult to wrap my head around it and I'm sure others do too. Could you help spread the knowledge by explaining why this code fails to do what the author intended it to do, and how you would go about fixing it (if you had to content yourself with just putting a bandaid on it?)
|
# ? Jan 21, 2020 23:11 |
|
|
# ? Jun 1, 2024 09:11 |
|
I'm not a c# dev, but seems like - This doesn't need to be recursive, it should absolutely be iterative - CacheService should have an async function that completes when the background refresh is no longer in progress - Task.Run returns immediately, although it's not clear if the author wanted the waiting to happen on another thread or not so that might be ok, but recursively making a new thread each time is gross Edit: Assuming we can't do #2 and #3 is expected behavior, seems like we can do slightly better with code:
Volmarias fucked around with this message at 23:45 on Jan 21, 2020 |
# ? Jan 21, 2020 23:32 |