Skip to content

Commit 34ff085

Browse files
committed
Image/Movement/Display updates
1 parent 9187847 commit 34ff085

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/assets/bkg.png

490 KB
Loading

src/assets/boat.png

29.5 KB
Loading

src/assets/raccoon.png

28 KB
Loading

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Phaser from 'phaser';
44
import MainGame from './scenes/mainGame';
55
import TackleBox from './scenes/tacklebox';
66
import MyFish from './scenes/myfish';
7-
import Market from './scenes/market'
7+
import Market from './scenes/market';
88

99
// Load style.css into our page
1010
import './assets/style.css';
@@ -135,7 +135,7 @@ document.getElementById('run-code').addEventListener('click', () => {
135135
// Restart the gameloop right now
136136
// Note phaser has a way to do a game loop that's probably better than this, I would look into using that instead maybe
137137
codeRunner.step();
138-
gameLoop = setInterval(() => codeRunner.step(), gameLoopSpeed)
138+
gameLoop = setInterval(() => codeRunner.step(), gameLoopSpeed);
139139
});
140140

141141

src/scenes/mainGame.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import C4C from 'c4c-lib';
22
import { gameLoopSpeed } from '..';
3-
import background from '../assets/lake-testAsset.jpg';
4-
import boat from '../assets/testBoat.png';
3+
import background from '../assets/bkg.png';
4+
import boat from '../assets/boat.png';
55
import Phaser from 'phaser';
6-
import hook from '../assets/hook-testAsset.png'
6+
import hook from '../assets/hook-testAsset.png';
7+
import raccoon from '../assets/raccoon.png';
78

89
export default class MainGame extends Phaser.Scene{
910
constructor(){
@@ -15,6 +16,7 @@ export default class MainGame extends Phaser.Scene{
1516

1617
preload(){
1718
this.load.image('background', background);
19+
this.load.image('raccoon',raccoon);
1820
this.load.image('boat', boat);
1921
this.load.image('hook', hook);
2022

@@ -23,19 +25,22 @@ export default class MainGame extends Phaser.Scene{
2325
create(){
2426
// Add images
2527
this.add.image(400, 300, 'background').setDisplaySize(800, 600);
26-
this.boat = this.physics.add.sprite(400, 300, 'boat').setDisplaySize(130, 100);
28+
this.raccoon = this.physics.add.sprite(400, 110, 'raccoon').setDisplaySize(115,110);
29+
this.boat = this.physics.add.sprite(400, 140, 'boat').setDisplaySize(170, 60);
2730

2831
this.boat.setCollideWorldBounds(true);
32+
this.raccoon.setCollideWorldBounds(true);
2933

3034
// C4C default text
3135
C4C.Editor.setText(`// Enter your code here!\n`);
3236

3337

3438
// Keyboard Input
3539
this.cursor = this.input.keyboard.createCursorKeys();
36-
40+
3741
// Define functions used in the written code----------------------------
3842

43+
// THIS DOES NOTHING ATM
3944
C4C.Interpreter.define('cast', (speed) => {
4045
if (speed === undefined) {
4146
speed = 100;
@@ -55,15 +60,21 @@ export default class MainGame extends Phaser.Scene{
5560

5661
// Conditional logic for keyboard controls
5762
const speed = this.cursor.shift.isDown ? 300 : 160;
63+
64+
// Boat & Raccoon movement
5865
if (this.cursor.left.isDown) {
5966
this.boat.setVelocityX(-speed);
67+
this.raccoon.setVelocityX(-speed);
68+
this.raccoon.setFlipX(false);
6069
} else if (this.cursor.right.isDown) {
6170
this.boat.setVelocityX(speed);
71+
this.raccoon.setVelocityX(speed);
72+
this.raccoon.setFlipX(true);
6273
} else {
6374
this.boat.setVelocityX(0);
75+
this.raccoon.setVelocityX(0);
6476
}
6577

66-
}
67-
6878
// Functions
79+
}
6980
}

0 commit comments

Comments
 (0)