User prompt
make the viewpoint triangle
User prompt
add a viewpoint to the teacher if we are in the viewpoint and cheating he will catch us do not make this viewpoint big and show it as transparent red
User prompt
make the teacher a little bit bigger
User prompt
make the teacher bigger
User prompt
make the nerd a little bit bigger
User prompt
make the students a little bit bigger
User prompt
make it bigger
User prompt
make the boar 100 * 100 make it square
User prompt
Those 3 children should be in different rows every round, it should be random but they should be in the desks.
User prompt
Let's say there are 3 more students but they stay where they are and we can't copy from them.
User prompt
add a classroom environment to this, desks and board, desks have hitboxes
Code edit (1 edits merged)
Please save this source code
User prompt
Copying From a Nerd
Initial prompt
make me a "copying from a nerd" game
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Nerd class var Nerd = Container.expand(function () { var self = Container.call(this); // Attach nerd asset (green ellipse) var nerdAsset = self.attachAsset('nerd', { anchorX: 0.5, anchorY: 0.5 }); nerdAsset.width = 120; nerdAsset.height = 120; nerdAsset.color = 0x6be445; // green nerdAsset.shape = 'ellipse'; // Move nerd to a random position in the classroom (with padding) self.moveToRandom = function () { var pad = 180; var nx = pad + Math.random() * (2048 - 2 * pad); var ny = 400 + Math.random() * (2732 - 800); tween(self, { x: nx, y: ny }, { duration: 900 + Math.random() * 800, easing: tween.easeInOut }); }; return self; }); // Student (Player) class var Student = Container.expand(function () { var self = Container.call(this); // Attach student asset (blue box) var studentAsset = self.attachAsset('student', { anchorX: 0.5, anchorY: 0.5 }); // Set color and size studentAsset.width = 140; studentAsset.height = 140; studentAsset.color = 0x3a8ee6; // blue // For possible future use self.radius = 70; return self; }); // Teacher class var Teacher = Container.expand(function () { var self = Container.call(this); // Attach teacher asset (red rectangle) var teacherAsset = self.attachAsset('teacher', { anchorX: 0.5, anchorY: 0.5 }); teacherAsset.width = 180; teacherAsset.height = 180; teacherAsset.color = 0xe64b3a; // red // For patrol direction self.targetX = 0; self.targetY = 0; self.speed = 8 + Math.random() * 4; // Move teacher to a random position in the classroom (with padding) self.moveToRandom = function () { var pad = 180; self.targetX = pad + Math.random() * (2048 - 2 * pad); self.targetY = 400 + Math.random() * (2732 - 800); self.speed = 8 + Math.random() * 4; }; // Teacher patrol update self.update = function () { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 10) { self.moveToRandom(); } else { self.x += dx / dist * self.speed; self.y += dy / dist * self.speed; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf7e7c1 // light classroom color }); /**** * Game Code ****/ // --- Game variables --- var student = new Student(); var nerd = new Nerd(); var teacher = new Teacher(); var dragNode = null; var lastCopying = false; var copyingTimer = 0; var copyScore = 0; var scoreTxt = null; var lastTeacherCaught = false; var copyDistance = 180; // px, how close to nerd to copy var teacherCatchDistance = 220; // px, how close to teacher to get caught var teacherFOV = Math.PI / 2; // 90 degree field of view var teacherVisionDistance = 500; // px, how far teacher can "see" var nerdMoveTimer = 0; // --- Add elements to game --- game.addChild(nerd); game.addChild(student); game.addChild(teacher); // Initial positions student.x = 2048 / 2; student.y = 2732 - 400; nerd.x = 2048 / 2; nerd.y = 900; teacher.x = 2048 / 2; teacher.y = 400; teacher.moveToRandom(); nerd.moveToRandom(); // --- Score display --- scoreTxt = new Text2('0', { size: 120, fill: 0x222222 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // --- Helper functions --- // Distance between two objects function dist(a, b) { var dx = a.x - b.x; var dy = a.y - b.y; return Math.sqrt(dx * dx + dy * dy); } // Angle from teacher to student function angleTo(a, b) { return Math.atan2(b.y - a.y, b.x - a.x); } // Is student in teacher's field of view and close enough? function teacherCanSeeStudent() { var d = dist(teacher, student); if (d > teacherVisionDistance) return false; // Teacher "looks" toward their movement direction (target) var teacherDir = Math.atan2(teacher.targetY - teacher.y, teacher.targetX - teacher.x); var angleToStu = angleTo(teacher, student); var diff = Math.abs(teacherDir - angleToStu); if (diff > Math.PI) diff = 2 * Math.PI - diff; return diff < teacherFOV / 2; } // --- Dragging logic --- function handleMove(x, y, obj) { if (dragNode) { // Clamp to classroom area (avoid top menu) var pad = 100; var minY = 400; var maxY = 2732 - pad; var minX = pad; var maxX = 2048 - pad; dragNode.x = Math.max(minX, Math.min(maxX, x)); dragNode.y = Math.max(minY, Math.min(maxY, y)); } } game.move = handleMove; game.down = function (x, y, obj) { // Only allow drag if not caught if (!lastTeacherCaught) { dragNode = student; handleMove(x, y, obj); } }; game.up = function (x, y, obj) { dragNode = null; }; // --- Main game update --- game.update = function () { // Move nerd occasionally nerdMoveTimer++; if (nerdMoveTimer > 90 + Math.random() * 60) { nerd.moveToRandom(); nerdMoveTimer = 0; } // Teacher patrol teacher.update(); // --- Copying logic --- var copying = false; if (dist(student, nerd) < copyDistance) { copying = true; } // If copying, increment timer and score if (copying) { copyingTimer++; if (copyingTimer % 30 === 0) { // every 0.5s copyScore++; scoreTxt.setText(copyScore); // Win condition if (copyScore >= 30) { LK.showYouWin(); } } // Visual feedback: flash nerd green if (!lastCopying) { LK.effects.flashObject(nerd, 0x00ff00, 400); } } lastCopying = copying; // --- Teacher detection logic --- var teacherCaught = false; // If student is copying and teacher can see and is close enough if (copying && teacherCanSeeStudent() && dist(teacher, student) < teacherCatchDistance) { teacherCaught = true; } if (teacherCaught && !lastTeacherCaught) { // Flash screen red LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } lastTeacherCaught = teacherCaught; };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,225 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Nerd class
+var Nerd = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach nerd asset (green ellipse)
+ var nerdAsset = self.attachAsset('nerd', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ nerdAsset.width = 120;
+ nerdAsset.height = 120;
+ nerdAsset.color = 0x6be445; // green
+ nerdAsset.shape = 'ellipse';
+ // Move nerd to a random position in the classroom (with padding)
+ self.moveToRandom = function () {
+ var pad = 180;
+ var nx = pad + Math.random() * (2048 - 2 * pad);
+ var ny = 400 + Math.random() * (2732 - 800);
+ tween(self, {
+ x: nx,
+ y: ny
+ }, {
+ duration: 900 + Math.random() * 800,
+ easing: tween.easeInOut
+ });
+ };
+ return self;
+});
+// Student (Player) class
+var Student = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach student asset (blue box)
+ var studentAsset = self.attachAsset('student', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Set color and size
+ studentAsset.width = 140;
+ studentAsset.height = 140;
+ studentAsset.color = 0x3a8ee6; // blue
+ // For possible future use
+ self.radius = 70;
+ return self;
+});
+// Teacher class
+var Teacher = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach teacher asset (red rectangle)
+ var teacherAsset = self.attachAsset('teacher', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ teacherAsset.width = 180;
+ teacherAsset.height = 180;
+ teacherAsset.color = 0xe64b3a; // red
+ // For patrol direction
+ self.targetX = 0;
+ self.targetY = 0;
+ self.speed = 8 + Math.random() * 4;
+ // Move teacher to a random position in the classroom (with padding)
+ self.moveToRandom = function () {
+ var pad = 180;
+ self.targetX = pad + Math.random() * (2048 - 2 * pad);
+ self.targetY = 400 + Math.random() * (2732 - 800);
+ self.speed = 8 + Math.random() * 4;
+ };
+ // Teacher patrol update
+ self.update = function () {
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist < 10) {
+ self.moveToRandom();
+ } else {
+ self.x += dx / dist * self.speed;
+ self.y += dy / dist * self.speed;
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xf7e7c1 // light classroom color
+});
+
+/****
+* Game Code
+****/
+// --- Game variables ---
+var student = new Student();
+var nerd = new Nerd();
+var teacher = new Teacher();
+var dragNode = null;
+var lastCopying = false;
+var copyingTimer = 0;
+var copyScore = 0;
+var scoreTxt = null;
+var lastTeacherCaught = false;
+var copyDistance = 180; // px, how close to nerd to copy
+var teacherCatchDistance = 220; // px, how close to teacher to get caught
+var teacherFOV = Math.PI / 2; // 90 degree field of view
+var teacherVisionDistance = 500; // px, how far teacher can "see"
+var nerdMoveTimer = 0;
+// --- Add elements to game ---
+game.addChild(nerd);
+game.addChild(student);
+game.addChild(teacher);
+// Initial positions
+student.x = 2048 / 2;
+student.y = 2732 - 400;
+nerd.x = 2048 / 2;
+nerd.y = 900;
+teacher.x = 2048 / 2;
+teacher.y = 400;
+teacher.moveToRandom();
+nerd.moveToRandom();
+// --- Score display ---
+scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0x222222
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// --- Helper functions ---
+// Distance between two objects
+function dist(a, b) {
+ var dx = a.x - b.x;
+ var dy = a.y - b.y;
+ return Math.sqrt(dx * dx + dy * dy);
+}
+// Angle from teacher to student
+function angleTo(a, b) {
+ return Math.atan2(b.y - a.y, b.x - a.x);
+}
+// Is student in teacher's field of view and close enough?
+function teacherCanSeeStudent() {
+ var d = dist(teacher, student);
+ if (d > teacherVisionDistance) return false;
+ // Teacher "looks" toward their movement direction (target)
+ var teacherDir = Math.atan2(teacher.targetY - teacher.y, teacher.targetX - teacher.x);
+ var angleToStu = angleTo(teacher, student);
+ var diff = Math.abs(teacherDir - angleToStu);
+ if (diff > Math.PI) diff = 2 * Math.PI - diff;
+ return diff < teacherFOV / 2;
+}
+// --- Dragging logic ---
+function handleMove(x, y, obj) {
+ if (dragNode) {
+ // Clamp to classroom area (avoid top menu)
+ var pad = 100;
+ var minY = 400;
+ var maxY = 2732 - pad;
+ var minX = pad;
+ var maxX = 2048 - pad;
+ dragNode.x = Math.max(minX, Math.min(maxX, x));
+ dragNode.y = Math.max(minY, Math.min(maxY, y));
+ }
+}
+game.move = handleMove;
+game.down = function (x, y, obj) {
+ // Only allow drag if not caught
+ if (!lastTeacherCaught) {
+ dragNode = student;
+ handleMove(x, y, obj);
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// --- Main game update ---
+game.update = function () {
+ // Move nerd occasionally
+ nerdMoveTimer++;
+ if (nerdMoveTimer > 90 + Math.random() * 60) {
+ nerd.moveToRandom();
+ nerdMoveTimer = 0;
+ }
+ // Teacher patrol
+ teacher.update();
+ // --- Copying logic ---
+ var copying = false;
+ if (dist(student, nerd) < copyDistance) {
+ copying = true;
+ }
+ // If copying, increment timer and score
+ if (copying) {
+ copyingTimer++;
+ if (copyingTimer % 30 === 0) {
+ // every 0.5s
+ copyScore++;
+ scoreTxt.setText(copyScore);
+ // Win condition
+ if (copyScore >= 30) {
+ LK.showYouWin();
+ }
+ }
+ // Visual feedback: flash nerd green
+ if (!lastCopying) {
+ LK.effects.flashObject(nerd, 0x00ff00, 400);
+ }
+ }
+ lastCopying = copying;
+ // --- Teacher detection logic ---
+ var teacherCaught = false;
+ // If student is copying and teacher can see and is close enough
+ if (copying && teacherCanSeeStudent() && dist(teacher, student) < teacherCatchDistance) {
+ teacherCaught = true;
+ }
+ if (teacherCaught && !lastTeacherCaught) {
+ // Flash screen red
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ lastTeacherCaught = teacherCaught;
+};
\ No newline at end of file
give a teacher. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
nerd emoji. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
The students who does do math exam. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
a classroom smartboard. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
student desk. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat