One-click sports.

I was recently browsing through my JavaScript library when I came across a series of amusing scripts centered around the idea of creating a game that can be played in just one click. For example, here’s One-click Football:

<!DOCTYPE html>
<html>
<head>
<title>One-click Football</title>
</head>
<body>

<p id="demo1">HOME:</p>
<p id="demo2">VISITORS:</p>

<button onclick="myFunction()">Start game!</button>

<script>
function myFunction()
{
document.getElementById("demo1").innerHTML='HOME: ' + Math.floor((Math.random()*50)+2);
document.getElementById("demo2").innerHTML='VISITORS: ' + Math.floor((Math.random()*50)+2);
}

</script>

</body>
</html>

When this script is run, you’ll see a “Start game” button that gives you the final score of the game in one click without you having to sit through the whole game, not to mention halftime. I also made a variation of this script called One-click Basketball that simply generates higher numbers for the final score.

I also came up with One-click Wrestling.

<!DOCTYPE html>
<html>
<head>
<title>One-click Wrestling</title>
</head>
<body>
<p id="demo">RED vs. BLUE</p>
<button onclick="myFunction()">Wrestle!</button>
<script>
function myFunction(x)
{
var r=Math.random();
var x=document.getElementById("demo")
if (r>0.5)
{
x.innerHTML="RED wrestler won.";
}
else
{
x.innerHTML="BLUE wrestler won.";
}
}
</script>
</body>
</html>

Either the Red or the Blue wrestler will win. Other variations of this script include One-click Chess, One-click Billiards and One-click Racing that simply tell you whether you won or lost.

I close with a script called One-click Politics:

<!DOCTYPE html>
<html>
<head>
<title>One-click Politics</title>
</head>
<body>
<p id="demo"></p>
<button onclick="myFunction()">Submit</button>

<script>
function myFunction(x)
{
var r=Math.random();
var x=document.getElementById("demo")
if (r>0.5)
{
x.innerHTML="Blame it on the Democrats.";
}
else
{
x.innerHTML="Blame it on the Republicans.";
}
}
</script>
</body>
</html>

The possibilities for one-click games like these are truly endless.

Leave a Comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s