love2d-community / splashes

A collection of splash screens for LÖVE
Other
76 stars 18 forks source link

Init on new #5

Closed josefnpat closed 8 years ago

josefnpat commented 8 years ago

So instead of having arguments for the new operator like this:

splash = splashlib.new(background,foreground,cactus)

leading to awkward situations when you only want cactus:

splash = splashlib.new(nil,nil,cactus)

We can simply pass in a definition table that allows for the defaults to be overridden on creation:

splash = splashlib.new{cactus=cactus}

The best thing about this is that it's easy to make forward compatible because the order doesn't matter. For example, let's say you add cactus after the you added background. The following call will work with both versions of the library, even if the cactus variable is not handled.

splash = splashlib.new({background=background,cactus=cactus)

and now for a cat

image

josefnpat commented 8 years ago

Sorry this is dependent on 23f7ecc, my mistake. WIll remake PR if it's an issue.

josefnpat commented 8 years ago

Got in during this rebase: https://github.com/love2d-community/splashes/commit/1dfb7f7ec7b5c9fdaf798bf843dd3d2c1e20f601