more comment
This commit is contained in:
parent
30224c15bf
commit
80f00e8107
1 changed files with 17 additions and 9 deletions
|
@ -129,15 +129,23 @@ type Scanner interface {
|
||||||
|
|
||||||
// Scener components are a scene (Scene or SceneRef).
|
// Scener components are a scene (Scene or SceneRef).
|
||||||
type Scener interface {
|
type Scener interface {
|
||||||
// Q: Why not make Scener a small interface with just Scene() ?
|
// Q: Why not make Scene able to load itself?
|
||||||
// A: Everything in the engine would then need to type switch for Scener or SceneRef, i.e.
|
// A: Having separate types makes it easier to reason about what is loading
|
||||||
// switch x := i.(type) {
|
// what. There is less ambiguity about what "save" means (the contents of
|
||||||
// case Drawer:
|
// the scene, or the path to the file?) Additionally, the gob decoder
|
||||||
// i.Draw(screen, opts)
|
// decodes over existing fields, which could lead to some fun bugs.
|
||||||
// case Scener:
|
//
|
||||||
// i.Scene().Draw(screen, opts)
|
// Q: Why not make Scener a small interface, e.g. with just Scene() ?
|
||||||
// }
|
// A: Everything in the engine would then need to type switch for Scener or
|
||||||
// It seems cleaner to let the engine assert only for the interface it needs at that moment.
|
// SceneRef, i.e.
|
||||||
|
// switch x := i.(type) {
|
||||||
|
// case Drawer:
|
||||||
|
// i.Draw(screen, opts)
|
||||||
|
// case Scener:
|
||||||
|
// i.Scene().Draw(screen, opts)
|
||||||
|
// }
|
||||||
|
// It seems cleaner to let the engine assert only for the interface it
|
||||||
|
// needs at that moment.
|
||||||
|
|
||||||
Bounder
|
Bounder
|
||||||
Disabler
|
Disabler
|
||||||
|
|
Loading…
Reference in a new issue