var Altman = Container.expand(function () { var self = Container.call(this); var altmanGraphics = self.createAsset('altman', 'Altman character', .5, .5); self.vx = 15; self.vy = 15; var altmanLabel = new Text2('Sam', { size: 50, fill: '#ffffff' }); altmanLabel.x = altmanGraphics.x - altmanLabel.width / 2; altmanLabel.y = altmanGraphics.y + altmanGraphics.height / 2; self.addChild(altmanLabel); self.move = function () { self.x += self.vx; self.y += self.vy; if (self.x < 0 || self.x > 2048) { self.vx *= -1; } if (self.y < 0 || self.y > 2732) { self.vy *= -1; } }; self.update = function () { self.move(); }; }); var OpenAI = Container.expand(function () { var self = Container.call(this); var openAIGraphics = self.createAsset('openai', 'OpenAI logo', .5, .5); var openAILabel = new Text2('OpenAI', { size: 50, fill: '#ffffff' }); openAILabel.y = openAIGraphics.height; self.addChild(openAILabel); self.update = function (altman) { if (altman.vx < 0) { if (altman.y < self.y && self.y > 0) { self.y -= 15; } if (altman.y > self.y && self.y < 2732 - self.height) { self.y += 15; } if (self.y < 0) { self.y = 0; } if (self.y > 2732 - self.height) { self.y = 2732 - self.height; } } openAILabel.x = openAIGraphics.x - openAILabel.width / 2; openAILabel.y = openAIGraphics.y + openAIGraphics.height / 2; }; }); var Microsoft = Container.expand(function () { var self = Container.call(this); var microsoftGraphics = self.createAsset('microsoft', 'Microsoft logo', .5, .5); var microsoftLabel = new Text2('Microsoft', { size: 50, fill: '#ffffff' }); microsoftLabel.y = microsoftGraphics.height; self.addChild(microsoftLabel); self.update = function (altman) { microsoftLabel.x = microsoftGraphics.x - microsoftLabel.width / 2; microsoftLabel.y = microsoftGraphics.y + microsoftGraphics.height / 2; }; }); var Game = Container.expand(function () { var self = Container.call(this); LK.stageContainer.setBackgroundColor(0x000000); var altman = self.addChild(new Altman()); altman.x = 2048 / 2; altman.y = 2732 / 2; altman.vx = 0; altman.vy = 0; var openAI = self.addChild(new OpenAI()); openAI.x = 150; openAI.y = 2732 / 2 - openAI.height / 2; var microsoft = self.addChild(new Microsoft()); microsoft.x = 2048 - microsoft.width + 150; microsoft.y = 2732 / 2 - microsoft.height / 2; var startMoving = false; var startMovingTimeout = LK.setTimeout(function () { startMoving = true; var angle; do { angle = Math.random() * Math.PI * 2; altman.vx = 10 * Math.cos(angle); altman.vy = 10 * Math.sin(angle); } while (Math.abs(altman.vx) < 3 || Math.abs(altman.vy) < 3); }, 500); stage.on('down', function (obj) { var pos = obj.event.getLocalPosition(self); if (pos.x > 2048 / 2) { microsoft.y = pos.y - microsoft.height / 2; } }); stage.on('move', function (obj) { var pos = obj.event.getLocalPosition(self); if (pos.x > 2048 / 2) { microsoft.y = pos.y - microsoft.height / 2; } }); LK.on('tick', function () { if (startMoving) { altman.update(); } openAI.update(altman); microsoft.update(altman); if (altman.intersects(openAI)) { var diffY = altman.y - openAI.y; altman.vx *= -1; altman.vy = diffY / openAI.height * 10; } if (altman.intersects(microsoft)) { var diffY = altman.y - microsoft.y; altman.vx *= -1; altman.vy = diffY / microsoft.height * 10; } if (altman.x > 2048 - altman.width) { LK.showGameOver(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -117,6 +117,9 @@
var diffY = altman.y - microsoft.y;
altman.vx *= -1;
altman.vy = diffY / microsoft.height * 10;
}
+ if (altman.x > 2048 - altman.width) {
+ LK.showGameOver();
+ }
});
});
sam altman head Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
openai logo inside of a pong paddle Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
microsoft logo inside of a pong paddle Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.