Add intro scene with title screen

- Create IntroScene with ocean-themed background
- Display game title and 18th century whaling subtitle
- Add decorative waves and ship silhouette
- Implement START GAME button with hover effects
- Initialize inventory and transition to ShipDeckScene

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Thomas Richter
2025-12-17 03:43:27 +01:00
parent d6941621cd
commit a17500dff4
2 changed files with 122 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import Phaser from 'phaser';
import IntroScene from './scenes/IntroScene.js';
import ShipDeckScene from './scenes/ShipDeckScene.js';
import MapScene from './scenes/MapScene.js';
import TransitionScene from './scenes/TransitionScene.js';
@@ -10,7 +11,7 @@ const config = {
height: 600,
parent: 'game-container',
backgroundColor: '#2d5f8e',
scene: [ShipDeckScene, MapScene, TransitionScene, HuntingScene],
scene: [IntroScene, ShipDeckScene, MapScene, TransitionScene, HuntingScene],
physics: {
default: 'arcade',
arcade: {

120
src/scenes/IntroScene.js Normal file
View File

@@ -0,0 +1,120 @@
export default class IntroScene extends Phaser.Scene {
constructor() {
super({ key: 'IntroScene' });
}
init(data) {
// No data needed - this is the entry point
}
create() {
// Ocean blue background
this.add.rectangle(400, 300, 800, 600, 0x1e5a8e);
// Draw decorative waves
this.drawWaves();
// Ship silhouette (decorative element)
this.drawShip();
// Game title
const title = this.add.text(400, 150, 'WHALE HUNTING', {
fontSize: '56px',
fill: '#ffffff',
fontStyle: 'bold'
}).setOrigin(0.5);
title.setStroke('#000000', 3);
// Subtitle
this.add.text(400, 210, 'An 18th Century Whaling Voyage', {
fontSize: '22px',
fill: '#cccccc',
fontStyle: 'italic'
}).setOrigin(0.5);
// Decorative separator line
const line = this.add.graphics();
line.lineStyle(3, 0xcccccc, 0.6);
line.lineBetween(200, 240, 600, 240);
// Start button
const buttonBg = this.add.rectangle(400, 400, 200, 60, 0x2d5f8e);
buttonBg.setStrokeStyle(3, 0xffffff);
buttonBg.setInteractive({ useHandCursor: true });
const buttonText = this.add.text(400, 400, 'START GAME', {
fontSize: '28px',
fill: '#ffffff',
fontStyle: 'bold'
}).setOrigin(0.5);
// Button hover effects
buttonBg.on('pointerover', () => {
buttonBg.setFillStyle(0x4a90c4);
});
buttonBg.on('pointerout', () => {
buttonBg.setFillStyle(0x2d5f8e);
});
// Button click handler
buttonBg.on('pointerdown', () => {
this.startGame();
});
// Instructions text
this.add.text(400, 530, 'Click to begin your adventure', {
fontSize: '16px',
fill: '#ffff99'
}).setOrigin(0.5);
}
drawWaves() {
const waves = this.add.graphics();
waves.lineStyle(2, 0x4a90c4, 0.5);
// Draw 8 wavy horizontal lines
for (let i = 0; i < 8; i++) {
const y = 80 + (i * 60);
waves.beginPath();
waves.moveTo(0, y);
// Create wave pattern
for (let x = 0; x <= 800; x += 20) {
const waveY = y + Math.sin((x + i * 50) * 0.02) * 8;
waves.lineTo(x, waveY);
}
waves.strokePath();
}
}
drawShip() {
const ship = this.add.graphics();
// Hull
ship.fillStyle(0x654321);
ship.fillRect(655, 427, 90, 45);
// Sail (triangle)
ship.fillStyle(0x8B4513);
ship.beginPath();
ship.moveTo(700, 380); // Top of sail
ship.lineTo(680, 430); // Bottom left
ship.lineTo(720, 430); // Bottom right
ship.closePath();
ship.fillPath();
}
startGame() {
// Initialize inventory with starting values
const inventory = {
whaleOil: 0,
fuel: 100,
penguins: 0
};
// Transition to ship deck
this.scene.start('ShipDeckScene', { inventory: inventory });
}
}