Jump to content

[SOLVED] browser based game (map)


max_w1

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/89563-solved-browser-based-game-map/
Share on other sites

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.

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?

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).

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.