-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
2516 lines (2168 loc) · 107 KB
/
index.js
File metadata and controls
2516 lines (2168 loc) · 107 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
class PacManScene extends Phaser.Scene {
createInstructionalArrows() {
// Create a container for all instructional elements
this.instructionContainer = this.add.container(0, 0);
// Arrow properties
const arrowDistance = this.currentScale * 80; // Distance from Pacman center
const keyScale = this.currentScale * 0.065; // Scale for key icons
// Create arrows and keys for each direction
const directions = [
{ icon: 'w-key-logo', angle: 0, x: 0, y: -arrowDistance/2, direction: 'up' },
{ icon: 's-key-logo', angle: 0, x: 0, y: arrowDistance/2, direction: 'down' },
{ icon: 'a-key-logo', angle: 0, x: -arrowDistance/2, y: 0, direction: 'left' },
{ icon: 'd-key-logo', angle: 0, x: arrowDistance/2, y: 0, direction: 'right' }
];
this.instructionArrows = [];
directions.forEach(dir => {
// Calculate bounding box size based on key icon dimensions
// We'll use a fixed size that accommodates the key icon
const boxWidth = 50;
const boxHeight = 50;
const boxPadding = 5;
// Create bounding box (background)
const boundingBox = this.add.graphics();
// fill the bounding box with black color
boundingBox.fillStyle(0x000000, 0.8);
// make the line color to be white
boundingBox.lineStyle(2, 0xFFFFFF, 1);
boundingBox.fillRoundedRect(-boxWidth/2, -boxHeight/2, boxWidth, boxHeight, 5);
boundingBox.strokeRoundedRect(-boxWidth/2, -boxHeight/2, boxWidth, boxHeight, 5);
boundingBox.setScale(this.currentScale*0.80);
// Create key icon image
const keyIcon = this.add.image(0, -boxPadding, dir.icon); // Start slightly above center
keyIcon.setScale(this.currentScale * 0.065);
keyIcon.setAlpha(1.0);
// Rotate key icon to correct direction if needed
if (dir.angle !== 0) {
keyIcon.setRotation(Phaser.Math.DegToRad(dir.angle));
}
// Create container for this direction's elements
const directionContainer = this.add.container(dir.x, dir.y);
directionContainer.add([boundingBox, keyIcon]); // Box first (behind), then icon
// Store references
this.instructionArrows.push({
container: directionContainer,
arrow: keyIcon, // Keep 'arrow' name for compatibility with animations
boundingBox: boundingBox,
direction: dir.direction
});
this.instructionContainer.add(directionContainer);
});
// Initially hide the instruction container
this.instructionContainer.setAlpha(0);
this.instructionsVisible = false;
this.hasPlayerMoved = false;
}
showInstructions() {
if (!this.instructionsVisible && !this.hasPlayerMoved) {
this.instructionsVisible = true;
// Position instruction container at Pacman's position
this.instructionContainer.setPosition(this.pacman.x, this.pacman.y);
// Fade in instructions
this.tweens.add({
targets: this.instructionContainer,
alpha: 1,
duration: 500,
ease: 'Power2'
});
// Add pressing down animation to key icons
this.instructionArrows.forEach(instruction => {
const originalScaleX = instruction.arrow.scaleX;
const originalScaleY = instruction.arrow.scaleY;
const originalY = instruction.arrow.y;
const pressDownDistance = 8; // Distance to move down within the box
// Create a pressing down animation sequence
const pressDown = () => {
// Press down: scale down and move down within the bounding box
this.tweens.add({
targets: instruction.arrow,
scaleX: originalScaleX * 0.85,
scaleY: originalScaleY * 0.85,
y: originalY + this.currentScale * pressDownDistance/2,
duration: 150,
ease: 'Power2',
onComplete: () => {
// Release: return to normal position within box
this.tweens.add({
targets: instruction.arrow,
scaleX: originalScaleX,
scaleY: originalScaleY,
y: originalY,
duration: 500,
ease: 'Power2',
onComplete: () => {
// Wait a bit before next press
this.time.delayedCall(250, pressDown, [], this);
}
});
}
});
};
// Start the first press animation
pressDown();
});
}
}
hideInstructions() {
if (this.instructionsVisible) {
this.instructionsVisible = false;
this.hasPlayerMoved = true;
// Stop all instruction animations
this.instructionArrows.forEach(instruction => {
this.tweens.killTweensOf(instruction.arrow);
});
// Fade out instructions
this.tweens.add({
targets: this.instructionContainer,
alpha: 0,
duration: 300,
ease: 'Power2',
onComplete: () => {
this.instructionContainer.setVisible(false);
}
});
}
}
updateInstructions() {
// Stop showing instructions if Pacman is moving
if (this.pacman && this.pacman.isMoving) {
this.hideInstructions();
}
// Show instructions when game starts
if (!this.instructionsVisible && !this.hasPlayerMoved && this.pacman && this.pacmanInitialized) {
this.showInstructions();
}
// Update instruction position to follow Pacman (in case of camera movement)
if (this.instructionsVisible && this.pacman) {
this.instructionContainer.setPosition(this.pacman.x, this.pacman.y);
}
}
setCollisionWithTransformedTiles() {
// Extract all unique tile IDs from the walls layer data, including transformed ones
const wallsData = this.wallsLayer.layer.data;
const uniqueTileIds = new Set();
for (let row = 0; row < wallsData.length; row++) {
for (let col = 0; col < wallsData[row].length; col++) {
const tile = wallsData[row][col];
if (tile && tile.index > 0) {
uniqueTileIds.add(tile.index);
}
}
}
// Convert to array and set collision
const tileIdsArray = Array.from(uniqueTileIds);
this.wallsLayer.setCollision(tileIdsArray);
}
createSectionIcons() {
// Create a container for all section icons
this.sectionIconsContainer = this.add.container(0, 0);
// Define section positions (in tile coordinates)
const sections = [
{
// Top Left Section
x: 10, y: 5, icon: 'work-experience', name: 'Work Experience',
bounds: { minX: 2, maxX: 17, minY: 2, maxY: 7 }, // Outer bounds for detection
innerBounds: { minX: 3, maxX: 16.5, minY: 3, maxY: 6.5 } // Inner bounds for camera centering
},
{
// Top Right Section
x: 30, y: 5, icon: 'projects', name: 'Projects',
bounds: { minX: 22, maxX: 38, minY: 2, maxY: 7 }, // Outer bounds for detection
innerBounds: { minX: 23, maxX: 36.5, minY: 3, maxY: 6.5 } // Inner bounds for camera centering
},
{
// Bottom Left Section
x: 10, y: 15, icon: 'skills', name: 'Skills',
bounds: { minX: 2, maxX: 17, minY: 12, maxY: 18 }, // Outer bounds for detection
innerBounds: { minX: 3, maxX: 16.5, minY: 13, maxY: 16.5 } // Inner bounds for camera centering
},
{
// Bottom Right Section
x: 30, y: 15, icon: 'about-me', name: 'About Me',
bounds: { minX: 22, maxX: 38, minY: 12, maxY: 18 }, // Outer bounds for detection
innerBounds: { minX: 23, maxX: 36.5, minY: 13, maxY: 16.5 } // Inner bounds for camera centering
},
];
this.sectionIcons = [];
sections.forEach((section, index) => {
// Create the icon
const icon = this.add.image(0, 0, section.icon);
icon.setScale(0.3);
icon.setAlpha(0.9);
// Create glow effect using multiple copies
const glow1 = this.add.image(0, 0, section.icon);
const glow2 = this.add.image(0, 0, section.icon);
const glow3 = this.add.image(0, 0, section.icon);
// Set glow properties
glow1.setScale(0.6).setAlpha(0.3).setTint(0x00ffff);
glow2.setScale(0.7).setAlpha(0.2).setTint(0x0080ff);
glow3.setScale(0.8).setAlpha(0.1).setTint(0x8000ff);
// Create blur effect container
const blurContainer = this.add.container(0, 0);
blurContainer.add([glow3, glow2, glow1, icon]);
// Store section data
const sectionData = {
container: blurContainer,
icon: icon,
glows: [glow1, glow2, glow3],
tileX: section.x,
tileY: section.y,
name: section.name,
isRevealed: false,
contentContainer: null, // Container for section heading & content
originalY: 0, // Will be set properly in resize()
index: index, // Store index for animations
bounds: section.bounds, // Store bounds for proximity detection
innerBounds: section.innerBounds // Store inner bounds for camera centering
};
this.sectionIcons.push(sectionData);
this.sectionIconsContainer.add(blurContainer);
});
}
createSectionData() {
// Define custom data for each section
this.sectionData = {
'Work Experience': [
{
logo: 'smartbridge-logo',
title: 'Machine Learning Intern',
company: 'Smartbridge',
period: 'June 2019 - July 2019',
description: 'Developed a facial recognition module using Python, OpenCV and Scikit-Learn for tackling identity theft via facial spoofing attacks in biometric authentication systems.',
technologies: ['OpenCV', 'scikit-learn', 'NumPy', 'Pandas', 'Matplotlib', 'PyTorch', 'TensorFlow'],
achievements: [
'Developed a facial recognition module using OpenCV & NumPy for data analytics and data modeling.',
'Implemented anomaly detection algorithms using scikit-learn and PyTorch, testing & refining the model\'s problem solving aptitude to achieve optimal accuracy based on the confusion matrix, thereby mitigating identity theft risks.',
]
},
{
logo: 'serc-logo',
title: 'Full Stack Developer',
company: 'SERC, IIIT Hyderabad',
period: 'June 2020 - July 2020',
description: 'Developed interactive web interfaces for programming lab simulations and contributed to the Virtual Labs platform at IIIT Hyderabad, making coding concepts more interactive for students.',
technologies: ['JavaScript', 'TypeScript', 'React', 'Node.js', 'Express.js', 'Socket.io', 'MongoDB'],
achievements: [
'Resolved front-end bugs for Virtual Labs at IIIT Hyderabad, enhancing user experience and system stability.',
'Developed efficient REST APIs with query-parameter optimization & lazy-loading and evaluated the scalability of various technologies in internal projects.',
]
},
{
logo: 'forcepoint-logo',
title: 'Software Engineer',
company: 'Forcepoint',
period: 'July 2022 - August 2024',
description: 'Developed and maintained cybersecurity solutions using design patterns like CQRS & DDD. Worked on threat detection systems and user interface improvements for Remote Browser Isolation (RBI) and Cloud Access Security Broker (CASB).',
technologies: ['JavaScript', 'TypeScript', 'React', 'Node.js', 'Python', 'AWS', 'Kubernetes', 'Kafka', 'Docker', 'Memcached', 'Redis', 'MongoDB', 'MariaDB', 'Amazon RDS'],
achievements: [
'Products : RBI (Remote Browser Isolation) & CASB (Cloud Access Security Broker)',
'Migrated RBI codebase to cloud infrastructure and implemented AWS latency-based load balancing, enabling access to over a million daily end-users from any device globally, increasing user reach by 50% and reducing downtime by 20%.',
'Incorporated Antivirus, OPSWAT, and deep-secure scanning support, ensuring security compliance by processing over 500,000 scans weekly and ensuring 100% safe downloads through CDR and remote rendering of popular file formats.',
'Revamped CASB\'s monolithic architecture into an event-driven CQRS architecture using Golang, improving system responsiveness by 30%, eliminating testing framework bottlenecks and increasing scalability for future growth & load.'
]
},
{
logo: 'ucr-logo',
title: 'Research Assistant',
company: 'UC Riverside',
period: 'Jun 2025 - Present',
description: 'Built and optimized ML pipelines on HPCC Linux servers for large-scale genomic data, leveraging Bash scripting and CUDA libraries to accelerate training and inference of foundational models.',
technologies: ['Pytorch', 'TensorFlow', 'HuggingFace', 'WandB', 'LangChain'],
achievements: [
'Designed & Developed Transformer & VAE based ML models for scRNA-Seq data to model viral-host interactions.',
'Leveraged Contrastive Learning to extract latent biological features, boosting cellular differentiation prediction rate.',
'Integrated MLOps and workflow orchestration with Databricks, Prometheus, and W&B to streamline ML pipelines.'
]
}
],
'Projects': [
{
logo: 'mentorAI-logo',
title: 'MentorAI',
description: 'An AI-powered, multilingual learning platform that uses LLMs, RAGs, Agents and Voice Interactions for generating adaptive lessons & quizzes, and tracks students progress in real-time with teacher dashboards & AI tutors.',
technologies: ['Supabase', 'Groq', 'Anthropic Claude', 'Fetch.ai Agentverse', 'Google TTS', 'Python', 'FastAPI', 'React', 'Next.js', 'Tailwind CSS', 'TypeScript', 'Docker', 'Kubernetes', 'PostgreSQL', 'MySQL', 'MongoDB', 'SQLite'],
achievements: [
'Built an LLM-based RAG agent that generates adaptive coursework and quizzes from trusted curricula, tracks learning gaps in agent state, personalizes revisions, and alerts teachers when core concepts need intervention.',
'Developed multilingual voice and text interfaces with speech-to-text and text-to-speech pipelines, making learning more accessible for students from diverse and underserved backgrounds.',
'Designed adaptive feedback and progress-tracking workflows that continuously refine learning paths in real time, helping learners stay engaged and measure improvement clearly.',
],
url: 'https://github.com/ABCoder1/mentorAI'
},
{
logo: 'sensAI-search-logo',
title: 'SensAI Search',
description: 'A bi-directional multimodal search engine leveraging embedding fine-tuning, OOD (Out Of Distribution) detection, and image segmentation for localized, context-aware queries like "images where I\'m wearing a red hat."',
technologies: ['Python', 'FastAPI', 'React', 'Redis', 'S3', 'Docker', 'Kubernetes', 'WandB,', 'HuggingFace,'],
achievements: [
'Engineered a bi-directional multimodal search engine, optimizing a CLIP backbone with contrastive learning, foreground segmentation via SAM, object-level embeddings, and prompt refinement to boost retrieval accuracy and relevance.',
'Integrated OOD detection to evaluate result confidence and deployed a diffusion model to generate images when queries were valid but missing in the database.',
'Built a FastAPI web application with Redis caching and S3-backed storage for user-generated images, and implemented an FSSAI index for high-speed similarity search and efficient image retrieval.',
],
url: 'https://github.com/AB-at-UCR/SensAISearch'
},
{
logo: 'zk-charity-logo',
title: 'ZK Charity',
description: 'A decentralized charity platform leveraging ZK proofs for transparent, verifiable donations and impact tracking.',
technologies: ['Python', 'Midnight Blockchain', 'Smart Contracts', 'React', 'Compact Compiler', 'Docker', 'Kubernetes', 'PyTorch', 'TensorFlow', 'LangChain'],
achievements: [
'Architected a privacy-preserving donation dApp leveraging Zero-Knowledge Proofs (ZKPs) to enable anonymous contributions while allowing donors to cryptographically prove participation for tax or reputation claims.',
'Integrated Midnight\'s programmable privacy model using $DUST to shield transaction metadata and enable selective disclosure to auditors without exposing sensitive donor or recipient information.',
'Designed and implemented secure smart contract logic and end-to-end verification workflows to ensure transparency, auditability, and compliance without compromising on-chain privacy.',
],
url: 'https://github.com/ABCoder1/ZK-Charity'
},
{
logo: 'chargeWise-logo',
title: 'ChargeWise',
description: 'A reinforcement learning-based system that provides real-time congestion-aware EV charger recommendations to minimize total wait and charging time.',
technologies: ['Python', 'PyTorch', 'Reinforcement Learning', 'Multi-Agent Reinforcement Learning', 'Grid-Interactive Features', 'Dynamic Pricing', 'Adaptive Charge-Rate Optimization'],
achievements: [
'Leveraged Multi-Agent Reinforcement Learning (MARL) to optimize charger utilization and reduce congestion, improving overall user satisfaction and operational efficiency.',
'Built grid-interactive features including a home energy reservoir participation model with user-facing savings and compensation visualization dashboards.',
'Designed and implemented dynamic pricing and adaptive charge-rate optimization to incentivize off-peak usage and reduce public grid load.',
],
url: 'https://github.com/ABCoder1/ChargeWise'
}
],
'Skills': [
{
logo: 'databases',
title: 'Databases',
description: 'Experienced in designing and managing SQL, NoSQL, and vector database systems, including schema design, query optimization, indexing, and data modeling for distributed microservice architectures.',
icons: ['mysql-icon', 'mongodb-icon', 'redis-icon', 'postgresql-icon'],
},
{
logo: 'languages',
title: 'Programming Languages',
description: 'Strong foundation in core CS principles including OOPs, concurrency models, memory management, & multi-paradigm design, with production experience across Go, Python, TypeScript, and C++, building scalable, concurrent systems at Forcepoint and high-performance pipelines at UCR.',
icons: ['python-icon', 'javascript-icon', 'cpp-icon', 'golang-icon'],
},
{
logo: 'technologies',
title: 'Technologies',
description: 'Well versed in developing scalable full-stack solutions by leveraging Next.js and React for dynamic frontends, alongside high-performance FastAPI and Django backends, utilizing Tailwind CSS for responsive, utility-first design.',
icons: ['django-icon', 'fastapi-icon', 'flask-icon', 'nextjs-icon', 'node-js-icon', 'vue-js-icon', 'tailwind-css-icon', 'react-icon'],
},
{
logo: 'tools',
title: 'Tools',
description: 'Specializing in architecting scalable, agentic AI solutions via RAG and MCP, supported by robust MLOps and DevOps practices using Databricks, MLflow, and automated CI/CD pipelines.',
icons: ['kubernetes-icon', 'wandb-icon', 'jenkins-icon', 'docker-icon', 'mlflow-icon', 'langchain-icon', 'anthropic-mcp-icon', 'databricks-icon'],
}
],
'About Me': [
{
logo: 'github-logo',
title: 'Github',
url: 'https://github.com/ABCoder1'
},
{
logo: 'linkedin-logo',
title: 'LinkedIn',
url: 'https://www.linkedin.com/in/aditya-bhardwaj-57243217b/'
},
{
logo: 'resume-logo',
title: 'Resume',
url: 'https://drive.google.com/file/d/1xW9oG2jf3oZRbh0avNfpNQaYZfHylKc5/view?usp=sharing'
}
]
};
}
createSectionContent(section) {
if (!this.sectionData[section.name]) {
console.log('No section data found for:', section.name);
return;
}
const sectionItems = this.sectionData[section.name];
// Create container for all orbs in this section
section.orbsContainer = this.add.container(0, 0);
section.orbs = [];
// Calculate section bounds in WORLD coordinates
const innerBounds = section.innerBounds;
const tileSize = 32 * this.currentScale;
// Calculate the actual section dimensions in world coordinates
const sectionWorldWidth = (innerBounds.maxX - innerBounds.minX + 1) * tileSize;
const sectionWorldHeight = (innerBounds.maxY - innerBounds.minY + 1) * tileSize;
// Orb area settings - only use a portion of the section for orbs
const orbAreaWidth = sectionWorldWidth * 0.8; // 80% of inner section width
const orbAreaHeight = sectionWorldHeight * 0.4; // 40% of inner section height
// Calculate grid layout
const numOrbs = sectionItems.length;
const maxOrbsPerRow = Math.min(4, numOrbs);
const numRows = Math.ceil(numOrbs / maxOrbsPerRow);
// Calculate cell dimensions
const cellWidth = orbAreaWidth / maxOrbsPerRow;
const cellHeight = orbAreaHeight / numRows;
// For debug purposes - shows the orb area and grid
const debug = false;
if (debug) {
const debugGraphics = this.add.graphics();
// Inner bounds (green)
debugGraphics.lineStyle(2, 0x00ff00, 0.7);
debugGraphics.strokeRect(
- sectionWorldWidth/2,
- sectionWorldHeight/2 + 85,
sectionWorldWidth,
sectionWorldHeight
);
// Orb area (blue) -- Hidden below yellow table
debugGraphics.lineStyle(2, 0x0000ff, 0.7);
debugGraphics.strokeRect(
-orbAreaWidth/2,
-orbAreaHeight/2 + 85, // Since, orb positioning is offseted at +85
orbAreaWidth,
orbAreaHeight
);
// Table grid cells (yellow) - RELATIVE positioning
debugGraphics.lineStyle(1, 0xffff00, 0.7);
for (let r = 0; r < numRows; r++) {
// Calculate orbs in this row
const orbsInThisRow = (r === numRows-1)
? (numOrbs - (numRows-1) * maxOrbsPerRow)
: maxOrbsPerRow;
// Calculate row offset to center cells
const rowOffset = (maxOrbsPerRow - orbsInThisRow) * cellWidth / 2;
for (let c = 0; c < orbsInThisRow; c++) {
debugGraphics.strokeRect(
-orbAreaWidth/2 + rowOffset + c * cellWidth,
-orbAreaHeight/2 + 85 + r * cellHeight, // +85 to match orb offset
cellWidth,
cellHeight
);
}
}
// Section center (red dot)
debugGraphics.fillStyle(0xff0000, 1);
debugGraphics.fillCircle(0, 85, 5);
section.orbsContainer.add(debugGraphics);
}
// Create orbs
sectionItems.forEach((item, index) => {
// Calculate grid position
const row = Math.floor(index / maxOrbsPerRow);
const col = index % maxOrbsPerRow;
// Calculate how many orbs are in this row (last row might have fewer)
const orbsInThisRow = (row === numRows-1)
? (numOrbs - (numRows-1) * maxOrbsPerRow)
: maxOrbsPerRow;
// Center orbs in each row
const rowOffset = (maxOrbsPerRow - orbsInThisRow) * cellWidth / 2;
// Calculate RELATIVE position within the orb area
const orbX = -orbAreaWidth/2 + rowOffset + (col + 0.5) * cellWidth;
const orbY = -orbAreaHeight/2 + (row + 0.5) * cellHeight + 85; // +85 to position below heading
// Create floating orb
const orb = this.add.image(0, 0, item.logo);
orb.setScale(0.07); // Small size
orb.setAlpha(0.9);
// Create cooldown meter graphics
const cooldownMeter = this.add.graphics();
cooldownMeter.setAlpha(0); // Initially invisible
cooldownMeter.setDepth(10); // Ensure it's visible above the orb
// Create orb container at calculated position
const orbContainer = this.add.container(orbX, orbY);
orbContainer.add([orb, cooldownMeter]);
// Store orb data
const orbObject = {
container: orbContainer,
orb: orb,
cooldownMeter: cooldownMeter,
glows: [],
data: item,
isInteracted: false,
canInteract: true,
originalX: orbX,
originalY: orbY,
originalAlpha: 0.9,
isInCooldown: false,
cooldownProgress: 0
};
section.orbs.push(orbObject);
section.orbsContainer.add(orbContainer);
// Add physics body for collision detection
this.physics.add.existing(orbContainer);
orbContainer.body.setSize(30, 30); // Small collision area
orbContainer.body.setImmovable(true);
// Collision with Pacman - keep reference to collider per orb
const overlapCollider = this.physics.add.overlap(this.pacman, orbContainer, () => {
this.handleOrbInteraction(orbObject, section);
});
orbObject.overlapCollider = overlapCollider;
});
// Adding orbs to section content for proper cleanup
if (section.contentContainer) {
section.contentContainer.add(section.orbsContainer);
}
// Start orb animations
this.startOrbAnimations(section);
}
// Animation for orbs
startOrbAnimations(section) {
section.orbs.forEach(orb => {
// Floating animation
this.tweens.add({
targets: orb.container,
y: orb.originalY + 2, // Subtle movement
duration: 1500,
yoyo: true,
repeat: -1,
ease: 'Sine.easeInOut'
});
});
}
// Start cooldown visual effect on an orb
startCooldownVisual(orbObject) {
if (!orbObject || !orbObject.orb || !orbObject.cooldownMeter) return;
orbObject.isInCooldown = true;
orbObject.cooldownProgress = 0;
// Fade the orb (reduce alpha)
orbObject.orb.setAlpha(0.3);
// Show the cooldown meter and animate its appearance
orbObject.cooldownMeter.setAlpha(1);
const COOLDOWN_DURATION = 1200; // milliseconds
const METER_RADIUS = 20; // Radius of the circular meter
const METER_WIDTH = 3; // Width of the arc
const METER_COLOR = 0x00FFFF; // Cyan color for the meter
// Animate the cooldown progress
const startTime = this.time.now;
const updateCooldown = () => {
if (!orbObject.isInCooldown || !orbObject.cooldownMeter) return;
const elapsed = this.time.now - startTime;
orbObject.cooldownProgress = Math.min(elapsed / COOLDOWN_DURATION, 1);
// Clear previous drawings
orbObject.cooldownMeter.clear();
// Draw the cooldown progress arc
if (orbObject.cooldownProgress > 0) {
orbObject.cooldownMeter.lineStyle(METER_WIDTH, METER_COLOR, 1);
// Calculate the end angle (in radians)
// Starting from top (-Math.PI/2), going clockwise
const startAngle = -Math.PI / 2;
const endAngle = startAngle + (orbObject.cooldownProgress * 2 * Math.PI);
// Draw the arc
orbObject.cooldownMeter.arc(
0, 0, // Center of the orb
METER_RADIUS, // Radius
startAngle, // Start angle
endAngle, // End angle
false // Anticlockwise
);
orbObject.cooldownMeter.strokePath();
}
// Continue updating until cooldown is complete
if (orbObject.cooldownProgress < 1) {
this.time.addEvent({
delay: 16, // ~60fps
callback: updateCooldown,
callbackScope: this
});
}
};
// Start the cooldown update loop
updateCooldown();
}
// End cooldown visual effect on an orb
endCooldownVisual(orbObject) {
if (!orbObject || !orbObject.orb || !orbObject.cooldownMeter) return;
orbObject.isInCooldown = false;
// Restore the orb's original alpha with a smooth transition
this.tweens.add({
targets: orbObject.orb,
alpha: orbObject.originalAlpha,
duration: 300,
ease: 'Power2.easeOut'
});
// Hide the cooldown meter with a fade out
this.tweens.add({
targets: orbObject.cooldownMeter,
alpha: 0,
duration: 200,
ease: 'Power2.easeOut',
onComplete: () => {
orbObject.cooldownMeter.clear();
orbObject.cooldownProgress = 0;
}
});
}
// Interaction handler when Pacman touches an orb
handleOrbInteraction(orbObject, section) {
if (orbObject.isInteracted || this.overlayOpen || !orbObject.canInteract) return;
orbObject.isInteracted = true;
// Disable this orb's overlap collider to avoid immediate retrigger while Pacman overlaps
if (orbObject.overlapCollider) {
orbObject.overlapCollider.active = false;
}
this.showOverlay(orbObject, section);
// Visual feedback for interaction
this.tweens.add({
targets: orbObject.container,
scale: 1.3,
duration: 200,
yoyo: true,
ease: 'Power2'
});
}
// Show overlay with details
showOverlay(orbObject, section) {
// Close any existing overlay first
if (this.overlayOpen) {
this.closeOverlay();
// Wait a moment for cleanup to complete
// this.time.delayedCall(200, () => {
// this.createNewOverlay(orbObject, section);
// });
return;
}
this.createNewOverlay(orbObject, section);
}
createNewOverlay(orbObject, section) {
// Safety check - don't create overlay if one already exists
if (this.overlayOpen || this.overlayBg || this.overlayContainer) {
console.log('Overlay already exists, skipping creation');
return;
}
this.overlayOpen = true;
orbObject.canInteract = false;
const data = orbObject.data;
// Get current camera properties
const camera = this.cameras.main;
// Create overlay background - covers the entire visible area
this.overlayBg = this.add.graphics();
this.overlayBg.fillStyle(0x000000, 0.7);
this.overlayBg.fillRect(0, 0, camera.width, camera.height);
this.overlayBg.setScrollFactor(0); // Fixed to camera
this.overlayBg.setDepth(1000); // Ensure it's on top
const overlayWidth = Math.min(camera.width * 0.6, 350);
const overlayHeight = Math.min(camera.height * 0.35, 250);
// Store overlay height for continuous keyboard scrolling
this.currentOverlayHeight = overlayHeight;
// Create overlay container at SCREEN CENTER
this.overlayContainer = this.add.container(camera.width / 2, camera.height / 2);
this.overlayContainer.setScrollFactor(0); // Fixed to camera
this.overlayContainer.setDepth(1001); // Ensure it's above background
// Create window background with neon border
const overlayWindow = this.add.graphics();
overlayWindow.fillStyle(0x001122, 0.95);
overlayWindow.lineStyle(3, 0x00ffff, 1);
overlayWindow.fillRoundedRect(-overlayWidth/2, -overlayHeight/2, overlayWidth, overlayHeight, 15);
overlayWindow.strokeRoundedRect(-overlayWidth/2, -overlayHeight/2, overlayWidth, overlayHeight, 15);
overlayWindow.setDepth(1002); // Ensure it's above the overlayContainer
// Create non-scrollable content container
this.nonScrollableContent = this.add.container(0, 0);
this.nonScrollableContent.setScrollFactor(0); // Fixed to camera
this.nonScrollableContent.setDepth(1002); // Ensure it's above the overlayWindow & overlayContainer
// Position main content container at the top
this.nonScrollableContent.setPosition(-overlayWidth/2, -overlayHeight/2);
this.nonScrollableContent.setSize(overlayWidth, overlayHeight/2);
// Create scrollable content container
this.scrollableContent = this.add.container(0, 0);
this.scrollableContent.setScrollFactor(0); // Fixed to camera
this.scrollableContent.setDepth(1002); // Ensure it's above the overlayWindow & overlayContainer
// Position scrollable content in the lower half of the OverlayContainer
this.scrollableContent.setPosition(-overlayWidth/2, 0);
this.scrollableContent.setSize(overlayWidth, overlayHeight/2);
// draw a red rectangle around the scrollableContent
const debugForScrollableContent = false;
if (debugForScrollableContent) {
const debugGraphics = this.add.graphics();
debugGraphics.lineStyle(2, 0xff0000, 0.7);
debugGraphics.strokeRect(
5,
5,
overlayWidth,
overlayHeight/2
);
debugGraphics.setDepth(1005); // Ensure it's above the scrollableContent
this.scrollableContent.add(debugGraphics);
// debugGraphics.setPosition(-overlayWidth/2, -overlayHeight/2);
}
// Calculate text scaling for your specific overlay size - much smaller text
const textScale = Math.max(0.5, Math.min(1, overlayWidth / 350));
// const textScale = 1;
// Content positioning - start from top with appropriate padding
let startYInContainer = 20;
let currentY = startYInContainer; // Start from top with smaller padding
const contentPadding = 20;
const lineSpacing = 10; // Smaller line spacing
const sectionTitleSize = Math.floor(12 * textScale);
const bodySize = Math.floor(10 * textScale);
// Add logo at top
let logo = null;
if (data.logo) {
logo = this.add.image(overlayWidth/2, currentY + contentPadding, data.logo);
logo.setScale(0.07 * textScale);
currentY += contentPadding + 2*lineSpacing;
}
// Add title
let title = null;
if (data.title){
const titleSize = Math.floor(14 * textScale);
title = this.add.text(overlayWidth/2, currentY + contentPadding, data.title, {
fontSize: `${titleSize}px`,
fill: '#FFE400',
// fontFamily: this.fontLoaded ? 'Pixelify Sans' : 'Arial',
fontFamily: 'Monaco',
fontWeight: 'bold'
}).setOrigin(0.5);
currentY += 2*lineSpacing;
}
// Add company and period
let company = null;
if (data.company && data.period) {
const subtitleSize = Math.floor(10 * textScale);
company = this.add.text(overlayWidth/2, currentY + contentPadding, `${data.company} | ${data.period}`, {
fontSize: `${subtitleSize}px`,
fill: '#00FFFF',
// fontFamily: this.fontLoaded ? 'Pixelify Sans' : 'Arial'
fontFamily: 'Monaco'
}).setOrigin(0.5);
currentY += lineSpacing;
}
// Reset position for scrollableContent container
currentY = 0;
currentY += contentPadding; // Add additional padding from the top
// Add description
let description = null;
if (data.description) {
description = this.add.text(overlayWidth/2, currentY + contentPadding, data.description, { // We use overlayHeight/4 here because our description itself takes 4 lines of space
fontSize: `${bodySize}px`,
fill: '#FFFFFF',
// fontFamily: this.fontLoaded ? 'Pixelify Sans' : 'Arial',
fontFamily: 'Monaco',
wordWrap: { width: overlayWidth - contentPadding * 2 },
align: 'center'
}).setOrigin(0.5);
currentY += 2*contentPadding + lineSpacing;
}
// Add technologies
let techTitle = null;
let technologies = null;
if (data.technologies) {
techTitle = this.add.text(overlayWidth/2, currentY + contentPadding + lineSpacing, 'Technologies:', {
fontSize: `${sectionTitleSize}px`,
fill: '#FFE400',
// fontFamily: this.fontLoaded ? 'Pixelify Sans' : 'Arial',
fontFamily: 'Monaco',
fontWeight: 'bold'
}).setOrigin(0.5);
currentY += 2*contentPadding + 2*lineSpacing;
// Add technologies list
technologies = this.add.text(overlayWidth/2, currentY + contentPadding, data.technologies.join(' • '), {
fontSize: `${bodySize}px`,
fill: '#00FF00',
// fontFamily: this.fontLoaded ? 'Pixelify Sans' : 'Arial',
fontFamily: 'Monaco',
wordWrap: { width: overlayWidth - contentPadding * 2 },
align: 'center'
}).setOrigin(0.5);
const techHeight = technologies.height;
currentY += techHeight + 2*lineSpacing;
}
// Add achievements
let achieveTitle = null;
let achievements = null;
if (data.achievements) {
achieveTitle = this.add.text(overlayWidth/2, currentY + contentPadding, 'Key Achievements:', {
fontSize: `${sectionTitleSize}px`,
fill: '#FFE400',
// fontFamily: this.fontLoaded ? 'Pixelify Sans' : 'Arial',
fontFamily: 'Monaco',
fontWeight: 'bold'
}).setOrigin(0.5);
currentY += 2*lineSpacing;
achievements = this.add.text(overlayWidth/2, currentY + contentPadding, data.achievements.map(a => `• ${a}`).join('\n\n'), {
fontSize: `${bodySize}px`,
fill: '#FFFFFF',
// fontFamily: this.fontLoaded ? 'Pixelify Sans' : 'Arial',
fontFamily: 'Arial',
wordWrap: { width: overlayWidth - contentPadding * 2 },
align: 'left',
lineSpacing: 2
}).setOrigin(0.5, 0);
const achievementsHeight = achievements.height;
currentY += achievementsHeight + lineSpacing;
}
// Add URL
let openLinkPrompt = null;
let openLinkYesText = null;
let openLinkNoText = null;
this.currentOverlayUrl = null;
this.openLinkSelectionBox = null;
this.openLinkYesText = null;
this.openLinkNoText = null;
this.openLinkSelectedIndex = 0;
this.openLinkNavKeys = null;
if (data.url) {
this.currentOverlayUrl = data.url;
// Prompt text
const promptY = currentY + contentPadding + lineSpacing; // earlier : overlayHeight/2 - 48
openLinkPrompt = this.add.text(overlayWidth/2, promptY, 'Open this in a new tab?', {
fontSize: `${bodySize}px`,
fill: '#FFE400',
fontFamily: 'Monaco',
fontStyle: 'bold'
}).setOrigin(0.5);
// Yes / No option texts
// const optionsY = overlayHeight/2 - 30;
const optionsY = promptY + contentPadding + 0.50*lineSpacing;
const optionFontSize = Math.floor(8 * textScale);
openLinkYesText = this.add.text(overlayWidth/2 - 40, optionsY, 'YES', {
fontSize: `${optionFontSize}px`,
fill: '#FFFFFF',
fontFamily: 'Monaco',
fontStyle: 'italic'
}).setOrigin(0.5);
openLinkNoText = this.add.text(overlayWidth/2 + 40, optionsY, 'NO', {
fontSize: `${optionFontSize}px`,
fill: '#FFFFFF',
fontFamily: 'Monaco',
fontStyle: 'italic'
}).setOrigin(0.5);
// Create a selection box that will highlight the currently selected option
this.openLinkSelectionBox = this.add.graphics();
// this.openLinkSelectionBox.setSize(openLinkYesText.width + 24, openLinkYesText.height + 12);
// this.openLinkSelectionBox.fillRoundedRect(-openLinkYesText.width/2, -openLinkYesText.height/2, openLinkYesText.width, openLinkYesText.height, 5);
// this.openLinkSelectionBox.strokeRoundedRect(-openLinkYesText.width/2, -openLinkYesText.height/2, openLinkYesText.width, openLinkYesText.height, 5);
this.openLinkSelectionBox.lineStyle(2, 0xff0000, 0.7);
this.openLinkSelectionBox.strokeRect(
-openLinkYesText.width/2,
-openLinkYesText.height/2,
openLinkYesText.width,
openLinkYesText.height
);
this.openLinkSelectionBox.setDepth(1004);
this.openLinkYesText = openLinkYesText;
this.openLinkNoText = openLinkNoText;
this.openLinkSelectedIndex = 0; // 0 = YES, 1 = NO
// Initialize selection highlight around YES
this.setOpenLinkSelection(0);
// Create nav keys for selection (handled in update via JustDown)
const aKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A);
const dKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D);
const leftKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.LEFT);
const rightKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.RIGHT);
this.openLinkNavKeys = { A: aKey, D: dKey, LEFT: leftKey, RIGHT: rightKey };
// Advance currentY to the bottom of the URL prompt (prompt line + options line + padding)
currentY = optionsY;
}
// Add Icons in a 4x2 grid with hidden borders
const gridCols = 4;
let gridRows = 2;
const iconScale = 0.05 * textScale;
const cellHeight = 40;
let icons = [];
this.overlayIconImages = null;
if (data.icons && data.icons.length > 0) {
const cellWidth = overlayWidth / gridCols;
const iconsStartY = currentY + contentPadding;
currentY += contentPadding;
data.icons.forEach((iconKey, index) => {
const col = index % gridCols;
const row = Math.floor(index / gridCols);
gridRows = row+1;
const x = (col + 0.5) * cellWidth;
const y = iconsStartY + (row + 1) * (cellHeight + 2*lineSpacing);
const img = this.add.image(x, y, iconKey).setScale(iconScale);
icons.push(img);
});
currentY += gridRows * (cellHeight + 2*contentPadding);
this.overlayIconImages = icons;
}
// Add non-scrollable content elements to main content container