File tree Expand file tree Collapse file tree 3 files changed +51
-7
lines changed
Expand file tree Collapse file tree 3 files changed +51
-7
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,35 @@ window.setup = function() {
1010 let vignettes = new Vignettes ( ) ;
1111 setup_window_variables ( vignettes ) ;
1212 setup_vignettes ( vignettes ) ;
13- setup_new_canvas ( 1280 , 720 ) ;
13+ setup_new_canvas ( 100 , 100 ) ;
1414}
1515
1616window . draw = function ( ) {
1717 background ( 255 ) ;
18- vignettes . draw ( ) ;
18+ // vignettes.draw();
1919}
2020
2121window . setup_new_canvas = function ( width , height ) {
2222 createCanvas ( width , height ) ;
2323 setup_scenes ( vignettes ) ;
2424}
25+
26+ window . mouseClicked = function ( ) {
27+ vignettes . click ( ) ;
28+ }
29+
30+ window . mouseDragged = function ( ) {
31+ vignettes . mouse_dragged ( ) ;
32+ }
33+
34+ window . mouseMoved = function ( ) {
35+ vignettes . mouse_moved ( ) ;
36+ }
37+
38+ window . keyPressed = function ( ) {
39+ console . log ( keyCode ) ;
40+ }
41+
42+ window . keyReleased = function ( ) {
43+ vignettes . key_released ( ) ;
44+ }
Original file line number Diff line number Diff line change @@ -2,34 +2,55 @@ export default class Vignettes{
22
33 constructor ( ) {
44 this . _scenes = [ ] ;
5+ this . _current_scene = 0 ;
56 }
67
78 add_scene ( scene ) {
89 this . _scenes . push ( scene ) ;
9- this . current_event
1010 }
1111
1212 draw ( ) {
13+ if ( this . _scenes . length > 0 ) {
14+ this . _scenes [ this . _current_scene ] . draw ( ) ;
15+ }
1316 }
1417
1518 click ( ) {
16-
19+ if ( this . _scenes . length > 0 ) {
20+ this . _scenes [ this . _current_scene ] . click ( ) ;
21+ }
1722 }
1823
1924 mouse_moved ( ) {
20-
25+ if ( this . _scenes . length > 0 ) {
26+ this . _scenes [ this . _current_scene ] . mouse_moved ( ) ;
27+ }
2128 }
2229
2330 mouse_dragged ( ) {
24-
31+ if ( this . _scenes . length > 0 ) {
32+ this . _scenes [ this . _current_scene ] . mouse_dragged ( ) ;
33+ }
2534 }
2635
2736 key_pressed ( keyboard_event ) {
2837
38+ console . log ( keyCode ) ;
39+ if ( keyCode == 39 ) {
40+ this . _current_scene = this . _current_scene - 1 ;
41+ this . _current_scene = this . _current_scene < 0 ? this . _scenes . length - 1 : this . _current_scene ;
42+ } else if ( keyCode == 37 ) {
43+ this . current_scene = ( this . current_scene + 1 ) % this . _scenes . length ;
44+ } else if ( this . _scenes . length > 0 ) {
45+ this . _scenes [ this . _current_scene ] . key_pressed ( ) ;
46+ }
47+
48+ console . log ( this . _current_scene ) ;
49+
2950 }
3051
3152 key_released ( keyboard_event ) {
32-
53+ this . _scenes [ this . _current_scene ] . key_released ( ) ;
3354 }
3455
3556}
Original file line number Diff line number Diff line change 1+ import Scene from "./scene.js"
2+
13export const setup_window_variables = function ( vignettes ) {
24 window . vignettes = vignettes ;
5+ window . Scene = Scene ;
36 window . ccapturer = new CCapture ( { format : 'webm' } ) ;
47}
You can’t perform that action at this time.
0 commit comments