Conversation started Jan 19, 2015 at 15:12.
Jan 19, 2015 15:12
draw sprite <$> use lander.position <*> use lander.rotation
oh man
this line of code is fucking sexy
looks to me like fixed-function pipeline/immediate mode bullshit.
but maybe that's just appearance
@Xeo incidentally I just bought 20 huge 7-seg displays
@BartekBanachewicz if only you could write them one after the other and not use <*> and <$> :D
@BenjaminGruenbaum implicit state access? no thanks.
@Puppy we're thinking about a stateless API. Or as pure as it can reasonably get.
FFP/immediate mode is a thing specific to low-level implementation. This is a high-level API
it's really more of a pseudocode to make API decisions easier
personally I created the sprite and had it be drawn implicitly each frame
Jan 19, 2015 15:17
@Puppy Jefffrey is a strong opponent of making the user keep rendering objects. Registering them into a manager means a need to create a binding (can be complicated) to update them, or fiddling with their ids (terrible)
ModelView bindings are something that could be nice here, but I've no idea how to approach them yet
@BartekBanachewicz Make the manager the creating object and then register/unregister them implicitly.
user1804599
Diff the old and new game states and update the sprites accordingly.
@Puppy I (think I) got that part. What about updates?
Xeo
Xeo
@BartekBanachewicz pure createLander <*> generateTerrain - I guess precedence for <$> didn't work out so you could use it twice without parens?
@R.MartinhoFernandes Because it looks cool.
user1804599
Jan 19, 2015 15:19
Similar to what React does to the DOM.
It's just an old clock.
Xeo
Xeo
So?
@Xeo I am not sure if I like the fact that pure and impure arguments are applied differently, if that's what you mean
fun a <$> b seems less consistent than fun <$> pure a <*> b
Xeo
Xeo
oh wait, yeah
it might have some precedence issues because I haven't obviously compiled it yet
Jan 19, 2015 15:24
@BartekBanachewicz You could pass it a function to call to get the position for this frame. I obviously simply used mutable state to hold the position, but that was a long time ago.
@Puppy this game uses mutable state.
is it just me, or is the default icon for windows PCs on OS X when sharing stuff a 90's CRT monitor with a BSOD on the screen
lol
Xeo
Xeo
@BartekBanachewicz Nono, you're fine, I was confusing it with something else
@Puppy however, how do you manage objects that are added and removed dynamically?
user1804599
@AlexM. It is.
Jan 19, 2015 15:26
if draw has just a readonly view on game state, it's impossible to try accessing nonexisting entities
@рытфолд lol windows isn't that bad to deserve this
but say I have orcs :: [Orc], and an orcSprite
How do I draw that?
user1804599
foreach orc in orcs:
    draw orcSprite (position orc)
@рытфолд you need to pass the position to draw
yeah, that's one way certainly.
Whether it's forM or mapM is obviously irrelevant
@BartekBanachewicz Each Orc holds a distinct Sprite object that represents the final draw output.
Jan 19, 2015 15:32
Orcs are great carry on!
@Puppy so your Sprite is actually more like a refcounted SpriteHandle?
not really, because each Sprite has distinct positioning.
wait, you store positioning with the sprite?
@Puppy so it's SpriteHandle, with mutable transformation data?
user1804599
@Puppy Eww.
Jan 19, 2015 15:33
@AlexM. I call those instances
the SpriteHandle is an implementation detail.
so for 10000000000000 trees
you could simply load the texture data again for each Sprite if you really wanted to.
@Puppy perhaps, I just wanted to make sure I understand the idea
you'd have 10000000000000 sprites
Jan 19, 2015 15:34
obviously that would be dumb, but possible.
@Puppy no, it's not possible.
you'd run out of ram
depends on how many instances you have and how big the underlying texture is
cue my latest 1.3GB RAM-using code that drew a triangle
just make a sprite batch that takes in textures and outputs things
after batching things
right, well I said it would obviously be dumb.
Xeo
Xeo
Jan 19, 2015 15:35
A sprite references a (cutout from a) texture
but I agree it's implementation thing
what's more important is tying the transformation to it
if it's separate from your model, it forms a viewModel
so you have to sync it somehow
in a typical MVVM scenario it would be via a binding, again.
@Puppy but is that stored together with regular Model data?
doesn't that violate separation of concerns?
well, you don't strictly have to actually put the Sprite in the Orc, you could have an external map from Orc to Sprite if you wanted to.
@Puppy who would ensure the 1:1 invariant?
it's not like you can CREATE CONSTRAINT ON ORCS; they're big and green
well, who is normally responsible for rendering stuff from the model?
Jan 19, 2015 15:50
@Puppy I don't know what "normally" is supposed to mean in this context, but conceptually "something" takes the model state and turns it into something on the screen.
then that "something" also ensures 1:1
@Puppy so in every frame the drawing component looks at the orcs container, and for each orc, if a sprite tied to it exists it updates it, if it doesn't it creates a new one, and if any sprites are left it deletes them?
@BartekBanachewicz It might be simpler to just have the Orc accept an opaque type as a kind of RenderData object and keep it in there.
but personally I think that it may be easier to create the Sprite with a function that gets the data from the Orc directly, as then there is no need to update the Sprite.
@Puppy separation of concerns again
the concerns are properly separated if the model code cannot access the rendering data, and that's still true if the type iss opaque.
Jan 19, 2015 15:57
@Puppy but you still have to run the constraint, no? Separating the constraint and the update loop gives you... what exactly?
@Puppy I disagree. If a model is literred with data not relevant to its purpose, it's a strong smell of bad design.
I also think it's a bad design to have one thing split into several pieces.
and what you're ultimately ending up with is OrcModel, OrcRender, etc.
I think a good game framework design is one that doesn't look like someone's master's thesis in design patterns :(
@Puppy not really. What I'm proposing is that logic should be written as if graphics didn't exist.
@BartekBanachewicz Which is exactly what you'll get if the rendering stuff is opaque.
personally I think I had a design that I actually liked that solved this problem but I've totally forgotten it, if it was ever more than a figment.
the core issue is that you have two situations with conflicting requirements.
@Puppy um, no.
Jan 19, 2015 16:00
you don't want to end up with OrcRender OrcModel etc, but you also want to separate those two concerns.
In my approach you're not ending up with OrcRender
you create a model and operations on it, and graphics is completely stateless
you still have to define Orc-external routines that deal with rendering an Orc, specifically.
model stays pure (sans ~random)
hmm.
on reflection, I'm not actually sure why I objected to that so strongly, it seems perfectly logical right now.
perhaps I should take a moment to shake off the millenia of cruft that's built up over this stuff in my head
@Puppy oh, certainly. That's why MVVM is perhaps a bad name for it. It's more just a model and a view.
MV.
inb4 components.
Jan 19, 2015 16:04
ah well it becomes a little more complex when you do have to share state in your graphics engine, like I dunno, textures, meshes, etc.
@Puppy lightweight handles.
they're still state that have to live somewhere.
since I'm writing a framework, I'm fine with providing that storage as a global
wat
it's just a cache.
Jan 19, 2015 16:06
hm
arguably true.
View routines describe shaders, textures, models to be used when drawing an orc, but they don't care where they are stored.
They express their needs, and aren't concerned with implementation
bah fucking tar shit can't archive anything.
@Puppy Lol tar
and yeah, I like the "update/draw" distinction now that I think of it
update: runs with consistent time spans (you don't need explicit dt), gives you write access to state
draw: runs whenever the screen is ready, gives you readonly access
 
Conversation ended Jan 19, 2015 at 16:09.