How much GD is too much?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
Brokenhope
Forum Newbie
Posts: 6
Joined: Mon Dec 11, 2006 7:11 pm

How much GD is too much?

Post by Brokenhope »

Im working on a MMORPG and the maps are generated with GD by repeating the background image over a 320x320 pallate minimum, tiles being 16x16. On top of that tiles 16x16 to 80x80 are layred ontop of it, and one final image is saved to the server. Now theres 2 ways I can do this, generate the new map image every single time a new single object tile is layered on [through the map editor you add tiles such as barriers 1 at a time, via form], so that could be 50 times per 1 map edit, and thats a lot considering theres going to be several maps created a day.

So roughly GD will be creating around 50 320x320 images, 1 about every 5 seconds [though the form is filled out and submited 1 at a time, its not a looped action]. The maps when generated will have maybe 6 images at most accessed, and the background repeated 200 times.

Is that too much? Will it cause too much lag or use up to many resources? Right now im running Apache on windows with PHP4, but when this game comes closer to completion I will be investing in a small hosting package, just minimal needs.

I could also just update the image all at one time once your done editing, however the image wouldnt get updated if the editor forgets to click the update map image link, and while your editing the map, people navigating it at the same time will run into random things they dont see, and will completely cause problems (not that this would 100% not happen with the other way, it would only happen if the user slipped between the query insert/update and the GD image write).

So what do you think, would I be overusing GD if I did it so rapidly like that? Or should I just create the new image when all the editing is done?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You can likely use HTML and transparency to build the needed design. Technically, you could do the entire thing in HTML and CSS without any GD. If you require that these be finalized as images you can simply store the information required to build the end result in session data and either manipulate it through standard forms like you do now (using HTML and CSS for the quick view) and generate the image after the user has finalized the design.
Brokenhope
Forum Newbie
Posts: 6
Joined: Mon Dec 11, 2006 7:11 pm

Post by Brokenhope »

The problem is this map thing is becoming increasingly complex, and im using so many tables for just map functions. Right now there is:

maps - Holds the maps basically just plugs an id to a x and y value, and gives the script the image.
map_id
map_name
map_x
map_y
map_img -> I would find it much more eaiser and browser compadible to have GD generate the image, and to layer the persons character image over it.

maptiles - Stores each tile type, what map its on, and where its at on that map
mt_id
mt_mapid -> specifys which map_id it goes too
mt_tileid -> specifys which tile_id it is, which is queryed from the tiles table
mt_x -> x position on map
mt_y -> y position on map

tiles - Stores all the tiles used for map editing
tile_id -> the id
tile_img -> the .jpg or .gif image
tile_width -> the width; every 16px equals 1
tile_height -> same as above
tile_name -> just a name
tile_type -> 0 = None; 1 = Barrier; 2 = Building
tile_wildnumber -> an extra field for a number, currently only for buildingid


Right now im thinking on the terms of each form submit would update maptiles and insert the selected tileid and such, and position it. But since that table would be accessed for users browsing the map, and the image of the map wouldnt be updated, barriers will appear and disappear out of nowhere. It would not be a huge blow using CSS and Javascript for the map editor so everything can be added to the map, and inserted to the database, and an image to be generated after that, but it would be a huge blow to rely only on CSS for displaying the map for the users...

so somehow in a process I have to get the image creation and database updating to happen in the same runtime.
Post Reply