-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: break out all animations into packages
- Loading branch information
Showing
13 changed files
with
104 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
package anim | ||
package meta | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cfoust/cy/pkg/geom/image" | ||
) | ||
|
||
const DEFAULT_FPS = 30 | ||
|
||
type Animation interface { | ||
Init(image.Image) | ||
Update(delta time.Duration) image.Image | ||
} | ||
|
||
type Creator func() Animation | ||
|
||
var Animations = map[string]Creator{} | ||
|
||
func registerAnimation(name string, animation Creator) { | ||
Animations[name] = animation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package anim | ||
|
||
import ( | ||
"github.com/cfoust/cy/pkg/anim/collapse" | ||
"github.com/cfoust/cy/pkg/anim/conway" | ||
"github.com/cfoust/cy/pkg/anim/cos" | ||
"github.com/cfoust/cy/pkg/anim/cy" | ||
"github.com/cfoust/cy/pkg/anim/fluid" | ||
"github.com/cfoust/cy/pkg/anim/meta" | ||
"github.com/cfoust/cy/pkg/anim/midjo" | ||
"github.com/cfoust/cy/pkg/anim/musicforprogramming" | ||
"github.com/cfoust/cy/pkg/anim/slime" | ||
) | ||
|
||
const DEFAULT_FPS = 30 | ||
|
||
type Creator = meta.Creator | ||
type Animation = meta.Animation | ||
|
||
var Animations = map[string]Creator{} | ||
|
||
func registerAnimation(name string, animation Creator) { | ||
Animations[name] = animation | ||
} | ||
|
||
func init() { | ||
registerAnimation("collapse", func() Animation { | ||
return &collapse.Collapse{} | ||
}) | ||
registerAnimation("conway", func() Animation { | ||
return &conway.Conway{} | ||
}) | ||
registerAnimation("cos", func() Animation { | ||
return &cos.Cos{} | ||
}) | ||
registerAnimation("cy", func() Animation { | ||
return &cy.Cyform{} | ||
}) | ||
registerAnimation("fluid", func() Animation { | ||
return &fluid.Fluid{} | ||
}) | ||
registerAnimation("midjo", func() Animation { | ||
return &midjo.Midjo{} | ||
}) | ||
registerAnimation("musicforprogramming", func() Animation { | ||
return musicforprogramming.New() | ||
}) | ||
registerAnimation("slime", func() Animation { | ||
return &slime.Slime{} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.