ASTROBARN CS 174A
To add new objects, use file separation with mixins
Ex.
- Create new file Thingy.js
- In thingy.js, define a mixin class such as
let ThingyMixin = {
draw_thingy(m, graphics_state) {
this.draw_thingy_arm(m, graphics_state)
},
draw_thingy_arm(m, graphics_state) {
...
},
}
- (Notice its a Javascript object not class, so you need a comma after every function def)
- Include the JS file in index.html
-
<script src="thingy.js"></script>
- Use the following syntax at the bottom of main-scene.js to assign the mixin (dumb JS hack)
Object.assign(Assignment_Two.prototype, ThingyMixin);
- Now use your thingy methods defined in the mixin file in the scene display() to draw