Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
do you think it's possible to merge these two scripts?
Old 08-06-2010, 09:23 AM do you think it's possible to merge these two scripts?
Webmaster Talker

Posts: 611
Trades: 0
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.

Code:
<?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.

Code:
/////////////////////////////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.
silverglade is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to do you think it's possible to merge these two scripts?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.53833 seconds with 12 queries