试试眼力zim游戏找到哪个方块一直不变
代码语言:html
所属分类:游戏
代码描述:试试眼力zim游戏找到哪个方块一直不变
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body translate="no"> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/createjs-1.3.2.js"></script> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/zim-cat.js"></script> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/zim-game.2.3.js"></script> <script> const frame = new Frame("fit", 1024, 768, "#A496A4".lighten(.8), "#A496A4".lighten(.3)); frame.on("ready", () => {// ES6 Arrow Function - similar to function(){} zog("ready from ZIM Frame"); // logs in console (F12 - choose console) // often need below - so consider it part of the template const stage = frame.stage; const stageW = frame.width; const stageH = frame.height; // REFERENCES for ZIM at https://zimjs.com // see https://zimjs.com/intro.html for an intro example // see https://zimjs.com/learn.html for video and code tutorials // see https://zimjs.com/docs.html for documentation // see https://codepen.io/topic/zim/ for ZIM on CodePen // *** NOTE: ZIM Cat defaults to time in seconds // All previous versions, examples, videos, etc. have time in milliseconds // This can be set back with TIME = "milliseconds" but we suggest you give it a try! // There will be a warning in the conslole if your animation is not moving ;-) // CODE HERE // The AHA Game // Try and find the square that is not changing const colors = ["#A5A7BB", "#A496A4", "#554d73"]; const size = 520; // size of game tile let num = 4; // number of tiles per col or row // Just some design - a backing focus rectangle new Rectangle(900, 530, "#A5A7BB", yellow).alp(.2).loc(50, 70); // Backing rectangle for game tile new Rectangle(size + 5, size + 5, dark).rot(45).center(); // When we get the right square we emit particles // These will be the same size as the tile // but the tile sizes can be changed // So... we could make a new emitter each time // or there is a better solution below: // ZIM has dynamic parameters - called ZIM VEE values or Pick Objects // This means, we can pass in a ZIM VEE value to the obj parameter // Each time the particle is made inside it will pick from the ZIM VEE value // Different ZIM VEE values are as follows: // [1,3,2] - random // {min:10, max:20} - range // series(1,2,3) - order, // function(){return result;} - function // We want to make a particle the size of the current tile // so we can use a function to make the particle // and then pass the function to the Emitter // Note that the Rectangle being made also uses a ZIM VEE value // It is using the colors array to pick randomly from the color // This would not work without ZIM VEE system function makeParticle() { return new Rectangle(size / num, size / num, colors, dark).rot(45); } const emitter = new Emitter({ obj: makeParticle, startPaused: true, gravity: 0, force: { min: 10, max: 20 } }); // One square will always stay the same color // This is the function to start each round // and set the correct square and its color let correct = null; function startRound() { correct = rand(num * num - 1); // 0-value correctColor = shuffle(colors)[0]; emitter.clearPool(); // emitter pools particles - which could be the wrong size } startRound(); // Create the tile in an interval // We can pause and change the speed of a ZIM interval // We will get rid of the old tile if there is one // and make a new tile each time // Passing in the colors array will make the tile pick randomly from the colors // each time it makes a time - this is ZIM VEE again let tile = null; timer = interval(.6, () => { if (tile) tile.removeFrom(); tile = new Tile(new Rectangle(size / num, size / num, colors, dark).centerReg(), num, num). rot(45). cur(). centerReg(stage, 2); // above backing rectangles tile.on("mousedown", () => { wrong.score++; }); let correctTile = tile.getChildAt(correct); // correctTile.borderColor = red; correctTile.color = correctColor; correctTile.on("mousedown", () => { emitter.loc(correctTile).spurt(10); // go to next level num++; if (num > dial.max) num = dial.min; dial.currentValue = num; right.score++; wrong.score--; // wrong value will also go up so fix that startRound(); }, null, true); // only click once on correct tile stage.update(); }, null, t.........完整代码请登录后点击上方下载按钮下载查看
网友评论0