Jump to content

do you think it's possible to merge these two scripts?


silverglade

Recommended Posts

Hi, I'm trying to make my game navigation that involves switching div images to navigate in the game world. It is browser based. The first script, the user clicks on the world map to go to "Teardrop Ocean". The second script lets the user press the "further" button or "back" button to navigate within "Teardrop Ocean". My problem is I'm trying to combine the image map navigation with the "further" and "back" navigation. The problem is, I don't know if it's possible since the first world map script involves javascript. Here is the code, any help greatly appreciated Thanks. Derek

 

 

 

This is the code that uses javascript to process a hidden form to use php to output. This is our "world map" link, that should load the "teardrop ocean" image inside the div, which it doesn't do yet here.

<?php

$zone='';

if(isset($_POST['checker']) && $_POST['checker'] == 'checked')
{
   echo "it worked !";

$zone="<img src='teardrop.jpg'/>";   
}

if(isset($_POST['back']))
{
$zone='';
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="aradia.php" method="post" name="mapform" id="mapform">
<input type="hidden" name="checker" value="checked" />
  <div align="left"> <img src="aradia.jpg" width="256" height="328" border="0" usemap="#Map" /></div>
</form>

<map name="Map" id="Map">
   <area shape="rect" coords="5,176,81,249" href="javascript: void(0);" onclick="javascript: document.getElementById('mapform').submit();" />
</map>
<div align="center"><?php echo $zone;?></div>

<form action="aradia.php" method="post" > <input type = "submit" name="back" value="back" /></form>
</body>
</html>

 

and here is the "Teardrop ocean" navigation, which uses php to navigate forward and backwards in the zone, but can't go back to the world map, or there is no way to yet.

 

/////////////////////////////GAME NAVIGATION AND MONSTER SEARCH CODE NOT FINISHED//////////////////////////////////

if(( !isset($_SESSION['current_background']) && !isset($_SESSION['currentMonster'])) OR (! $_POST))
{
    $_SESSION['current_monster'] = 0;
    $_SESSION['current_background'] = 0;
}


if (!isset($_SESSION['background']) && !isset($_SESSION['monster'])) {
  $_SESSION['background'] = array
  (
    "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>",
    "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>",
   "<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>",
   "<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>",
   "<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>"
  );
  
   $_SESSION['monster'] = array
  (
    "<img src='sundragon_monsters_source/water/goldfish/goldfish.png'/>",
    "<img src='sundragon_monsters_source/water/eel/eel_transp_FRAME.png '/>",
   "<img src='sundragon_monsters_source/water/shark/shark_transp_FRAME.png'/>",
   "<img src='sundragon_monsters_source/water/octalisk/octalisk_transp_FRAME.png'/>",
   "<img src='sundragon_monsters_source/water/teardrop_ocean_protector/teardrop_ocean_protector.png'/>"
  );
  
  
}
if(!isset($_SESSION['current_background']) && !isset($_SESSION['current_monster']))
{


$_SESSION['current_monster']=0;	

$_SESSION['current_background'] = 0;
}

if(isset($_POST['further']))
{


$_SESSION['current_monster'] = isset($_SESSION['monster'][$_SESSION['current_monster'] + 1]) ? ($_SESSION['current_monster'] + 1) : 0;
$_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] + 1]) ? ($_SESSION['current_background'] + 1) : 0;
}
elseif(isset($_POST['back']))
{
$_SESSION['current_monster'] = isset($_SESSION['monster'][$_SESSION['current_monster'] - 1]) ? ($_SESSION['current_monster'] - 1) : count($_SESSION['monster'])-1;
$_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] - 1]) ? ($_SESSION['current_background'] - 1) : count($_SESSION['background'])-1;
} 

$currentBackground=$_SESSION['background'][$_SESSION['current_background']];
$currentMonster=$_SESSION['monster'][$_SESSION['current_monster']];

 

and I echo out $currentBackground and $currentMonster in the main game div.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.