Skip to content

Commit 7852701

Browse files
committed
feat: improved pet sim + bring back legacy sky for future
1 parent a6eb9f2 commit 7852701

File tree

3 files changed

+70
-20
lines changed

3 files changed

+70
-20
lines changed

back/src/scripts/petSimulatorScript.js

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ const EGG_TYPES = {
107107
epic: 0.5,
108108
legendary: 0.2,
109109
},
110+
buyPosition: { x: -97.73, y: -12.08, z: 13.17 },
110111
},
111112
SPOTTED: {
112113
name: 'Spotted Egg',
@@ -120,6 +121,7 @@ const EGG_TYPES = {
120121
epic: 0.8,
121122
legendary: 0.5,
122123
},
124+
buyPosition: { x: -89.87, y: -12.59, z: -2.18 },
123125
},
124126
GOLDEN: {
125127
name: 'Golden Egg',
@@ -133,6 +135,7 @@ const EGG_TYPES = {
133135
epic: 1.5,
134136
legendary: 1.0,
135137
},
138+
buyPosition: { x: -82.12, y: -12.46, z: -17.4 },
136139
},
137140
CRYSTAL: {
138141
name: 'Crystal Egg',
@@ -146,6 +149,7 @@ const EGG_TYPES = {
146149
epic: 2.0,
147150
legendary: 3.0,
148151
},
152+
buyPosition: { x: -73.78, y: -12.07, z: -29.45 },
149153
},
150154
}
151155

@@ -172,7 +176,7 @@ const chatEntity = EntityManager.getFirstEntityWithComponent(allEntities, ChatCo
172176
const playerData = new Map()
173177

174178
// Leaderboard display
175-
const leaderboardText = new FloatingText('👑 LEADERBOARD 🏆', 0, 10, -250, 150)
179+
const leaderboardText = new FloatingText('👑 LEADERBOARD 🏆', 93.47, -12.45, 39.26, 150)
176180

177181
function updateLeaderboard() {
178182
// Convert Map to array for sorting
@@ -499,25 +503,19 @@ function levelUpPet(playerId, petIndex) {
499503
}
500504

501505
// Initialize separate egg shops for each egg type
502-
Object.entries(EGG_TYPES).forEach(([eggType, eggData], index) => {
506+
Object.entries(EGG_TYPES).forEach(([eggType, eggData]) => {
503507
// Position each shop in a line, spaced out from each other
504-
const xPos = index * 16 // Spread them out by 4 units, starting at -4
505-
506-
const eggShop = new Cube({
507-
position: { x: xPos - 50, y: -15, z: 130.238 },
508-
size: {
509-
width: 2,
510-
height: 2,
511-
depth: 2,
512-
},
508+
const eggShop = new Mesh({
509+
position: { x: eggData.buyPosition.x, y: eggData.buyPosition.y, z: eggData.buyPosition.z },
513510
colliderProperties: {
514511
isSensor: true,
515512
},
516513
physicsProperties: {
517514
mass: 0,
518515
gravityScale: 0,
519516
},
520-
// name: eggData.name,
517+
meshUrl: 'https://notbloxo.fra1.cdn.digitaloceanspaces.com/Notblox-Assets/base/Egg.glb',
518+
name: eggData.name,
521519
})
522520

523521
// Add proximity prompt for buying this specific egg type
@@ -553,14 +551,14 @@ Object.entries(EGG_TYPES).forEach(([eggType, eggData], index) => {
553551
},
554552
interactionCooldown: 1000,
555553
holdDuration: 0,
556-
maxInteractDistance: 10,
554+
maxInteractDistance: 12,
557555
})
558556
eggShop.entity.addNetworkComponent(eggShopPrompt)
559557
})
560558

561559
// Initialize egg hatching station
562560
const eggHatchingStation = new Cube({
563-
position: { x: -0.027, y: -15.877, z: 80.238 },
561+
position: { x: 90.27, y: -15, z: -57.81 },
564562
size: {
565563
width: 0.1,
566564
height: 0.1,
@@ -682,10 +680,12 @@ const eggHatchPrompt = new ProximityPromptComponent(eggHatchingStation.entity.id
682680

683681
// Send appropriate notifications based on rarity
684682
const rarityInfo = RARITY_DATA[petData.rarity]
685-
const hatchMessage = `Your ${eggData.emoji} ${eggData.name} hatched into a ${rarityInfo.emoji} ${petData.name}! (${petData.bonus} coins/jump)`
686-
687-
sendTargetedNotification(`🥚 Hatched!`, hatchMessage, [playerId])
683+
// Create a colored message based on pet rarity
684+
const rarityText = getRarityColoredText(petData.name, petData.rarity)
685+
const hatchMessage = `Your ${eggData.emoji} ${eggData.name} hatched into a ${rarityText}! It gives you +${pet.bonus} coins per jump!`
688686

687+
sendTargetedNotification(`🐣 New Pet!`, hatchMessage, [playerId])
688+
sendTargetedChat('🐣', hatchMessage, [playerId])
689689
// For rare or higher pets, broadcast to everyone to create FOMO
690690
if (
691691
petData.rarity === 'rare' ||
@@ -992,6 +992,25 @@ ScriptableSystem.update = (dt, entities) => {
992992
'📊',
993993
`${playerData.name} stats: 💰 ${coins} coins | 🥚 ${eggs} eggs | 🐾 ${pets.length} pets${legendaryString} | ⏱️ ${playtimeString}`
994994
)
995+
} else if (command === '/pos') {
996+
const playerData = getPlayerData(event.entityId)
997+
if (!playerData) continue
998+
const entity = EntityManager.getEntityById(entities, event.entityId)
999+
if (!entity) {
1000+
console.error('Entity not found', event.entityId)
1001+
continue
1002+
}
1003+
// Show player position
1004+
const positionComponent = entity.getComponent(PositionComponent)
1005+
if (!positionComponent) {
1006+
console.error('Position component not found', positionComponent)
1007+
continue
1008+
}
1009+
const position = positionComponent.serialize()
1010+
sendGlobalChatMessage(
1011+
'📍',
1012+
`${playerData.name} is at ${position.x}, ${position.y}, ${position.z}`
1013+
)
9951014
}
9961015
}
9971016
}

front/game/Renderer.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'
1414
import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass.js'
1515
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'
1616
import { GammaCorrectionShader } from 'three/examples/jsm/shaders/GammaCorrectionShader.js'
17+
import { Sky } from 'three/examples/jsm/objects/Sky.js'
1718

1819
export class Renderer extends THREE.WebGLRenderer {
1920
camera: Camera
@@ -42,9 +43,15 @@ export class Renderer extends THREE.WebGLRenderer {
4243

4344
// Prevent right click context menu
4445
this.domElement.addEventListener('contextmenu', (event) => event.preventDefault())
45-
//this.addStaticLight()
4646
this.addDirectionnalLight()
47-
this.addHDRSky()
47+
const legacySky = false
48+
if (legacySky) {
49+
this.addStaticLight()
50+
this.addSky()
51+
} else {
52+
// HDR sky breaks mobile lighting
53+
this.addHDRSky()
54+
}
4855
// this.setupPostProcessing()
4956

5057
window.addEventListener('resize', this.onWindowResize.bind(this), false)
@@ -91,6 +98,31 @@ export class Renderer extends THREE.WebGLRenderer {
9198
//this.addOcean()
9299
}
93100

101+
private addSky() {
102+
// Normal sky Three.JS
103+
const sun = new THREE.Vector3()
104+
105+
const sky = new Sky()
106+
107+
const uniforms = sky.material.uniforms
108+
uniforms['turbidity'].value = 12
109+
uniforms['rayleigh'].value = 0
110+
uniforms['mieCoefficient'].value = 0.045
111+
uniforms['mieDirectionalG'].value = 0.0263
112+
113+
const elevation = 2
114+
const azimuth = 360
115+
116+
const phi = THREE.MathUtils.degToRad(90 - elevation)
117+
const theta = THREE.MathUtils.degToRad(azimuth)
118+
119+
sun.setFromSphericalCoords(1, phi, theta)
120+
121+
uniforms['sunPosition'].value.copy(sun)
122+
123+
sky.scale.setScalar(450000)
124+
this.scene.add(sky)
125+
}
94126
private addHDRSky() {
95127
// Environment map
96128
const textureLoader = new THREE.TextureLoader()

front/game/ecs/entity/Player.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { EntityManager } from '@shared/system/EntityManager'
44

55
export class Player {
66
entity: Entity
7-
debug: boolean = true
87

98
constructor(entityId: number) {
109
this.entity = EntityManager.createEntity(SerializedEntityType.PLAYER, entityId)

0 commit comments

Comments
 (0)