DEVELOPMENT

Last night, while surfing the net i came through a very quite intresting game. It was a photo comparison game, you have remebered such type of game appearing in many of the children edition newspaper. Simultaneously, two photos are displayed one they called the original and other having some errors in it, and you have to find out the error. If you've gone through other's of my article, you've come to know that i never write actually the full code of the problem. What i do is to just provide you with the logic. Thus, here i've written just some part of the code, giving you the diving force to write the code for the full game.

Here i've used Image-select Area jquery plugin, which is available under the dual mit and gnu public license. To use the plugin, please go through the page link http://odyniec.net/projects/imgareaselect/, which will guide you on it's usage instruction.

snap


<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">
</script> 
<link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" ><link/> 
<script type="text/javascript" src="scripts/jquery.min.js">
</script> 
<script type="text/javascript" src="scripts/jquery.imgareaselect.pack.js">
</script>
<script> 
function setInfo(i, e) 
{
$('#x').val(e.x1); 
$('#y').val(e.y1); 
$('#w').val(e.width);
$('#h').val(e.height);
} $(document).ready(function () { 
$('img#photo').imgAreaSelect({ handles: true, onSelectEnd: setInfo }); });
</script> 
</head>
<body>
<form method="POST" action="index.php" width="500px" height="250px"> 
<img id="photo" src="map.jpg"></img>
<input type="hidden" id="x" name="x" >
<input type="hidden" id="y" name="y" > 
<input type="hidden" id="w" name="w" >
<input type="hidden" id="h" name="h" > 
<input type="submit"/> 
</form> 
</body> 
</html>
    


<?php
if($_SERVER['REQUEST_METHOD']=="POST")
{
        $x=145;
        $y=72;
    
        echo "
Area = ".$_REQUEST['w']*$_REQUEST['h']; echo "
"; echo "w cor = ".$_REQUEST['w'];echo "
"; echo "h cor = ".$_REQUEST['h'];echo "
"; echo "x cor = ".$_REQUEST['x'];echo "
"; echo "y cor = ".$_REQUEST['y'];echo "
"; . . .

  • Since,our setinfo() method has already done feeding work, now let see the result by echoing all the four of them. This is just the unnecessary part, included just to make you understand better.
  • I've arbitrary selected the encircle region(depicted in the below figure) as our desiered region.


  • select region

            .
            .
            .
            
         if($_REQUEST['w']*$_REQUEST['h']<11000 && ($_REQUEST['x']>141) && $_REQUEST['x']<149 && $_REQUEST['y']<76 && $_REQUEST['y']>68 )
            {
                echo "
    You selected the desired region.
    "; } }








    All rights reserved, the content is copyrighted to the author.

    RELATED POST