Rly need for someone to explain and help
Rly need for someone to explain and help
Ok, well like first thing is i have working in my game were like the player can click on an empty building spot and it the shows the player which buildings he/she can build. then they click on the build link and it goes to build.php and updates the DB and all that stuff and automatically redirects to villageview.php within 0.5 seconds. What i really need help with is i need to add somehow an amount of time that it actually takes for that building to be built. like after it redirects back to the villageview.php so that under the little pic of the building that is building, it'll have the count down untill its built. i almost have no idea how to do this, so any help is rly rly going to be appreciated.
Lastly, im getting close to the time when ill have to make a map for my game. the reason halls tutorials cant rly help me on this is because his games are like rpg. mine there is no person that actually moves around or anything. like players start with a village and latr on they can build or found new colonies and villages. So how i need the map to be is sort of like this:
-when the player registers, so that it would put him on the map.
-when a player clicks on map, so that it would center his current village in the middle of the map
-all the map is going to have are players villages. (maybe latr ill add npc barbarian villages)
so like i have no idea even were i would start with this. i rly need someone to explain this to me. THANKS!!!
Lastly, im getting close to the time when ill have to make a map for my game. the reason halls tutorials cant rly help me on this is because his games are like rpg. mine there is no person that actually moves around or anything. like players start with a village and latr on they can build or found new colonies and villages. So how i need the map to be is sort of like this:
-when the player registers, so that it would put him on the map.
-when a player clicks on map, so that it would center his current village in the middle of the map
-all the map is going to have are players villages. (maybe latr ill add npc barbarian villages)
so like i have no idea even were i would start with this. i rly need someone to explain this to me. THANKS!!!
Thanks,
Slav2
Slav2
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Rly need for someone to explain and help
Having a timer show when the building will be ready is going to be Javascript. No way for PHP to do it. It is actually quite easy in Javascript, and a breeze in jQuery, which I highly suggest.
As for the map, problem, one way to handle it would be through absolute positioned images. For example, you store everyone's village as a pixel location on the main map in the database. Add a div to your page to wrap the world map with no space inside (i.e., the div hugs directly against the border of the map. Now you can absolutely position the villages against the div, and they will appear to be on the map, even though they are technically on a layer above it. You can just fetch the pixel positions from the database and draw the villages at those locations.
As for the map, problem, one way to handle it would be through absolute positioned images. For example, you store everyone's village as a pixel location on the main map in the database. Add a div to your page to wrap the world map with no space inside (i.e., the div hugs directly against the border of the map. Now you can absolutely position the villages against the div, and they will appear to be on the map, even though they are technically on a layer above it. You can just fetch the pixel positions from the database and draw the villages at those locations.
The indelible lord of tl;dr
Re: Rly need for someone to explain and help
ok, but like if i did do it in javascript, like how would i kinda do this?Having a timer show when the building will be ready is going to be Javascript. No way for PHP to do it. It is actually quite easy in Javascript, and a breeze in jQuery, which I highly suggest.
hmmm dont understand exactly what you mean, but i think i might have an idea as to what u ment. ill try this and see how it goes.As for the map, problem, one way to handle it would be through absolute positioned images. For example, you store everyone's village as a pixel location on the main map in the database. Add a div to your page to wrap the world map with no space inside (i.e., the div hugs directly against the border of the map. Now you can absolutely position the villages against the div, and they will appear to be on the map, even though they are technically on a layer above it. You can just fetch the pixel positions from the database and draw the villages at those locations.
question
im constantly running into issues with these while loops...like here is the one thats not displaying anything at all:
Code: Select all
<?php
if ($bypass != 1)
echo "<br/><table><tr><td> </td><td><b>Subject</b></td><td><b>From</b></td><td><b>Received</b></td></tr>";
$get_messages = mysql_query("SELECT * FROM inbox WHERE to_user='$currentuser' ORDER BY id DESC") or die(mysql_error());
while ($messageinfo = mysql_fetch_array($get_messages)); {
echo $messageinfo['id'];
}
?>
Thanks,
Slav2
Slav2
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Rly need for someone to explain and help
As for the while loop, use mysql_fetch_row(), not fetch_array() if you are expecting multiple results back to loop through. I could be wrong, but I don't think that fetch_array is enumerable in that way and attempts to unload itself completely on the first pass. Maybe someone else can chime in on this, as I have never tried to use fetch_array() that way and just used fetch_row.
As for the Javascript issue, I am not sure I follow what you want to do, so I suggest to check out Halls game-based tutorials (such as Forsaken Sanctum) and his Javascript tutorials. These go over Javascript and what you can do with them. If you just need a timer, that is pretty simple and there are literally hundreds of tutorials online for how to do it (look up "Javascript settimeout()" for a long list of tutorials). If you need parts of the game to get feedback from the timer, that is going to get more complex, in which case the timer in Javascript is just going to be decorative, and the real calculation will be done on the server.
As for the Javascript issue, I am not sure I follow what you want to do, so I suggest to check out Halls game-based tutorials (such as Forsaken Sanctum) and his Javascript tutorials. These go over Javascript and what you can do with them. If you just need a timer, that is pretty simple and there are literally hundreds of tutorials online for how to do it (look up "Javascript settimeout()" for a long list of tutorials). If you need parts of the game to get feedback from the timer, that is going to get more complex, in which case the timer in Javascript is just going to be decorative, and the real calculation will be done on the server.
The indelible lord of tl;dr
Re: Rly need for someone to explain and help
oh ok ill try the mysql_fetch_row(). and yea for the time thing, ill have to try and find some tutorials on that.
But could you give me just a little more info on how i would code that map that you explained earlier?
But could you give me just a little more info on how i would code that map that you explained earlier?
Thanks,
Slav2
Slav2
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Rly need for someone to explain and help
Here is an idea of how absolute positioning works (not full page code):
Assume that the map image is about 200x200px. The div will also be 200x200px because it fits to hold the content inside it. Once the "insidemap" images are turned to absolute positioning, the location referenced by the "top" and "left" in the styles refer to the pixels from the left and top of the containing div, which in this case is going to basically be the same as the image. So provided that the "insidemap" images are significantly smaller than the map, you can place those anywhere you want by generating the "left" and "top" values through PHP or Javascript.
Code: Select all
<style type="text/css">
#insidemap1 {
position: absolute;
top: 32px;
left: 98px;
}
#insidemap2 {
position: absolute;
top: 124px;
left: 21px;
}
</style>
<body>
<div id="wrapper">
<img id="map" src="somepic.png" />
<img id="insidemap1" src="somecreature1.png" />
<img id="insidemap2" src="somecreature2.png" />
</div>
</body>
The indelible lord of tl;dr
Re: Rly need for someone to explain and help
hmmmm...ok this gave me a much better understanding......ummm for the wrapper div, like does that do on my style.css the same way as the top part? or like is it going to be something like .wrapper ?? <<-- cause ive seen that somewere before, but not rly sure what its for.
And then one more thing thats unclear for me is like what if the world map is 100x100 squares. the player only see's 10x10 at a time....
|
\/
ok, so like the things im wondering how to do write is, right after the player registers, ill need it to automatically place the players village somewere on the map....how would i do this? and so like back to the 100x100 map, how would i put this in the DB and then display only 10x10 parts of it. like the player will be able to go to direct cordenents or, move left right or up or down.
And then one more thing thats unclear for me is like what if the world map is 100x100 squares. the player only see's 10x10 at a time....
|
\/
ok, so like the things im wondering how to do write is, right after the player registers, ill need it to automatically place the players village somewere on the map....how would i do this? and so like back to the 100x100 map, how would i put this in the DB and then display only 10x10 parts of it. like the player will be able to go to direct cordenents or, move left right or up or down.
Thanks,
Slav2
Slav2
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Rly need for someone to explain and help
I don't quite understand your question about the divs. The part in the <style> tag could/should go in an external stylesheet (style.css if that is what you are calling it).
As for the map, if you want to be able to scroll around the map and only see parts at a time, I would just make them all separate images to just give the illusion of scrolling around. That way when the user clicks a direction, the page reloads with the portion of the map that they are moving to. There are ways to make it actually scroll without a screen refresh, but doing that with dynamic villages would be quite advanced Javascript, so I would suggest to not worry about that for now.
You won't actually store the map image in the database (you will store it in an image folder, just like normal). Instead, you will just store (X, Y) coordinates in the database that can be used to fill in the "top" and "left" values in the code.
As for the map, if you want to be able to scroll around the map and only see parts at a time, I would just make them all separate images to just give the illusion of scrolling around. That way when the user clicks a direction, the page reloads with the portion of the map that they are moving to. There are ways to make it actually scroll without a screen refresh, but doing that with dynamic villages would be quite advanced Javascript, so I would suggest to not worry about that for now.
You won't actually store the map image in the database (you will store it in an image folder, just like normal). Instead, you will just store (X, Y) coordinates in the database that can be used to fill in the "top" and "left" values in the code.
The indelible lord of tl;dr
Re: Rly need for someone to explain and help
hmm oh ok...i think i may understand exactly how to do it...last thing on this subject for now: like for example, lets say that x=25 and y=25 is just grassland. then a player registers, (no idea how it would randomly give him x and y continents) and somehow it puts him in x=25 and y=25. so like how would i make that little square pic of the grassland that was there before, now display a different pic?
and one more thing off subject, ive never done checkboxes before, and dont know how to do this corectly:
ok i have this:
so like it make a table with all those different messages they have in the DB for that player. then they can check the boxes and click the Delete Selected button, and it reloads the same page, except it does this part:
its not actually deleting cause i kno i prob set it up wrong. if you could tell me what i did wrong, or what im still not doing, it would be nice. (btw i tried to find this on google, but it shows the checkboxs already with default values. here it has to the message id, and then delete the messages selected, based on the id.)
and one more thing off subject, ive never done checkboxes before, and dont know how to do this corectly:
ok i have this:
Code: Select all
<?php
if ($bypass != 1)
{
echo '<form name="select" method="post" action="inbox.php?delete">';
echo "<br/><table border='0' style='border-width: 0px; border-color:#000000; border-style: solid; margin-left: 10;'><tr>";
echo "<td> </td><td><b> Subject </b></td><td><b> From </b></td><td><b> Received </b></td></tr>";
$messages=("SELECT * from inbox WHERE to_user='$currentuser' ORDER BY id DESC");
$messages2=mysql_query($messages) or die("Could not get messages!");
while($messages3=mysql_fetch_array($messages2)){
$messageid=$messages3['id'];
$from=$messages3['from_user'];
$to=$messages3['to_user'];
$subject=$messages3['message_subject'];
$content=$messages3['message_contents'];
$time=$messages3['message_sent'];
$unread=$messages3['unread'];
echo "<tr><td><input type='checkbox' name=".$messageid." value=' '> ".$unread."</td><td><A href='inbox.php?id=".$messageid."'>".$subject."</a></td><td>".$from."</td><td>".date("M-d-Y g:i A", $time + 7200)."</td></tr>";
}
echo "</table>";
echo "<input type='submit' value=' Delete Selected '></form>";
}
?>
Code: Select all
<?php
if(isset($_GET['delete']))
{
$bypass = 1;
$delete = $_POST['$messageid'];
mysql_query("DELETE FROM inbox WHERE id='$messageid'");
}
?>
Thanks,
Slav2
Slav2
Re: Rly need for someone to explain and help
i didnt read trough all the posts, but your last question is not that hard.
Either you store all x and y coordinates in your database, or you store all x and y values from users in the database. Even so, you still need the map to be specified to be working with both cases, so i recommand storing all fields in the database.
Now, if you generate a map, you can get properties for each field in your map. So if you know 20,20 has a user, you can give it a different style, based on the database information.
This is how i`m going to implement it anyway. I`m currently working on a map editor, but until then or something odd has to happen, thIs will be the way for me to follow. I guess you can do the same, unless someone else here has a better idea?
Either you store all x and y coordinates in your database, or you store all x and y values from users in the database. Even so, you still need the map to be specified to be working with both cases, so i recommand storing all fields in the database.
Now, if you generate a map, you can get properties for each field in your map. So if you know 20,20 has a user, you can give it a different style, based on the database information.
This is how i`m going to implement it anyway. I`m currently working on a map editor, but until then or something odd has to happen, thIs will be the way for me to follow. I guess you can do the same, unless someone else here has a better idea?