0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

plunkerでtateno

Posted at

概要

plunkerでtatenoやってみた。
モグラ叩き、やってみた。

参考にしたページ

写真

image.png

サンプルコード


var t1 = "lib/mogu_tan1.png";
var t2 = "lib/mogu_tan2.png";
var t3 = "lib/mogu_tan3.png";

window.onload = function() {
	game = new Game();
	game.fps(30);
	game.preload(t1);
	game.preload(t2);
	game.preload(t3);
	game.start();
	var aLabel = new Label("score", 10, 10);
	aLabel.size(20);
	var flg = 0;
	var score = 0;
	var count = 0;
	var count2 = 0;
	var kan = Math.random() * 35;
	function main() {
		setTimeout(function() {
			if (flg == 0) 
			{
				count++;
				count2++;
				aLabel.label("time: " + Math.floor(count / 10) + " score: " + score);
				if (count2 > kan)
				{
					var mogura = new Sprite(120, 120, t2, 1, 1);
					mogura.x(Math.random() * 380);
					mogura.y(Math.random() * 330 + 50);
					mogura.jq.click(function() {
						mogura.x(-100);
						score++;
					});
					kan = Math.random() * 25;
					count2 = 0;
				}
				if (Math.floor(count / 10) == 11)
				{
					alert("game over");
					flg = 1;
				}
				main();
			}
		}, 100);
	}
	main();
}




成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?