Skip to content

created LadyBugController and sprite #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Features

* Creates multiple fruit flys which fly and walk around the browser window.
* Creates multiple spiders which walk around the browser window.
* Creates multiple ladybugs which walk around the browser window.
* Flys are responsive to mouse movements (optional) and mouse overs events.


Expand Down Expand Up @@ -44,16 +45,22 @@ or
```
You can use SpiderController() as a shortcut for loading options and the sprite for the spiders.

```
```js
new SpiderController({'minBugs':2, 'maxBugs':6});
```

You also can use LadyBugController() as a shortcut for loading options and the sprite for the ladybugs.

```js
new LadyBugController({'minBugs':2, 'maxBugs':6});
```

See example.html

BugController constructor can optionally take an object of options. To make this js more async friendly, you can adjust the default options at the top of bug.js, and then instantiate at the bottom of the file as above. This will allow one to wrap the entire script in a closure to prevent any global window name space overlaps.

Async code:
```
```js
var targethead = window.document.getElementsByTagName("head")[0],
loadedSpiders = false,
jst = window.document.createElement("script");
Expand Down
24 changes: 24 additions & 0 deletions bug.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,30 @@ var SpiderController = function() {
}
SpiderController.prototype = BugDispatch;

var LadyBugController = function() {
var ladyBugOptions = {
imageSprite: 'ladybug-sprite.png',
bugWidth: 69,
bugHeight: 90,
num_frames: 7,
canFly: false,
canDie: true,
numDeathTypes: 2,
zoom: 6,
minDelay: 200,
maxDelay: 3000,
minSpeed: 7,
maxSpeed: 14,
minBugs: 2,
maxBugs: 4
};
this.options = mergeOptions(this.options, ladyBugOptions);
this.initialize.apply(this, arguments);

}

LadyBugController.prototype = BugDispatch;

/***************/
/** Bug **/
/***************/
Expand Down
6 changes: 5 additions & 1 deletion example.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
</head>
<body>
<script type='text/javascript' src='bug-min.js'></script>
<script type='text/javascript' src='bug.js'></script>
<script type='text/javascript'>
// default fruit fly bug:
new BugController({
Expand All @@ -12,6 +12,10 @@
// default spiders:
new SpiderController({
});

// ladybugs
new LadyBugController({
});
</script>
</body>
</html>
Binary file added ladybug-sprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added originals/joaninha.psd
Binary file not shown.