PHP city-sim castle layout

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I am currently contemplating the layout system for my php based game but i've run into a couple of worries. So my idea is a 9X9 grid where the center 3X3 are inner castle. The inner castle will be 6X6 if you enter it(click on it). and with the option to expand the inner castle converting one of the 9X9 tiles to a 4X4 inner castle tile. So here is my question: What is the best way to tackle this type of layout? my original idea was a 18X18 grid and saving it in the db as (idCastle, Y, X) where X is a string of 18 numbers long telling me if the tile is an inner/outer tile or a inner/outer building. but i am not really fond of this idea and would like to hear some other ideas on how to tackle this. Thanks in Advance,

 

Gert

profilepic.png
manpreet 2 years ago

It depends on whether or not information about the outer layer tiles can be deduced from information about the inner layer tiles. If they can, then database normalization suggests to treat information about the outer layer tiles as redundant and only store information about the inner layer tiles. This is how this might work:

table tile // only inner tiles are recorded
    id (or use [castleID, x, y] as a composite primary key])
    castleID (int)
    x (tinyint) // on a 18x18 grid
    y (tinyint) // on a 18x18 grid
    content (whatever) // content of the inner tile for castleID at position 

This will result in 18x18 entries for every castle, assuming that you save all non-castle tiles as well. You could also just store castle tiles and assume that if there isn't a record for a given position, the tile is unoccupied. In order to get information about the outer layer tiles, you have to fetch information about the respective inner layer tiles and deduce information about the outer layer from that.

If, on the other hand, information about the outer layer tiles cannot be deduced from their respective inner layer tiles, you have to add another table for the outer layer tiles:

table outertile
    id (or use [castleID, x, y] as a composite primary key])
    castleID
    x (tinyint) // on a 9x9 grid
    y (tinyint) // on a 9x9 grid
    content  (whatever) // content of the outer tile for castleID at position 

The content field is just a placeholder for whatever you want to store with respect to your tiles. In actuality, it might be an id of a record in your building table, or several fields like startedBuilding (timestamp), spriteFile (varchar), etc


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community