@@ -3,7 +3,8 @@ import C4C from 'c4c-lib';
33import Phaser from 'phaser' ;
44import MainGame from './scenes/mainGame' ;
55import TackleBox from './scenes/tacklebox' ;
6- import Badges from './scenes/badges' ;
6+ import MyFish from './scenes/myfish' ;
7+ import Market from './scenes/market'
78
89// Load style.css into our page
910import './assets/style.css' ;
@@ -25,7 +26,7 @@ const theme = {
2526// Create the C4C editor
2627// The functions that you want the code editor to autocomplete
2728// If you want to add more on the fly depending on the scene, you will have to create a new editor
28- const autocompleteFunctions = [ 'moveRight' , 'moveLeft' , ' cast', 'addBait' ] ;
29+ const autocompleteFunctions = [ 'cast' , 'addBait' ] ;
2930C4C . Editor . create ( document . getElementById ( 'code-editor' ) , theme , false , autocompleteFunctions ) ;
3031
3132// Create the game
@@ -42,7 +43,7 @@ const config = {
4243 // Where the game is located (id of the DOM element)
4344 parent : 'game-container' ,
4445 // All the scenes in the game
45- scene : [ MainGame , TackleBox , Badges ]
46+ scene : [ MainGame , TackleBox , MyFish , Market ]
4647}
4748
4849const game = new Phaser . Game ( config ) ;
@@ -63,37 +64,54 @@ document.getElementById('tackle-box').addEventListener('click', () => {
6364 // Stop running any code that's currently running
6465 codeRunner . reset ( ) ;
6566 clearInterval ( gameLoop ) ;
66- // If the current scene is mainGame.js, or badges .js, switch to tacklebox.js
67+ // If the current scene is mainGame.js, or myfish .js, switch to tacklebox.js
6768 if ( game . scene . isActive ( 'MainGame' ) ) {
6869 game . scene . stop ( 'MainGame' ) ;
6970 game . scene . start ( 'TackleBox' ) ;
70- } else if ( game . scene . isActive ( 'Badges ' ) ) {
71- game . scene . stop ( 'Badges ' ) ;
71+ } else if ( game . scene . isActive ( 'MyFish ' ) ) {
72+ game . scene . stop ( 'MyFish ' ) ;
7273 game . scene . start ( 'TackleBox' ) ;
7374 } else {
7475 game . scene . stop ( 'TackleBox' ) ;
7576 game . scene . start ( 'MainGame' ) ;
7677 }
7778} ) ;
7879
79- // Switch the scene whenever the "Badges " button is pressed
80- document . getElementById ( 'badges ' ) . addEventListener ( 'click' , ( ) => {
80+ // Switch the scene whenever the "My Fish " button is pressed
81+ document . getElementById ( 'my-fish ' ) . addEventListener ( 'click' , ( ) => {
8182 // Stop running any code that's currently running
8283 codeRunner . reset ( ) ;
8384 clearInterval ( gameLoop ) ;
84- // If the current scene is mainGame.js, or tacklebox.js, switch to badges .js
85+ // If the current scene is mainGame.js, or tacklebox.js, switch to myfish .js
8586 if ( game . scene . isActive ( 'MainGame' ) ) {
8687 game . scene . stop ( 'MainGame' ) ;
87- game . scene . start ( 'Badges ' ) ;
88+ game . scene . start ( 'MyFish ' ) ;
8889 } else if ( game . scene . isActive ( 'TackleBox' ) ) {
8990 game . scene . stop ( 'TackleBox' ) ;
90- game . scene . start ( 'Badges ' ) ;
91+ game . scene . start ( 'MyFish ' ) ;
9192 } else {
92- game . scene . stop ( 'Badges ' ) ;
93+ game . scene . stop ( 'MyFish ' ) ;
9394 game . scene . start ( 'MainGame' ) ;
9495 }
9596} ) ;
9697
98+ // Switch the scene whenever the "Market" button is pressed
99+ document . getElementById ( 'market' ) . addEventListener ( 'click' , ( ) => {
100+ // Stop running any code that's currently running
101+ codeRunner . reset ( ) ;
102+ clearInterval ( gameLoop ) ;
103+ // If the current scene is mainGame.js, or myfish.js, switch to tacklebox.js
104+ if ( game . scene . isActive ( 'MainGame' ) ) {
105+ game . scene . stop ( 'MainGame' ) ;
106+ game . scene . start ( 'Market' ) ;
107+ } else if ( game . scene . isActive ( 'MyFish' ) ) {
108+ game . scene . stop ( 'MyFish' ) ;
109+ game . scene . start ( 'Market' ) ;
110+ } else {
111+ game . scene . stop ( 'TackleBox' ) ;
112+ game . scene . start ( 'MainGame' ) ;
113+ }
114+ } ) ;
97115
98116// Run the code whenever the "Run Code" button is pressed
99117document . getElementById ( 'run-code' ) . addEventListener ( 'click' , ( ) => {
0 commit comments