Script 8.11. Simple bug catching game
Jaap MurreSimple bug catching game
Drag the target over the bug. This is the script 8.11 in the Getting Started book.It consists of only 30 lines of code.
Press the space bar to start the game. The red bug will move erratically.
The objective is to catch the by dragging the target on top of the bug.
If you are a registered user and signed in, you can here copy this script and its stimuli to your own account, where you can edit it and change it in any way you want.
It is absolutely free to register (no credit card info asked!). You can then instantly copy this experiment with one click and edit it, change its accompanying texts, its landing page, stimuli, etc. Invite your colleagues, friends, or students to check out your experiment. There is no limit on how many people can do your experiment, even with a free account.
The catch? There is no catch! Just keep in mind that with a free account, you cannot collect data. For teaching that is usually not a problem. For research, prepaid data collection (unlimited subjects) starts as low as €10.00 for a 10-day period.
var a = addblock("center","bottom",80,20).text("Press Space bar to start!"), c = addblock(1,1,15,15).icon('bug',350).style('color','crimson'), b = addblock(40,40,20,20).icon('bullseye',450).style('color','navy').moveable(), speed = 1, hor = speed, ver = speed; awaitkey(" "); // Wait for space a.clear(); // Clear starting message for (var i = 0; i < 2000; i++) { RAF(); // Request animation frame c.move(hor,ver); // Move the bug if (c.inside(b)) { a.text("Caught!!!"); break; // Break out of the loop } if (random() < .025) { // Keep movements within bounds hor = -hor; } if (random() < .025) { ver = -ver; } if (c.left < 0 || c.left > 85) { hor = -hor; } if (c.top < 0 || c.top > 85) { ver = -ver; } } await(4000);