max_w1 Posted February 5, 2008 Share Posted February 5, 2008 hi! i am in a process of creating a browser based rpg (role playing game), there is a map where user cam move around and see others moving around. can anybody tell me how to do that. i have a plan for the map and a single player. but i dont know how to display other people who are online and their moves. thankyou in advance... Quote Link to comment Share on other sites More sharing options...
revraz Posted February 5, 2008 Share Posted February 5, 2008 Realtime movement? Doubt you can do that with php. Quote Link to comment Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 Its not impossible with php - you can force a reload of the page ever few seconds. But then your page is constantly reloading. On top of this, its not true real-time, its always going to be off by the amount of time since the last page reload. It could be done better with javascript, but still not that well. Javascript can't listen for other files to do something, it has to call the other files and ask for something. So its the same basic issue as with php - its not true real-time. Quote Link to comment Share on other sites More sharing options...
max_w1 Posted February 5, 2008 Author Share Posted February 5, 2008 we can do this i have a plan. the mape is divided into 12 rows and 12 colums and will be displayed in 12 diffrent rows and coloums of a table as a background. and a image is loaded according to the x and y axis. for example if ($_GET["x"] == 1 && $_GET["y"] == 2) the image will be displayed in the top second colum of the map. but what i need is how should i display other people who are online in my map? Quote Link to comment Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 I can think of two options: Both of them require 12x12 table in your database that registers where any player is at a given time. As moves are made, the table is updated with the players location. option 1 - php Use a header function to reload the page after a set period of time. As the page updates, it accesses the database to see where the players are currently located, and loads the appropriate image. option 2 - AJAX Same basic idea, but rather than reloading the whole page every few seconds, have your ajax function check the database to see if any changes have been made since its last check (you will need to add some extra columns to your database to know if there have been any changes). Quote Link to comment Share on other sites More sharing options...
max_w1 Posted February 5, 2008 Author Share Posted February 5, 2008 can i use flat flie to store this temproary information insted of sql? Quote Link to comment Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 I don't know what a flat file is. But you can use whatever you want as long as it will store data, and you have a way of accessing that data. If you can do that with a flat file, then the answer to your question is yes. Quote Link to comment Share on other sites More sharing options...
max_w1 Posted February 5, 2008 Author Share Posted February 5, 2008 thankz Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.