/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var PowerpuffGirl = Container.expand(function (color, startX) { var self = Container.call(this); var girl = self.attachAsset(color === 0xFF69B4 ? 'powerpuffGirl1' : color === 0x87CEEB ? 'powerpuffGirl2' : 'powerpuffGirl3', { anchorX: 0.5, anchorY: 1.0 }); self.x = startX; self.y = 2732 - 100; self.baseY = self.y; self.floatOffset = Math.random() * Math.PI * 2; self.update = function () { self.y = self.baseY + Math.sin(LK.ticks * 0.05 + self.floatOffset) * 10; }; return self; }); var ScanLine = Container.expand(function () { var self = Container.call(this); var line = self.attachAsset('scanLine', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); self.speed = 15; self.update = function () { self.y += self.speed; if (self.y > screenBottom + 10) { self.y = screenTop - 10; } }; return self; }); var StaticLine = Container.expand(function () { var self = Container.call(this); var line = self.attachAsset('staticLine', { anchorX: 0.5, anchorY: 0.5, alpha: 0.3 }); self.speed = Math.random() * 10 + 5; self.update = function () { self.y += self.speed; self.alpha = Math.random() * 0.5 + 0.1; if (self.y > screenBottom + 50) { self.y = screenTop - 50; self.x = Math.random() * 1200 + screenLeft; } }; return self; }); var YogiBear = Container.expand(function () { var self = Container.call(this); var bear = self.attachAsset('yogiBear', { anchorX: 0.5, anchorY: 0.5 }); self.x = 1024; self.y = screenTop + 450; self.baseX = self.x; self.visible = false; self.update = function () { if (self.visible) { self.x = self.baseX + Math.sin(LK.ticks * 0.03) * 20; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ // TV positioning var tvCenterX = 1024; var tvCenterY = 1200; // Screen boundaries var screenLeft = tvCenterX - 600; var screenRight = tvCenterX + 600; var screenTop = tvCenterY - 450; var screenBottom = tvCenterY + 450; // Create TV stand var tvStand = game.addChild(LK.getAsset('tvStand', { anchorX: 0.5, anchorY: 0.5, x: tvCenterX, y: 2200 })); // Create TV frame var tvFrame = game.addChild(LK.getAsset('tvFrame', { anchorX: 0.5, anchorY: 0.5, x: tvCenterX, y: tvCenterY })); // Create TV screen var tvScreen = game.addChild(LK.getAsset('tvScreen', { anchorX: 0.5, anchorY: 0.5, x: tvCenterX, y: tvCenterY })); // Create play button var playButton = game.addChild(LK.getAsset('playButton', { anchorX: 0.5, anchorY: 0.5, x: tvCenterX, y: tvCenterY + 200 })); // Create play button text var playText = new Text2('PLAY', { size: 40, fill: 0xFFFFFF }); playText.anchor.set(0.5, 0.5); playText.x = tvCenterX; playText.y = tvCenterY + 200; game.addChild(playText); // Create Powerpuff Girls var blossom = game.addChild(new PowerpuffGirl(0xFF69B4, 300)); var bubbles = game.addChild(new PowerpuffGirl(0x87CEEB, 1024)); var buttercup = game.addChild(new PowerpuffGirl(0x90EE90, 1748)); // Create Yogi Bear var yogiBear = game.addChild(new YogiBear()); // Static effects var staticLines = []; var scanLines = []; // Game state var isPlaying = false; var staticIntensity = 0.5; // Initialize static lines for (var i = 0; i < 15; i++) { var staticLine = new StaticLine(); staticLine.x = Math.random() * 1200 + screenLeft; staticLine.y = Math.random() * 900 + screenTop; staticLines.push(staticLine); game.addChild(staticLine); } // Initialize scan lines for (var j = 0; j < 5; j++) { var scanLine = new ScanLine(); scanLine.x = tvCenterX; scanLine.y = screenTop + j * 180; scanLines.push(scanLine); game.addChild(scanLine); } // Handle play button press playButton.down = function (x, y, obj) { if (!isPlaying) { isPlaying = true; yogiBear.visible = true; playButton.visible = false; playText.visible = false; LK.getSound('buttonClick').play(); // Reduce static when playing staticIntensity = 0.2; // Add screen color tint for retro effect tween(tvScreen, { tint: 0x003300 }, { duration: 1000 }); // Flash effect LK.effects.flashObject(tvScreen, 0x004400, 500); } }; // TV static effect timer var staticTimer = LK.setInterval(function () { if (Math.random() < 0.1) { LK.getSound('tvStatic').play(); } }, 2000); game.update = function () { // Update static effect intensity for (var i = 0; i < staticLines.length; i++) { var line = staticLines[i]; if (Math.random() < staticIntensity) { line.visible = true; line.alpha = Math.random() * 0.6; } else { line.visible = false; } } // Screen flicker effect if (isPlaying && Math.random() < 0.02) { tvScreen.alpha = 0.9 + Math.random() * 0.1; } // Color distortion effect if (isPlaying && LK.ticks % 120 === 0) { var colors = [0x003300, 0x330033, 0x000033, 0x003333]; var randomColor = colors[Math.floor(Math.random() * colors.length)]; tween(tvScreen, { tint: randomColor }, { duration: 200, onFinish: function onFinish() { tween(tvScreen, { tint: 0x003300 }, { duration: 300 }); } }); } }; // Play ambient retro music LK.playMusic('retroAmbient');
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,219 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var PowerpuffGirl = Container.expand(function (color, startX) {
+ var self = Container.call(this);
+ var girl = self.attachAsset(color === 0xFF69B4 ? 'powerpuffGirl1' : color === 0x87CEEB ? 'powerpuffGirl2' : 'powerpuffGirl3', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.x = startX;
+ self.y = 2732 - 100;
+ self.baseY = self.y;
+ self.floatOffset = Math.random() * Math.PI * 2;
+ self.update = function () {
+ self.y = self.baseY + Math.sin(LK.ticks * 0.05 + self.floatOffset) * 10;
+ };
+ return self;
+});
+var ScanLine = Container.expand(function () {
+ var self = Container.call(this);
+ var line = self.attachAsset('scanLine', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.8
+ });
+ self.speed = 15;
+ self.update = function () {
+ self.y += self.speed;
+ if (self.y > screenBottom + 10) {
+ self.y = screenTop - 10;
+ }
+ };
+ return self;
+});
+var StaticLine = Container.expand(function () {
+ var self = Container.call(this);
+ var line = self.attachAsset('staticLine', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.3
+ });
+ self.speed = Math.random() * 10 + 5;
+ self.update = function () {
+ self.y += self.speed;
+ self.alpha = Math.random() * 0.5 + 0.1;
+ if (self.y > screenBottom + 50) {
+ self.y = screenTop - 50;
+ self.x = Math.random() * 1200 + screenLeft;
+ }
+ };
+ return self;
+});
+var YogiBear = Container.expand(function () {
+ var self = Container.call(this);
+ var bear = self.attachAsset('yogiBear', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = 1024;
+ self.y = screenTop + 450;
+ self.baseX = self.x;
+ self.visible = false;
+ self.update = function () {
+ if (self.visible) {
+ self.x = self.baseX + Math.sin(LK.ticks * 0.03) * 20;
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a1a
+});
+
+/****
+* Game Code
+****/
+// TV positioning
+var tvCenterX = 1024;
+var tvCenterY = 1200;
+// Screen boundaries
+var screenLeft = tvCenterX - 600;
+var screenRight = tvCenterX + 600;
+var screenTop = tvCenterY - 450;
+var screenBottom = tvCenterY + 450;
+// Create TV stand
+var tvStand = game.addChild(LK.getAsset('tvStand', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: tvCenterX,
+ y: 2200
+}));
+// Create TV frame
+var tvFrame = game.addChild(LK.getAsset('tvFrame', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: tvCenterX,
+ y: tvCenterY
+}));
+// Create TV screen
+var tvScreen = game.addChild(LK.getAsset('tvScreen', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: tvCenterX,
+ y: tvCenterY
+}));
+// Create play button
+var playButton = game.addChild(LK.getAsset('playButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: tvCenterX,
+ y: tvCenterY + 200
+}));
+// Create play button text
+var playText = new Text2('PLAY', {
+ size: 40,
+ fill: 0xFFFFFF
+});
+playText.anchor.set(0.5, 0.5);
+playText.x = tvCenterX;
+playText.y = tvCenterY + 200;
+game.addChild(playText);
+// Create Powerpuff Girls
+var blossom = game.addChild(new PowerpuffGirl(0xFF69B4, 300));
+var bubbles = game.addChild(new PowerpuffGirl(0x87CEEB, 1024));
+var buttercup = game.addChild(new PowerpuffGirl(0x90EE90, 1748));
+// Create Yogi Bear
+var yogiBear = game.addChild(new YogiBear());
+// Static effects
+var staticLines = [];
+var scanLines = [];
+// Game state
+var isPlaying = false;
+var staticIntensity = 0.5;
+// Initialize static lines
+for (var i = 0; i < 15; i++) {
+ var staticLine = new StaticLine();
+ staticLine.x = Math.random() * 1200 + screenLeft;
+ staticLine.y = Math.random() * 900 + screenTop;
+ staticLines.push(staticLine);
+ game.addChild(staticLine);
+}
+// Initialize scan lines
+for (var j = 0; j < 5; j++) {
+ var scanLine = new ScanLine();
+ scanLine.x = tvCenterX;
+ scanLine.y = screenTop + j * 180;
+ scanLines.push(scanLine);
+ game.addChild(scanLine);
+}
+// Handle play button press
+playButton.down = function (x, y, obj) {
+ if (!isPlaying) {
+ isPlaying = true;
+ yogiBear.visible = true;
+ playButton.visible = false;
+ playText.visible = false;
+ LK.getSound('buttonClick').play();
+ // Reduce static when playing
+ staticIntensity = 0.2;
+ // Add screen color tint for retro effect
+ tween(tvScreen, {
+ tint: 0x003300
+ }, {
+ duration: 1000
+ });
+ // Flash effect
+ LK.effects.flashObject(tvScreen, 0x004400, 500);
+ }
+};
+// TV static effect timer
+var staticTimer = LK.setInterval(function () {
+ if (Math.random() < 0.1) {
+ LK.getSound('tvStatic').play();
+ }
+}, 2000);
+game.update = function () {
+ // Update static effect intensity
+ for (var i = 0; i < staticLines.length; i++) {
+ var line = staticLines[i];
+ if (Math.random() < staticIntensity) {
+ line.visible = true;
+ line.alpha = Math.random() * 0.6;
+ } else {
+ line.visible = false;
+ }
+ }
+ // Screen flicker effect
+ if (isPlaying && Math.random() < 0.02) {
+ tvScreen.alpha = 0.9 + Math.random() * 0.1;
+ }
+ // Color distortion effect
+ if (isPlaying && LK.ticks % 120 === 0) {
+ var colors = [0x003300, 0x330033, 0x000033, 0x003333];
+ var randomColor = colors[Math.floor(Math.random() * colors.length)];
+ tween(tvScreen, {
+ tint: randomColor
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ tween(tvScreen, {
+ tint: 0x003300
+ }, {
+ duration: 300
+ });
+ }
+ });
+ }
+};
+// Play ambient retro music
+LK.playMusic('retroAmbient');
\ No newline at end of file