Image in Nine Game Hide and Seek Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Image in Nine Game Hide and Seek  Tutorial

Image in Nine Game Hide and Seek Tutorial

Our โ€œImage in Nine Gameโ€ from yesterdayโ€™s Image in Nine Game Primer Tutorial as shown below, was a bit lacking as a โ€œgameโ€ in real world terms. But what if we added a โ€œHide and Seekโ€ element to it? Lots of people in the world know the idea of โ€œHide and Seekโ€ as a game. But doesnโ€™t โ€œHide and Seekโ€ involve at least two players? Yes, that is so, and we donโ€™t go inventing some new game console functionality here to add this new โ€œHide and Seekโ€ functionality to our game today. Instead, we rely on user goodwill and sense, as we so often do at this blog. We have a โ€œHiding Playerโ€ and a โ€œFinding Playerโ€ and just ask that the โ€œFinding Playerโ€ turns away when the โ€œHiding Playerโ€ is selecting something to hide and using two document.body onclick events to define top left and bottom right co-ordinates respectively, in time for the overlayed images to โ€œcloudโ€ the issue for the โ€œFinding Playerโ€, who will have to use scrolling techniques and clues from the name left by the โ€œHiding Playerโ€ as to what was hidden to โ€ฆ

  1. pick the correct square of nine (parts to the background image of game)
  2. make the hidden thing go up to the top left of that square via scrolling techniques

โ€ฆ to succeed with their game quest. Again, we show a time taken aspect to how the โ€œFinding Playerโ€ does. After any one finding, the game is totally reworked, and presumably, this could be the chance for the players to swap roles, perhaps โ€ฆ but that is up to them?!

Along the way here youโ€™ll have seen that a new component to our web application, which still can do all yesterdayโ€™s ideas as well, is that document.body onclick event, used exclusively in the game by the โ€œHiding Playerโ€, which is made to work via a document.body onload scenario as per bold bits of HTML and Javascript code below โ€ฆ



<head>

// Lots of CSS styling code and title

// ...

// End of CSS styling code and title

<script type='text/javascript'>

var i, j, imgw=0, imgh=0, factor=1.0, x=0, y=0, tlx=0, tly=0, brx=0, bry=0, squarethingison=-1, rtlx=0, rtly=0, rbrx=0, rbry=0;

// Lots of other Javascript code

// ...

// End of lots of other Javascript code

function oc(event) {

if (event.clientX || event.clientY) {

x = event.clientX;

y = event.clientY;

} else {

x = event.pageX;

y = event.pageY;

}

if (!tl_click && thing != '') {

tl_click=true;

tlx=x;

tly=y;

document.title="Got that, 'Hiding Player', thanks. Now the bottom right? After that, call in 'Finding Player', quickly to see a message and to find your hidden " + thing + ".";

document.getElementById('custom-alert-1').innerHTML="Got that, 'Hiding Player', thanks. Now the bottom right? After that, call in 'Finding Player', quickly to see a message and to find your hidden " + thing + ".";

document.getElementById('custom-alert-1').style.visibility='visible';

setTimeout(andt, hiding_fourfivehundred);

} else if (!br_click && thing != '') {

br_click=true;

brx=x;

bry=y;

squarethingison=whichsquare();

var imgs=document.getElementsByTagName('img');

for (var m=0; m<imgs.length; m++) {

if (imgs[m].id != 'myimg' && thing != '') imgs[m].style.display=dmode;

}

document.title="Okay 'Finding Player', over to you to find the " + thing + " that 'Hiding Player' has hidden, by scrolling " + thing + " into the top left of relevant of Nine Parts of Image square. The correct square must be the one scrolled in to succeed.";

document.getElementById('custom-alert-1').innerHTML="Okay 'Finding Player', over to you to find the " + thing + " that 'Hiding Player' has hidden, by scrolling " + thing + " into the top left of relevant of Nine Parts of Image square. The correct square must be the one scrolled in to succeed.";

document.getElementById('custom-alert-1').style.visibility='visible';

setTimeout(andt, finding_eightfivehundred);

setTimeout(secondstaken, 1000);

}

}


</script>

</head>

<body onload='pregetwh();' onclick=' oc(event); ' ontouchstart=' oc(event); '>

We channelled our temporary dialog (like Android โ€œtoastโ€) functionality we talked about at Web Slideshow Like PowerPoint Hashtag Navigation Tutorial to place some temporary โ€œoverlayedโ€ advice for the Hide and Seek players as the game progresses.

So whatโ€™s the opening โ€œblurbโ€ of the web application game now โ€ฆ

Welcome to our Image in Nine Games โ€ฆ firstly, one player mode game is a bit like a jigsaw game, with the top left of nine filled in (they have a yellow border when fitting nicely โ€ฆ though there is a tolerance) โ€ฆ and help for others via faint underneath image and getting numbers up in the title close to zero โ€ฆ once you move the other eight pieces around via one finger swipe gesture for mobile or scrolling for non-mobile. This starting image is //www.rjmprogramming.com.au/HTMLCSS/your_acronyms.jpg and you can practice or give up by using //www.rjmprogramming.com.au/HTMLCSS/scroll_touch.htm?goes=1 URL in order to specify your own URL image as required, or enter your own image URL below, or as a collaborative game for two (Hiding Player and Finding Player), enter name of Thing You Want Other Player to Find or [image URL]&thing=[Thing You Want Other Player to Find]

And here is the new liveโœ‚run link to the โ€œImage in Nine Gameโ€ including a โ€œHide and Seekโ€ component, that has this HTML and Javascript and CSS programming source code you could call scroll_touchโšซhtm that changed from yesterday in thisway.

Weโ€™ll leave you with a fairly obvious theme of usage of this game with a Whereโ€™s Wally scenario, the image for which weโ€™d like to thank the imgur website.

Did you know?

Sometimes, as with todayโ€™s game, but not always, with web applications, if youโ€™ve forgotten to โ€œtest mobileโ€ โ€ฆ how sinful โ€ฆ youโ€™ll find that wherever you have some onclick event code you can just double up the same logic for an ontouchstart event, and have your web application burst to life in the mobile wooooooorrrrrrlllld.



Previous relevant Image in Nine Game Primer Tutorial is shown below.

Image in Nine Game Primer Tutorial

Image in Nine Game Primer Tutorial

Today weโ€™ve written a web application game that really benefits, in its mobile device incarnations, by โ€œtouch scrollingโ€ or momentum-based scrolling techniques.

We found lots of great advice for todayโ€™s game from the Open Source community on the net, and give thanks to โ€ฆ

So what is our game? Hereโ€™s the opening โ€œblurbโ€ for it โ€ฆ

Welcome to our Image in Nine Game โ€ฆ bit like a jigsaw game with top left of nine filled in (they have a yellow border when fitting nicely โ€ฆ though there is a tolerance) โ€ฆ and help for others via faint underneath image and getting numbers up in the title close to zero โ€ฆ once you move the other eight pieces around via one finger swipe gesture for mobile or scrolling for non-mobile. This starting image is //www.rjmprogramming.com.au/HTMLCSS/your_acronyms.jpg and you can practice or give up by using //www.rjmprogramming.com.au/HTMLCSS/scroll_touch.html?goes=1 URL in order to specify your own URL image as required, or enter your own image URL below.

Itโ€™s a simple premise. An image gets cut evenly up into nine equal area pieces, a bit like a jigsaw. We add this to a table of HTML div elements including the gameโ€™s image as a background image with a defined background-position property, within HTML table td cells. Those HTML div elements โ€œrevealโ€ the game image again overlayed on top, but with no offsets in positioning, so you end up with the top left cellโ€™s HTML div element being totally fine, and so showing a yellow border to indicate this. But the mobile user will need to use momentum-based scrolling and the non-mobile user can use normal scrolling techniques to pull the โ€œoverlayedโ€ image back into the correct โ€œjigsawโ€ position, and get a yellow border, to succeed at the game. There is a numerical reporting helper in document.title that when creeping towards zero helps the user out with their positioning. We time the user doing this, should they want to try the game again to try to improve, perhaps with their own image URL in mind.

Here is the liveโœ‚run link to the โ€œImage in Nine Gameโ€ that has this HTML and Javascript and CSS programming source code you could call scroll_touchโšซhtml and here for your perusal. And here is a liveโœ‚run for an Australian Lighthouses image.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Games, Tutorials and tagged , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *