Author Topic: making a browsergame nead help  (Read 1555 times)

Offline jack13580

  • Level 7
  • *
  • Posts: 35
  • Reputation: +0/-0
    • View Profile
making a browsergame nead help
« on: July 27, 2011, 11:50:37 PM »
I dubt my question will be answered because i already tried on 3 other forums but i am making a browser game where users register they start out with 1 town they can found new towns build up build armies found alliances attack other players take colonies from other players as your own and message other players right now i have finished the register part skipping login untill i get the town page finished and i am trying to build a world map for the game

so far this is the code i have for the world map obviously theres not much but this is my first time making a world map like this

Code: [Select]

<?php

$number_of_tiles_x 
15;
$number_of_tiles_y 15;

$tile_width 50;
$tile_height 50;

$map_height $tile_height*$number_of_tiles_y;
$map_width $tile_width*$number_of_tiles_x;

?>

<html>
<head>
<style type="text/css">
#map {
width: <?php echo $map_width?>px;
height: <?php echo $map_height?>px;
background-color: #000;
position:relative;
}
.tile {
width: <?php echo $tile_width+$number_of_tiles_x+12?>px;
height: <?php echo $tile_height+$number_of_tiles_y+12?>px;
position:absolute;
}
</style>
</head>
<body>

<?php

echo "<center><h1>Test Map</h1><br />$number_of_tiles_x | $number_of_tiles_y<br /> is number of tiles on XAxis | is number of tiles on YAxis</center><br />";

?>

<div id="map">
<?php

for ($x 1;$x<$number_of_tiles_x;$x++){
for ($y 1;$y<$number_of_tiles_y;$y++){
$tx $x $tile_height 1.5;
        
$ty $y $tile_height + ($x 2) * $tile_height 2;
$style sprintf("left:%dpx;top:%dpx"$tx$ty);
echo "<img src=\"plain.gif\" class=\"tile\" style=\"$style\" />\n";
}
}

?>

</div>

</body>
</html>


the picture im using is


and this is a link to the map
http://the-test.comoj.com/map/test_map.php

as you can see i want it go 15 by 15 tiles but its not its going 8 by 15

and also you can also notice that it is aligned to far down it should be on the black map background but its not also i am trying to make it look similar to this map



but i have no clue how to align the tiles like that please help if you can

one more thing thats not relevent to this is i want you guys to tell me if the code im using for the home page is bad or not the way i have coded it
Code: [Select]

<?php
ob_start
();
session_start();
$action $_GET['act'];
$actions_array = array('forgot_password','about','TandC');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="styles/main.css" />
    <?php $site "medieval-wars.com"$title "Home"?>
    <title>
      <?php echo "$site - $title"?>
    </title>
    <style type="text/css">
.page-top-sceen-island {
background-image: url(../images/bg-island.png);
top:150px;
width:300px;
height:164px;
right:-1098px;
position:relative;
}
.page-top-sceen-island-for-IE {
display:none;
}
</style>
<!--[if IE]>
<style type="text/css">
.page-top-sceen-island-for-IE {
display: block;
background-image: url(../images/bg-island.png);
top:150px;
width:300px;
height:164px;
right:-1096px;
position:relative;
}
.page-top-sceen-island { display: none; }
</style>
<![endif]-->
  </head>
  <body>
    <div id="page-top">
      <div id="page-top-top">
        <div id="page-top-under">
        </div>
      </div>
      <div id="page-top-sceen-logo">
        <div style="font-size:16pt;color: #000;"><br /><br />
          <a title="medieval-wars.com" href="http://medieval-world.webuda.com/">We are at war!<br />Now it is your time to lead our nation to victory!<br />medieval-wars.com </a>
        </div>
      </div>
      <div id="page-top-sceen-left">
      </div>
      <div id="page-top-sceen-island-wrapper">
<div class="page-top-sceen-island">
</div>
<div class="page-top-sceen-island-for-IE">
</div>
</div>
    </div>
    <div id="main-content-character" title="King">
    </div>
    <div id="left-side-bar">
      <ul class="ul-box">
        <li class="li-top">
          <div style="position:relative;top:6px;">
            <h1 title="Register for free">Register for free</h1>
          </div><br />
        </li>
        <li class="content">
<?php
if (isset($_POST['register'])) {
  
$regusername $_POST['username'];
  
$regemail $_POST['email'];
  
$regserver $_POST['server'];
}
else {
  
$regusername '';
  
$regemail '';
  
$regserver 0;
}

$servers = array(0=>'Select Your World...'1=>'S1 Medieval-Europe', );

$regform "
    <form action=\"testing.php\" method=\"post\">
      <div class=\"input-wrap\">
        <label title=\"Username\">Username</label><br />
        <input type=\"text\" name=\"username\" value=\"
$regusername\" title=\"Username\" style=\"\" />
      </div>
      <div class=\"input-wrap\">
        <label title=\"Password\">Password</label><br />
        <input type=\"password\" name=\"password\" value=\"\" title=\"Password\" style=\"\" />
      </div>
      <div class=\"input-wrap\">
        <label title=\"Confirm Password\">Confirm Password</label><br />
        <input type=\"password\" name=\"confpassword\" value=\"\" title=\"Confirm Password\" style=\"\" />
      </div>
      <div class=\"input-wrap\">
      <label title=\"Email\">Email</label><br />
      <input type=\"text\" name=\"email\" value=\"
$regemail\" title=\"Email\" style=\"\" />
      </div>
      <div class=\"input-wrap\">
        <label title=\"Choose Your World\">World</label><br />
        <select name=\"server\" title=\"Select Your World...\">"
;
        foreach (
$servers as $snum=>$sname) {
            if (
$regserver == $snum$selectedserver 'selected="selected"';
            else 
$selectedserver '';
            
$regform .= "
            <option value=\"
$snum\" title=\"$sname\" $selectedserver >$sname</option>
            "
;
        }
$regform .= "
        </select>
      </div>
      <div style=\"padding-left:60px;\">
        <input type=\"submit\" name=\"register\" value=\"Register\" title=\"Register\" class=\"button\" />
      </div>
    </form>"
;
if(
$_POST['register']){
$regpassword $_POST['password'];
$regconfpassword $_POST['confpassword'];
        
//$regform2 = "<form action=\"index.php\" method=\"post\"><div class=\"input-wrap\"><label title=\"Username\">Username</label><br /><input type=\"text\" name=\"username\" value=\"$regusername\" title=\"Username\" style=\"\" /></div><div class=\"input-wrap\"><label title=\"Password\">Password</label><br /><input type=\"password\" name=\"password\" value=\"\" title=\"Password\" style=\"\" /></div><div class=\"input-wrap\"><label title=\"Confirm Password\">Confirm Password</label><br /><input type=\"password\" name=\"confpassword\" value=\"\" title=\"Confirm Password\" style=\"\" /></div><div class=\"input-wrap\" title=\"Email\"><label>Email</label><br /><input type=\"text\" name=\"email\" value=\"$regemail\" title=\"Email\" style=\"\" /></div><div class=\"input-wrap\"><label title=\"Choose Your World\">World</label><br /><select name=\"server\" title=\"Select Your World...\"><option value=\"0\" title=\"Select Your World...\">Select Your World...</option><option value=\"1\" title=\"S1 Medieval-Europe\">S1 Medieval-Europe</option></select></div><div style=\"padding-left:60px;\"><input type=\"submit\" name=\"register\" value=\"Register\" title=\"Register\" class=\"button\" /></div></form>";
        
$regform2 $regform;

if($regusername && $regpassword && $regconfpassword && $regemail && $regserver){
if($regpassword === $regconfpassword){
if(strlen($regusername) >= && strlen($regusername) <= 32){
if(strlen($regpassword) >= && strlen($regpassword) <= 32){
include "./scripts/connect.php";
$regsql "SELECT username FROM `users` WHERE `username`='".$regusername."'";
$regres mysql_query($regsql) or die(mysql_error());
if(mysql_num_rows($regres) > 0){
echo "$regform<font style=\"padding-left:20px;\">That username is already in use!</font><br /><br />";
}else {
$regsql2 "SELECT email FROM `users` WHERE `email`='".$regemail."'";
$regres2 mysql_query($regsql2) or die(mysql_error());
if(mysql_num_rows($regres2) > 0){
echo "$regform<font style=\"padding-left:20px;\">That email is already in use!</font><br /><br />";
}else {
$checkemail "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
if(preg_match($checkemail$regemail)){
$regCorX mt_rand(1,400);
$regCorY mt_rand(1,400);
$regallCorssql "SELECT * FROM cities WHERE CorX='".$regCorX."' AND CorY='".$regCorY."'";
$regallCorsres mysql_query($regallCorssql) or die(mysql_error());
if(mysql_num_rows($regallCorsres) > 0){
echo "$regform<font style=\"padding-left:20px;\">There was an error <br /><b>(Error Code \"1\")</b></font><br /><br />";
}else {
$regIP_adress $_SERVER['REMOTE_ADDR'];
$regrand_act_code substr(md5(rand(111111111199999999999999)), 225);
$regrand_login_code substr(md5(rand(121212121288888888888888)), 550);
$regencrypted_regpassword md5(md5("kjfiufj".$regpassword."Fdj56fj"));

$regsql3 "INSERT INTO users VALUES ('', '$regusername', '$regencrypted_regpassword', '$regemail', '0', '$regIP_adress', '0', '$regusername', '$regserver', '', '', '$regrand_act_code', '$regrand_login_code', '1', '1')";
$regres3 mysql_query($regsql3) or die(mysql_error());
$regsql4 "INSERT INTO profile VALUES ('', '$regserver', '$regusername', '0', '0', 'This user hasn&#38;#039;t entered any profile text yet.', 'default.png', '1', 'Polis')";
$regres4 mysql_query($regsql4) or die(mysql_error());
$regsql5 "INSERT INTO cities VALUES ('', '$regserver', 'Polis', '$regusername', '$regCorX', '$regCorY', '1')";
$regres5 mysql_query($regsql5) or die(mysql_error()); }
}else {
echo "$regform<font style=\"padding-left:20px;\">That is an invalid email!</font><br /><br />";
}
}
}
}else {
echo "$regform<font style=\"padding-left:10px;\">Your password has to be atleast 8 to <br /><font style=\"padding-left:10px;\">32 characters in length!</font></font><br /><br />";
}
}else {
echo "$regform<font style=\"padding-left:10px;\">Your username has to be atleast 3 to <br /><font style=\"padding-left:10px;\">32 characters in length!</font></font><br /><br />";
}
}else {
echo "$regform<font style=\"padding-left:20px;\">Those passwords do not match!</font><br /><br />";
}
}else {
echo "$regform<font style=\"padding-left:20px;\">You must fill in the entire form!</font><br /><br />";
}
}else {
   echo 
$regform;
}
          
?>

        </li>
        <li class="li-bottom">
        </li>
      </ul>
    </div>
    <div id="content">
      <div id="box">
        <div id="top">
        </div>
        <div id="bottom">
        </div>
        <div style="text-align:center;">
<?php
if(!
$action || !in_array($action,$actions_array)){
echo "<p style=\"text-decoration:underline\">Home Page</p>";
}else {
if($action == 'TandC'){
include "./T&C.php";
}
}
          
?>

        </div>
      </div>
    </div>
  </body>
</html>
<?php
ob_end_flush
();
?>



and my database looks like

Code: [Select]

-- phpMyAdmin SQL Dump
-- version 2.11.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 28, 2011 at 12:49 AM
-- Server version: 5.1.57
-- PHP Version: 5.2.17

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `a8510207_game`
--

-- --------------------------------------------------------

--
-- Table structure for table `bann chance 2`
--

CREATE TABLE `#mysql50#bann chance 2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `IP_address` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `chance_2` int(11) NOT NULL DEFAULT '1',
  `date` varchar(50) COLLATE latin1_general_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;

--
-- Dumping data for table `bann chance 2`
--


-- --------------------------------------------------------

--
-- Table structure for table `cities`
--

CREATE TABLE `cities` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `server` varchar(10) COLLATE latin1_general_ci NOT NULL,
  `name` varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT 'Polis',
  `owner` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `CorX` varchar(100) COLLATE latin1_general_ci NOT NULL,
  `CorY` varchar(100) COLLATE latin1_general_ci NOT NULL,
  `points` bigint(20) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=23 ;

--
-- Dumping data for table `cities`
--

INSERT INTO `cities` VALUES(17, '1', 'Polis', 'testing3', '258', '11', 1);
INSERT INTO `cities` VALUES(16, '1', 'Polis', 'testing4', '222', '367', 1);
INSERT INTO `cities` VALUES(18, '1', 'Polis', 'testing2', '41', '198', 1);
INSERT INTO `cities` VALUES(19, '1', 'Polis', 'Concept', '235', '258', 1);
INSERT INTO `cities` VALUES(20, '1', 'Polis', 'a'' OR 1=1;', '400', '269', 1);
INSERT INTO `cities` VALUES(21, '1', 'Polis', 'test', '89', '273', 1);
INSERT INTO `cities` VALUES(22, '1', 'Polis', ''' OR 1=1 #', '382', '389', 1);

-- --------------------------------------------------------

--
-- Table structure for table `profile`
--

CREATE TABLE `profile` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `server` varchar(10) COLLATE latin1_general_ci NOT NULL,
  `username` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `banned` int(11) NOT NULL DEFAULT '0',
  `activated` int(11) NOT NULL DEFAULT '0',
  `profile_text` text COLLATE latin1_general_ci NOT NULL,
  `profile_pic` varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT 'default.png',
  `points` bigint(20) NOT NULL DEFAULT '1',
  `cities` varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT 'Polis',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=22 ;

--
-- Dumping data for table `profile`
--

INSERT INTO `profile` VALUES(15, '1', 'testing4', 0, 0, 'This user hasn&#039;t entered any profile text yet.', 'default.png', 1, 'Polis');
INSERT INTO `profile` VALUES(16, '1', 'testing3', 0, 0, 'This user hasn&#039;t entered any profile text yet.', 'default.png', 1, 'Polis');
INSERT INTO `profile` VALUES(17, '1', 'testing2', 0, 0, 'This user hasn&#039;t entered any profile text yet.', 'default.png', 1, 'Polis');
INSERT INTO `profile` VALUES(18, '1', 'Concept', 0, 0, 'This user hasn&#039;t entered any profile text yet.', 'default.png', 1, 'Polis');
INSERT INTO `profile` VALUES(19, '1', 'a'' OR 1=1;', 0, 0, 'This user hasn&#039;t entered any profile text yet.', 'default.png', 1, 'Polis');
INSERT INTO `profile` VALUES(20, '1', 'test', 0, 0, 'This user hasn&#039;t entered any profile text yet.', 'default.png', 1, 'Polis');
INSERT INTO `profile` VALUES(21, '1', ''' OR 1=1 #', 0, 0, 'This user hasn&#039;t entered any profile text yet.', 'default.png', 1, 'Polis');

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `password` varchar(200) COLLATE latin1_general_ci NOT NULL,
  `email` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `activation` int(11) NOT NULL DEFAULT '0',
  `IP_address` varchar(20) COLLATE latin1_general_ci NOT NULL,
  `banned` int(11) NOT NULL DEFAULT '0',
  `profile` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `server` varchar(20) COLLATE latin1_general_ci NOT NULL,
  `last_login` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `last_logout` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `rand_act_code` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `rand_login_code` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `cities` varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT '1',
  `points` bigint(20) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=22 ;

--
-- Dumping data for table `users`
--

INSERT INTO `users` VALUES(16, 'testing3', '55983d8b233836b1d259055b38a985ab', 'testing3@testing3.com', 0, '71.177.16.172', 0, 'testing3', '1', '', '', '9030d4543159d697104966b2a', '80fe7030dabcefae89d29e8d002', '1', 1);
INSERT INTO `users` VALUES(15, 'testing4', 'a23172c19886e344886727db01137e23', 'testing4@testing4.com', 0, '71.177.16.172', 0, 'testing4', '1', '', '', '09eec9b03706943dfa84a2b61', '9d5224bef3f3251b596e0c778f8', '1', 1);
INSERT INTO `users` VALUES(17, 'testing2', '55983d8b233836b1d259055b38a985ab', 'testing2@testing2.com', 0, '173.55.248.113', 0, 'testing2', '1', '', '', 'cdc76ddde9479bc3f10ff9a0f', 'fb8b8c474995a1109c46fa8663a', '1', 1);
INSERT INTO `users` VALUES(20, 'test', '55983d8b233836b1d259055b38a985ab', 'test@test.com', 0, '173.55.248.113', 0, 'test', '1', '', '', '625b0f5e7ecbeabc82c64beb6', '3de415652f9127b31ebbc07aad3', '1', 1);


ohh and the link to the test website is http://medieval-world.webuda.com/
« Last Edit: July 27, 2011, 11:56:27 PM by jack13580 »

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: making a browsergame nead help
« Reply #1 on: July 28, 2011, 05:03:26 AM »
Why both W and H use "$tile_height"? Where is $tile_width?

Quote
$tile_width = 50;
$tile_height = 50;
It is not square, it is isometric... Height has to be 1/2 of width. I know, it will mess up with the "buildings", still, in iso you need to make all calcuations based on the tile base, not on the maximum height of the gfx. The simpliest render would be probably "left:%dpx;BOTTOM:%dpx;".

Quote
and my database looks like
It's very poor. But nothing you can't fix later once you get hang on how databases work.
But get rid of the "server". If you really insist on separate worlds make these on diferent physical machines and completely not connected with each other.


Offline gnoh

  • Game Owner
  • Level 15
  • *
  • Posts: 127
  • Reputation: +2/-0
    • View Profile
Re: making a browsergame nead help
« Reply #2 on: July 28, 2011, 09:23:58 AM »
It looks as if you've been following a guide to render with the zigzag method if you google the diamond rendering method you'll find plenty of texts on it.
The zigzag method is why it looks as if you have less tiles on the x axis as the conversion is non intuitive, good work getting to that point I assume you haven't got the mouse coord to tile coord working otherwise you'd have realised this.


The mockup is good, did you create it?

Offline saljutin

  • Level 22
  • *
  • Posts: 266
  • Reputation: +6/-0
    • View Profile
Re: making a browsergame nead help
« Reply #3 on: July 28, 2011, 10:17:18 AM »
this is pure math

solution is to have DIV with absolute position <div style="position:absolute;left:XXXpx;top:YYYpx;"><img></div>

http://www.w3schools.com/cssref/pr_class_position.asp

read about that on pages and try it :)
and of course you will need clickable links..you make that with MAP, and AREA:rectangle
http://www.w3schools.com/tags/tag_map.asp

P.S. make one big DIV and "write" that image DIVs inside it so absolute position will be used for that div and not for html page :)

Offline jack13580

  • Level 7
  • *
  • Posts: 35
  • Reputation: +0/-0
    • View Profile
Re: making a browsergame nead help
« Reply #4 on: July 29, 2011, 09:38:35 PM »
    i some what fixed the odd 8 by 16 problem by multiplying $number_of_tiles_x*2 and putting the < in the for loops to <= but i still get an error. There is an extra row for both X and Y and for some odd reason they are randomly missing 1 tile each and i googled the diamond rendering method but all i got was a bunch of art tutorials explaining how to paint a daimond a tutorial explaining how to make a daimond kite and a few tutorials explaining how to make daimonds but i only checked the first 6 pages of results.

    Most of this is my code the only part that is not is the positioning part because i suck at math and could not figure it out so i found a tutorial and used their positioning code.

this is pure math

solution is to have DIV with absolute position <div style="position:absolute;left:XXXpx;top:YYYpx;"><img></div>

http://www.w3schools.com/cssref/pr_class_position.asp

read about that on pages and try it :)
and of course you will need clickable links..you make that with MAP, and AREA:rectangle
http://www.w3schools.com/tags/tag_map.asp

P.S. make one big DIV and "write" that image DIVs inside it so absolute position will be used for that div and not for html page :)

thanks the map part will come in useful already know about the stuff in first link and i tried your suggestion and it kind of messed it up.

i tried to google a tutorial of how to make an isometric map in php could ony find one and of course no one replied to the users question.

can you guys please give me some sample code of how to make it into isometric?

and about my database how could i make it better?

and about the server thing i use shared hosting so i can't pick what computer gets used and i can have only 1 account.

and my thoughts for the server thing was:

with the existing test website i have, my hosting service lets me do the sub link thing

so for the server i could do
S1-Medieval-Middle-East.medieval-world.webuda.com

what would be bad about doing multible servers that way and also im not planning to have more then 1 server till the first gets over 1000 players which i dubt will happen

Why both W and H use "$tile_height"? Where is $tile_width?

Quote
$tile_width = 50;
$tile_height = 50;
It is not square, it is isometric... Height has to be 1/2 of width. I know, it will mess up with the "buildings", still, in iso you need to make all calcuations based on the tile base, not on the maximum height of the gfx. The simpliest render would be probably "left:%dpx;BOTTOM:%dpx;".

so i divide tile height by 2 and change top: to bottom: ?
« Last Edit: August 06, 2011, 12:44:21 AM by jack13580 »

Offline saljutin

  • Level 22
  • *
  • Posts: 266
  • Reputation: +6/-0
    • View Profile
Re: making a browsergame nead help
« Reply #5 on: July 31, 2011, 12:35:45 PM »
its MAP
try to make 2x2 map by manually using DIV with absolute position, and later create bigger databased map

Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: making a browsergame nead help
« Reply #6 on: August 05, 2011, 07:52:37 AM »
i some what fixed the odd 8 by 16 problem by multiplying $number_of_tiles_x*2 and putting the < in the for loops to <= but i still get an error there is an extra row for both X and Y and for some odd reason they are randomly missing 1 tile each and i googled the diamond rendering method all i got where a bunch of art tutorials explaining how to paint a daimond a tutorial explaining how to make a daimond kite and a few tutorials explaining how to make daimonds but i only checked the first 6 pages of results most of this is my code the only part that is not is the positioning part because i suck at math and could not figure it out so i found a tutorial and used their positioning code

this is pure math

solution is to have DIV with absolute position <div style="position:absolute;left:XXXpx;top:YYYpx;"><img></div>

http://www.w3schools.com/cssref/pr_class_position.asp

read about that on pages and try it :)
and of course you will need clickable links..you make that with MAP, and AREA:rectangle
http://www.w3schools.com/tags/tag_map.asp

P.S. make one big DIV and "write" that image DIVs inside it so absolute position will be used for that div and not for html page :)

thanks the map part will come in useful already know about the stuff in first link and i tried your suggestion and it kind of messed it up

i tried to google a tutorial of how to make an isometric map in php could ony find one and of course no one replied to the users question

can you guys please give me some sample code of how to make it into isometric?

and about my database how could i make it better

and about the server thing i use shared hosting so i can't pick what computer gets used and i can have only 1 account

and my thoughts for the server thing was

with the existing test website i have my hosting service lets me do the sub link thing

so for the server i could do
S1-Medieval-Middle-East.medieval-world.webuda.com

what would be bad about doing multible servers that way and also im not planning to have more then 1 server till the first gets over 1000 players which i dubt will happen

Why both W and H use "$tile_height"? Where is $tile_width?

Quote
$tile_width = 50;
$tile_height = 50;
It is not square, it is isometric... Height has to be 1/2 of width. I know, it will mess up with the "buildings", still, in iso you need to make all calcuations based on the tile base, not on the maximum height of the gfx. The simpliest render would be probably "left:%dpx;BOTTOM:%dpx;".

so i divide tile height by 2 and change top: to bottom: ?

Sorry I didn't bother to read this. Make paragraphs and proper sentences first. I can deal with poor spelling and grammar but this is just to much.

Offline jack13580

  • Level 7
  • *
  • Posts: 35
  • Reputation: +0/-0
    • View Profile
Re: making a browsergame nead help
« Reply #7 on: August 06, 2011, 12:56:47 AM »
fixed

ok i have made it isometric using some code i found in an OpenGL tutorial luckly i understand  basics of C++ here is the new code

Code: [Select]

<?php
$number_of_tiles_x 
14;
$number_of_tiles_y 14;
$tile_width 50.0;
$tile_height 50.0;
$map_height $tile_height*$number_of_tiles_y;
$map_width $tile_width*$number_of_tiles_x;
?>

<html>
<head>
<style type="text/css">
.tile {
    width: <?php echo $tile_width+28?>px;
    height: <?php echo $tile_height+32?>px;
    position:absolute;
}
#map {}
</style>
</head>
<body>
<div id="map">
<?php
function screen_position($m,$n)
{
GLOBAL $tile_height,$map_height;
$tx $m $tile_height 1.50 ;
$ty =  ($n +1)* $tile_height/2.0;
return $gridpoint=array('x'=>$tx,'y'=>$ty);
}

for (
$m=0;$m<$number_of_tiles_x;$m++)
{
for ($n=0;$n<$number_of_tiles_y;$n++)
{
$gridpoint screen_position($m+$n,$number_of_tiles_y-$m+$n);
$style sprintf("left:%dpx;top:%dpx"$gridpoint['x'], $gridpoint['y']);
        echo "<img src=\"plain.gif\" class=\"tile\" style=\"$style\" />\n";
}
}

?>

</div>
</body>
</html>


it works but i nead it to start from the top and go to the right but this starts from the center and gows down

i tried to fix this by changing left:%dpx;top:%dpx; to top:%dpx;left:%dpx; this did work but the width is all off and the height is a little to high can you guys help me fix this i already figured out how to display the different images compared to the information in the database and i already figured out the links i just nead this

you can view the working map in action here http://the-test.comoj.com/map/test_map.php

and here is the link to the map with the correct positining but messed up width and height http://the-test.comoj.com/map/test_map2.php

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: making a browsergame nead help
« Reply #8 on: August 10, 2011, 03:56:02 AM »
Code: [Select]
<style>
    div.tile{
        position:absolute;
        background: url(plain.gif) no-repeat -0px -20px;
        width: 70px;
        height:35px;
  
    }
</style>

<?php
$tileWidth 
70;
$tileHeight 35;
$mapWidth 5//set the amount of tiles 
$mapHeight 5;
$xOffset = ($tileWidth $mapWidth) / 2//center the first tile
$yOffset 20//put the map a bit lower

for($y 1;$y <= $mapHeight;$y++){
  
    for(
$x 1;$x <= $mapWidth;$x++){
        
$map .= '<div class="tile" style="top:'.round($yOffset).'px;left:'.round($xOffset).'px;"></div>';
        
$yOffset += $tileHeight/2;
        
$xOffset += $tileWidth/2;
    }
      
$xOffset = ($tileWidth $mapWidth) / 2-$tileWidth/2*$y//the new line starts again from center - half tilewidth * linenumber
      
$yOffset 20 $tileHeight/2*$y;
}

echo 
$map;
?>


EDIT:

as i can see from here http://the-test.comoj.com/map/test_map2.php you did it, right?
« Last Edit: August 12, 2011, 05:05:46 AM by BlackScorp »

Offline jack13580

  • Level 7
  • *
  • Posts: 35
  • Reputation: +0/-0
    • View Profile
Re: making a browsergame nead help
« Reply #9 on: August 16, 2011, 08:33:05 PM »
yes and check it out again because i just made a new update to it

here is the updated code
Code: [Select]

<html>
<head>
<style>
    div.tile{
        position:absolute;
        background: url(plain.gif) no-repeat -0px -20px;
        width: 70px;
        height:35px;
text-align: center;
curser: pointer:
    }
img {
border: none;
}
.map_click_point {
position:absolute;
text-align:center;
height:35px;
width:70px;
padding-top:6px;
}
</style>
</head>
<body>
<?php
$tileWidth 
70;
$tileHeight 34;
$mapWidth 14//set the amount of tiles 
$mapHeight 14;
$xOffset = ($tileWidth $mapWidth) / 2//center the first tile
$yOffset 20//put the map a bit lower

$number 0;
for(
$y 1;$y <= $mapHeight;$y++){
    for(
$x 1;$x <= $mapWidth;$x++){
$number ++;

//positions the first layer
    
$map .= "<div class=\"tile\" style=\"top:".round($yOffset)."px;left:".round($xOffset)."px;\">";

//for showing the images based on corridinates from the database on the seconed layer
if($y=="1" && $x=="1" || $number=="19" || $number =="196"){
$map .= "<img src=\"test_image2.gif\" style=\"position:relative;top:-20;\" />"
}else { 
if($number=="15" || $y=="3" && $x=="5" || $y=="2" && $x=="2"){
$map .= "<img src=\"test-pc.gif\" style=\"position:relative;top:-9;\" />"
}else {} 


//the third layer has the links
$map .= "</div>\n<div class=\"map_click_point\" style=\"top:".round($yOffset)."px;left:".round($xOffset)."px;\"><a href=\"#spot=Xcord$y&amp;Ycord$x\" id=\"$number\" title=\"$y | $x\"><img src=\"click.png\" style=\"width:27px;height:21px;\"/></a></div>\n\n";
    
$yOffset += $tileHeight/2;
    
$xOffset += $tileWidth/2;
    }
    
$xOffset = ($tileWidth $mapWidth) / 2-$tileWidth/2*$y//the new line starts again from center - half tilewidth * linenumber
    
$yOffset 20 $tileHeight/2*$y;
}

echo 
"\n$map";
?>

</body>
</html>


i have a few problems though first problem is the link system works perfectly but instead of being the width and height i set them if you add border:1px solid #000; to the style for the click.png you will see how it should be but for some reason the link is only on the top half of the box and not the entire box which is annoying because it shouldn't do that

problem 2 is with the images i manualy  placed on the map i want it to go by the database but i am having trouble figuring out how to get it to work so far all my tests on my localhost have failed

and last but not least problem 3 is figuring out how to make the map 400 by 400 tiles big and make it so it only shows the 14 by 14 at a time and so when i click a link to go south it takes me down by 3 tiles how would i do this? so lets say it is showing position X267 and Y289 to where it would be centered on that spot and it would be going 7 tiles in each direction from the corners and i clicked go north so it would then take me up by 3 to X267 and Y286 how would i do this?

incase your wondering the click.png is just a 1px by 1px png file that is completely transparent
« Last Edit: August 16, 2011, 08:40:15 PM by jack13580 »

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: making a browsergame nead help
« Reply #10 on: August 17, 2011, 02:43:30 AM »
Code: [Select]
<style>
    .tile{
        position:absolute;
        background: url(sprites.png) no-repeat;
        width:70px;
        height:55px;
        line-height: 70px;
        text-align: center;
        font-size: 12px;

    }
    .tile.plain{
        background-position: 0px 0px;
    
    }
    .tile.town1{
   background-position: -81px 0px;
    }
    .tile.town2{
      background-position: -162px -2px;
    }
</style>

<?php
$myX 
= (isset($_GET['x']) ? $_GET['x'] : 0);
$myY = (isset($_GET['y']) ? $_GET['y'] : 0);
$tileWidth 70;
$tileHeight 34;
$mapWidth 15;
$mapHeight 15;
$startX $myX $mapWidth/;
$endX $myX $mapWidth/2;
$startY $myY$mapHeight/;
$endY $myY $mapHeight/2;
$xOffset = ($tileWidth $mapWidth) / 2//center the first tile
$yOffset 20//put the map a bit lower
$avaliableTiles = array(
    
'town1','town2','plain'
);
$lineNumber 1;
for (
$y ceil($startY); $y ceil($endY); $y++) {

    for (
$x ceil($startX); $x ceil($endX); $x++) {
        
$color'white';
        if(
$myX == $x && $myY == $y){
            
$color='green';
        }
        
$map .= '<div class="tile '.$avaliableTiles[rand(0,count($avaliableTiles)-1)].'" style="color:'.$color.';top:' round($yOffset) . 'px;left:' round($xOffset) . 'px;">Y'.$y.'/X'.$x.'</div>';
        
$yOffset += $tileHeight 2;
        
$xOffset += $tileWidth 2;
    }
    
$xOffset = ($tileWidth $mapWidth) / $tileWidth $lineNumber//the new line starts again from center - half tilewidth * linenumber
    
$yOffset 20 $tileHeight $lineNumber;
    
$lineNumber++;
}
$step = (isset($_GET['step']) ? $_GET['step'] : 1);
$directions = array(
    
'w'=>array('x'=>$myX,'y'=>$myY+$step),
    
's'=>array('x'=>$myX+$step,'y'=>$myY),
    
'e'=>array('x'=>$myX,'y'=>$myY-$step),
    
'n'=>array('x'=>$myX-$step,'y'=>$myY),
);

?>

<a href="<?= sprintf('?y=%s&x=%s&step=%s',$directions['w']['y'],$directions['w']['x'],$step)?>">West</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s',$directions['s']['y'],$directions['s']['x'],$step)?>">South</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s',$directions['n']['y'],$directions['n']['x'],$step)?>">North</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s',$directions['e']['y'],$directions['e']['x'],$step)?>">East</a>
<?= $map ?>
you need following sprite map for it http://imageshack.us/photo/my-images/818/spritesr.png/

this code generates you a random map. ?x=number&y=number center your map to this position so you just need to add links to your arrows

http://cccpmik.wmw.cc/isomap/ <-- result
« Last Edit: August 17, 2011, 05:14:53 AM by BlackScorp »

Offline jack13580

  • Level 7
  • *
  • Posts: 35
  • Reputation: +0/-0
    • View Profile
Re: making a browsergame nead help
« Reply #11 on: August 17, 2011, 11:10:29 PM »
I just updated it again and here is the new code:
Code: [Select]

<html>
<head>
<style>
    div.tile{
        position:absolute;
        background: url(plain.gif) no-repeat -0px -20px;
        width: 70px;
        height:35px;
text-align: center;
curser: pointer:
    }
img {
border: none;
}
.map_click_point {
position:absolute;
text-align:center;
height:35px;
width:70px;
padding-top:6px;
}
</style>
</head>
<body>
<?php
$myX 
= (isset($_GET['x']) ? $_GET['x'] : 8);
$myY = (isset($_GET['y']) ? $_GET['y'] : 8);
//for setting the corner views
if($myX == "1" && $myY == "1"){
$myX 8;
$myY 8;
}
if(
$myX == "1" && $myY == "400"){
$myX 8;
$myY 394;
}
if(
$myX == "400" && $myY == "1"){
$myX 394;
$myY 8;
}
if(
$myX == "400" && $myY == "400"){
$myX 394;
$myY 394;
}

$tileWidth 70;
$tileHeight 34;
$mapWidth 14//set the amount of tiles 
$mapHeight 14;
$startX $myX $mapWidth/;
$endX $myX $mapWidth/2;
$startY $myY$mapHeight/;
$endY $myY $mapHeight/2;
$xOffset = ($tileWidth $mapWidth) / 2//center the first tile
$yOffset 20//put the map a bit lower

$lineNumber 1;
for (
$y ceil($startY); $y ceil($endY); $y++) {

    for (
$x ceil($startX); $x ceil($endX); $x++) {
        
$color'white';
        if(
$myX == $x && $myY == $y){
            
$color='green';
        }
//positions the first layer
    
@$map .= "<div class=\"tile\" style=\"top:".round($yOffset)."px;left:".round($xOffset)."px;\">";

//for showing the images based on corridinates from the database on the seconed layer
if($y=="1" && $x=="1" || $y=="2" && $x=="5" || $y =="14" && $x=="14"){
$map .= "<img src=\"test_image2.gif\" style=\"position:relative;top:-20;\" />"
}else { 
if($y=="2" && $x=="1" || $y=="3" && $x=="5" || $y=="2" && $x=="2"){
$map .= "<img src=\"test-pc.gif\" style=\"position:relative;top:-9;\" />"
}else {} 


//the third layer has the links
$map .= "</div>\n<div class=\"map_click_point\" style=\"color:".$color.";top:".round($yOffset)."px;left:".round($xOffset)."px;\"><a href=\"#spot=Xcord$y&amp;Ycord$x\" title=\"$y | $x\"><img src=\"click.png\" style=\"width:27px;height:21px;\"/></a></div>\n\n";
    
$yOffset += $tileHeight/2;
    
$xOffset += $tileWidth/2;
    }
    
$xOffset = ($tileWidth $mapWidth) / $tileWidth $lineNumber//the new line starts again from center - half tilewidth * linenumber
    
$yOffset 20 $tileHeight $lineNumber;
    
$lineNumber++;
}
$step 3;
$directions = array(
    
'w'=>array('x'=>$myX-$step,'y'=>$myY),
    
's'=>array('x'=>$myX,'y'=>$myY+$step),
    
'e'=>array('x'=>$myX+$step,'y'=>$myY),
    
'n'=>array('x'=>$myX,'y'=>$myY-$step),
);

echo 
"\n$map";
?>

<a href="<?php echo sprintf('?x=%s&y=%s',$directions['n']['x'],$directions['n']['y']); ?>">North</a>
<a href="<?php echo sprintf('?x=%s&y=%s',$directions['s']['x'],$directions['s']['y']); ?>">South</a>
<a href="<?php echo sprintf('?x=%s&y=%s',$directions['e']['x'],$directions['e']['y']); ?>">East</a>
<a href="<?php echo sprintf('?x=%s&y=%s',$directions['w']['x'],$directions['w']['y']); ?>">West</a>
<br />
<?php echo "X".$myY." | Y".$myX.""?>
</body>
</html>


Ok i have a few new problems.

First dealing with the movement on the map.
As you can see i set the corners so it will show it just right how can i make it so that if it is showing the 400 by 400 tiles.
So that they can't go past the set boundries and same for the other corners and the sides of map so they can't go past the 400 by 400 map boundries.

I am still trying to figure out how to fix the link problem.

Third im still trying to figure out how to get the image names + corrdinates + the correct positioning from a database
and have it show all the images on the map based on the information provided in the database.
Im pretty sure i nead to get the information in an array but im not sure where to go from there.
« Last Edit: August 17, 2011, 11:24:02 PM by jack13580 »

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: making a browsergame nead help
« Reply #12 on: August 18, 2011, 04:04:53 AM »
ok here you can setup your limits in your map

Code: [Select]
<style>
    .tile{
        position:absolute;
        background: url(sprites.png) no-repeat;
        width:70px;
        height:55px;
        line-height: 70px;
        text-align: center;
        font-size: 12px;

    }
    .tile.plain{
        background-position: 0px 0px;

    }
    .tile.town1{
        background-position: -81px 0px;
    }
    .tile.town2{
        background-position: -162px -2px;
    }
</style>

<?php
$startPosition 
= array(//getting player position from Database
    
'x' => 100,
    
'y' => 100
);
$myX = (isset($_GET['x']) ? $_GET['x'] : $startPosition['x']);
$myY = (isset($_GET['y']) ? $_GET['y'] : $startPosition['y']);
$mapLimit = array(//Setting up limits
    
'minX' => 1,
    
'maxX' => 400,
    
'minY' => 1,
    
'maxY' => 400
);
$mapArray = array(); //array with the map
$viewX 0//X and Y which will be displayed on map
$viewY 0;
$tileWidth 70;
$tileHeight 34;
$mapWidth 15;
$mapHeight 15;
$startX $myX $mapWidth 2;
$endX $myX $mapWidth 2;
$startY $myY $mapHeight 2;
$endY $myY $mapHeight 2;
$xOffset = ($tileWidth $mapWidth) / 2//center the first tile
$yOffset 20//put the map a bit lower
$avaliableTiles = array(
    
'town1''town2''plain'
);
$lineNumber 1;
for (
$y ceil($startY); $y ceil($endY); $y++) {

    for (
$x ceil($startX); $x ceil($endX); $x++) {
        
$viewX $x//View X and ViewY are the true X and Y Coordinates
        
$viewY $y;
        if (
$x $mapLimit['minX']) {
            
$viewX $mapLimit['maxX'] + $x;
        }
        if (
$x $mapLimit['maxX']) {
            
$viewX $mapLimit['minX'] - $x;
        }
        if (
$y $mapLimit['minY']) {
            
$viewY $mapLimit['maxY'] + $y;
        }
        if (
$y $mapLimit['maxY']) {
            
$viewY $mapLimit['minY'] - $y;
        }
        
$map .= '<div class="tile ' $avaliableTiles[2] . '" style="color:' $color ';top:' round($yOffset) . 'px;left:' round($xOffset) . 'px;">Y' $viewY'/X' $viewX '</div>';
        
$yOffset += $tileHeight 2;
        
$xOffset += $tileWidth 2;
    }
    
$xOffset = ($tileWidth $mapWidth) / $tileWidth $lineNumber//the new line starts again from center - half tilewidth * linenumber
    
$yOffset 20 $tileHeight $lineNumber;
    
$lineNumber++;
}
$step = (isset($_GET['step']) ? $_GET['step'] : 1);
$directions = array(
    
'w' => array('x' => $myX'y' => $myY $step),
    
's' => array('x' => $myX $step'y' => $myY),
    
'e' => array('x' => $myX'y' => $myY $step),
    
'n' => array('x' => $myX $step'y' => $myY),
);
?>

<a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['w']['y'], $directions['w']['x'], $step) ?>">West</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['s']['y'], $directions['s']['x'], $step) ?>">South</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['n']['y'], $directions['n']['x'], $step) ?>">North</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['e']['y'], $directions['e']['x'], $step) ?>">East</a>
<?= $map ?>

next thing could be getting your tiles from database and setting the tilename $map , somethink like this

foreach($y..
foreach($x
mysql_query("SELECT tilename FROM towns WHERE x= "$viewX"And y="$viewY"

iam at holidays now for 2 weeks.. so try to make your map or hopefully someone else here can help you;)

Best regards
BlackSCorp

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: making a browsergame nead help
« Reply #13 on: August 18, 2011, 04:22:28 AM »
foreach($y..
foreach($x
mysql_query("SELECT tilename FROM towns WHERE x= "$viewX"And y="$viewY"
It's raping the database... You CAN'T, simply can't put a query in such loop :) It's immoral :)

mysql_query("SELECT tilename,x,y FROM towns WHERE x<=$startx AND x>=$endx AND y<=$starty AND y>=$endy ORDER BY x,y");
And then you have 1 query (not dozens or hundred) and use the loop to display it.

Offline lolninja

  • Level 19
  • *
  • Posts: 194
  • Reputation: +5/-0
  • BSc powered Programmer
    • View Profile
    • HTTPmmo
Re: making a browsergame nead help
« Reply #14 on: August 18, 2011, 04:29:14 AM »
foreach($y..
foreach($x
mysql_query("SELECT tilename FROM towns WHERE x= "$viewX"And y="$viewY"
It's raping the database... You CAN'T, simply can't put a query in such loop :) It's immoral :)

mysql_query("SELECT tilename,x,y FROM towns WHERE x<=$startx AND x>=$endx AND y<=$starty AND y>=$endy ORDER BY x,y");
And then you have 1 query (not dozens or hundred) and use the loop to display it.


+1

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: making a browsergame nead help
« Reply #15 on: August 18, 2011, 04:36:55 AM »
Chris i knew it, just have not many time to post or think about it..
ok because of chris:D i will pack my clothes later and post this code..

Code: [Select]
<style>
    .tile{
        position:absolute;
        background: url(sprites.png) no-repeat;
        width:70px;
        height:55px;
        line-height: 70px;
        text-align: center;
        font-size: 12px;

    }
    .tile.plain{
        background-position: 0px 0px;

    }
    .tile.town1{
        background-position: -81px 0px;
    }
    .tile.town2{
        background-position: -162px -2px;
    }
</style>

<?php
$startPosition 
= array(//getting player position from Database
    
'x' => 100,
    
'y' => 100
);
$myX = (isset($_GET['x']) ? $_GET['x'] : $startPosition['x']);
$myY = (isset($_GET['y']) ? $_GET['y'] : $startPosition['y']);
$mapLimit = array(//Setting up limits
    
'minX' => 1,
    
'maxX' => 400,
    
'minY' => 1,
    
'maxY' => 400
);
$mapArray = array(); //array with the map
$viewX 0//X and Y which will be displayed on map
$viewY 0;
$tileWidth 70;
$tileHeight 34;
$mapWidth 15;
$mapHeight 15;
$startX $myX $mapWidth 2;
$endX $myX $mapWidth 2;
$startY $myY $mapHeight 2;
$endY $myY $mapHeight 2;
$xOffset = ($tileWidth $mapWidth) / 2//center the first tile
$yOffset 20//put the map a bit lower
$avaliableTiles = array(
    
'town1''town2''plain'
);
$lineNumber 1;
$sql "SELECT users.username as owner , towns.townname as town ,towns.x as x,towns.y as y,towns.points as points, towns.picture as picture ".
"FROM users INNER JOIN towns ON(users.id = towns.user_id) ".
"WHERE towns.x BETWEEN ".$startX." AND ".$endX." ".
"AND towns.y BETWEEN ".$startY." AND ".$endY ." ";
$sql mysql_query($sql) or die(mysql_error());
 
while(
$row mysql_fetch_array($sql)){
$mapArray[$row['y']][$row['x']] = array(
'owner' => $row['owner'],
'townname'=> $row['townname'],
'points'=>$row['points'],
'picture'=>$row['picture']
)
}
for (
$y ceil($startY); $y ceil($endY); $y++) {

    for (
$x ceil($startX); $x ceil($endX); $x++) {
        
$viewX $x//View X and ViewY are the true X and Y Coordinates
        
$viewY $y;
        if (
$x $mapLimit['minX']) {
            
$viewX $mapLimit['maxX'] + $x;
        }
        if (
$x $mapLimit['maxX']) {
            
$viewX $mapLimit['minX'] - $x;
        }
        if (
$y $mapLimit['minY']) {
            
$viewY $mapLimit['maxY'] + $y;
        }
        if (
$y $mapLimit['maxY']) {
            
$viewY $mapLimit['minY'] - $y;
        }
        
        
$map .= '<div class="tile ' $mapArray[$viewY][$viewX]['picture'] . '" style="color:' $color ';top:' round($yOffset) . 'px;left:' round($xOffset) . 'px;">Y' $viewY'/X' $viewX '</div>';
        
$yOffset += $tileHeight 2;
        
$xOffset += $tileWidth 2;
    }
    
$xOffset = ($tileWidth $mapWidth) / $tileWidth $lineNumber//the new line starts again from center - half tilewidth * linenumber
    
$yOffset 20 $tileHeight $lineNumber;
    
$lineNumber++;
}
$step = (isset($_GET['step']) ? $_GET['step'] : 1);
$directions = array(
    
'w' => array('x' => $myX'y' => $myY $step),
    
's' => array('x' => $myX $step'y' => $myY),
    
'e' => array('x' => $myX'y' => $myY $step),
    
'n' => array('x' => $myX $step'y' => $myY),
);
?>

<a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['w']['y'], $directions['w']['x'], $step) ?>">West</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['s']['y'], $directions['s']['x'], $step) ?>">South</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['n']['y'], $directions['n']['x'], $step) ?>">North</a>
<a href="<?= sprintf('?y=%s&x=%s&step=%s', $directions['e']['y'], $directions['e']['x'], $step) ?>">East</a>
<?= $map ?>

and Jack stop editiing your code.. just replace my code with yours..

EDIT:

and please help jack instead of sayin somethink about my mistakes;) iam not who want to have a Diamond Iso Map
« Last Edit: August 18, 2011, 04:41:10 AM by BlackScorp »

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: making a browsergame nead help
« Reply #16 on: August 18, 2011, 05:15:20 AM »
and please help jack instead of sayin somethink about my mistakes;) iam not who want to have a Diamond Iso Map
http://www.google.com/imgres?q=graph+of+youtube+comments&um=1&hl=en&client=firefox-a&sa=N&rls=org.mozilla:pl:official&biw=1728&bih=800&tbm=isch&tbnid=4PwKC761TYcYxM:&imgrefurl=http://outmanned.com/blog/category/youtube/&docid=2Lxi8PJDj8rGxM&w=450&h=443&ei=V-VMTobvF9D34QS3uZCwBw&zoom=1

In the end we are all humans (even game devs), it is so in human nature to fall into the red part of the pie chart :D
Sorry...

Offline Basti

  • Level 2
  • *
  • Posts: 3
  • Reputation: +0/-0
    • View Profile
Re: making a browsergame nead help
« Reply #17 on: August 21, 2011, 11:23:15 AM »
Quote
I am still trying to figure out how to fix the link problem.
You could make the divs click-able with javascript.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: making a browsergame nead help
« Reply #18 on: August 24, 2011, 03:47:08 AM »
More about DB,  as you requested.

"`CorX` varchar(100)" it should be INT, I have on idea why you thought of varchar here...

"`IP_address` varchar(50)" IP adress is not 50 chars, and it can be represented as fixed size, the same for "`date` varchar(50) ". Since these are the only variable width fields in that database you could easily change it into fixed size table, which is very good for performance (especially MyISAAM).

"`IP_address` varchar(20)" and here IP is 20 not 50? Inconsistent.

"`password` varchar(200) " here you really went overboard, 200 char password? There are limits on people's paranoia, no one is as paranoid as to use 200 chars pass :D


Again, I don't think you need to worry about this right now, since this could be changed easily later. But the DB data structure is very poor (but the overall schema is acceptable).

Offline jack13580

  • Level 7
  • *
  • Posts: 35
  • Reputation: +0/-0
    • View Profile
Re: making a browsergame nead help
« Reply #19 on: August 24, 2011, 03:50:09 PM »
and the password part i had a problem with one of my old sites where i salted and md5'd the password and i had it set to 50 varcher and it got messed up so thats why

and about :

about the server thing i use purchased hosting at hosting24.com so i can't pick what computer gets used but i do have a lot of freedom.

and my thoughts for the server thing was:

with my website i have, my hosting service lets me add as many sub links as i want
so for the server i could do
S1-Medieval-Europe.medieval-wars-online.com

what would be bad about doing multible servers that way and also im not planning to have more then 1 server till the first gets over 1000 players which i dubt will happen
« Last Edit: August 24, 2011, 03:52:17 PM by jack13580 »

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal