User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: City Building Engine with online database

  1. #1
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleUnicode Add-onInstall Creator Pro
    StingRay's Avatar
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    1,052
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

    Question City Building Engine with online database

    Hi! I'm planning a city building game for a client (like you all may know 'cityville', 'megapolis',...)

    it's in the early stages and it should work on ios as well as on facebook. so it should be cross-plattform compatible.

    the user should be able to play the game on his ipad and at the same time continue at his pc on facebook.
    for this there will be an online database needed (save and load the progress of the player)

    the playfield can get a huge (it happens fast that in such a game you have 300x300 field at the end of the gameplay)

    the first i would think of is to use array for 'saving the city' but i'm afraid i cannot upload this data to a server.

    so should i use instead INI for this? I'm afraid that the ini file can get a bit huge in size and uploading the data with GET could fail (and with ini it can get a bit complicated at the end with 300x300 entries )


    what do you think about this problem, and may you have some kind of solution (I'm actually not thinking about)?!?

    thanks

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,365
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    When you save to the server, only save what is new from when the player loaded data from the server. You don't need to upload the whole city every time the clients posts to the server. When the player does something, the client uploads the new data to the server. It should tell the server wich cell was being altered. You can choose to store the data in the database in which way you'd like.

  3. #3
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleUnicode Add-onInstall Creator Pro
    StingRay's Avatar
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    1,052
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    thanks popcorn!

    do you know of some example for this type of storing data on the fly?

    i only can think of GET and a php script to feed a database, but i have just to low expierience what is the best way to start. (to not end up with a system that is just to huge)

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,365
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Well, then you're on the right track. You don't need more than that

    If the game logic going will be handled clientside, you don't need much servercode at all. Then you'll just have to make functions for sending and receiving data.

    To reduce servertraffic, only let the client send and retrieve data when it needs to. When the player first loads the game on a client, the server must send all gamedata. The next time the player requests data, the server should know which data was allready sent to the player, and only send the changes. Though since the game can be open on several clients at once, it should also check for data on timed intervals. You should also check for changes everytime the player uploads data, in case there was changes between the intervals.

    So on the server, have a basic function that retrieves all changes after a given step. The server itself should store what step the client was at the last time it retrieved / sent data. That means you will have to identify the different clients on the server, not only the player.

    The database should at least have 4 tables: players, clients, games and actions.

    Example:

    Players:
    PlayerId - int
    Playername - String

    Clients:
    ClientId - int
    GameId - int
    LastActionId - int

    Games:
    GameId - int
    PlayerId - int
    Gameover - boolean

    Actions:
    ActionId - int
    Action - String
    PlayerId - int
    ClientId - int


    The players table will keep track of all the players that plays your game
    The clients table will keep track of all clients
    The games table will keep track of all games that are played
    The actions table will keep track of all actions in a game

    When a client asks for gamedata, it tells the server its ClientId and the player's PlayerId, and also which game it wants to retrieve data from. The server will read the Clients table to check which action was the last registered for this client. Then it tells the Actions table to rerieve all rows where PlayerId = PlayerId, ClientId = ClientId and ActionId > ActionId.
    The server will then output the data as a string with delimiters between each action.

    Example of a string output from the server: 0;5;24;b;13|1;6;24;b;13

    How you format the output string is entirely up to you. Just make sure that it is as short as possible, and can easily be read by the client.
    When this string is sent to the client, the client should know what to do with it.

    The format in the above string is this: ActionId; x cell; y cell; action type; buildingId

    So the whole string could be translated to: ActionId = 0; x cell = 5; y cell = 24; action type = build; buildingId = 13|ActionId = 1; x cell = 6; y cell = 24; action type = build; buildingId = 13

    This would create two buildings, one at cell (5,24), and one at cell (6,24). Both being the same building, type 13.

    In the client, you will need to use a parsing tool, such as the String Parser 2 to split the data. Then use fastloops to loop through each action, and finally split each action into readable data.


    Was this enough info for you to get you started?

  5. #5
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleUnicode Add-onInstall Creator Pro
    StingRay's Avatar
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    1,052
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    that is just great, thanks alot!

    one question: why i need clientID's? where's the difference if the player plays on pc or ipad?

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,365
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StingRay View Post
    that is just great, thanks alot!

    one question: why i need clientID's? where's the difference if the player plays on pc or ipad?
    Maybe you can do without it. I just thought it was helpful when the player has the game open on two devices at the same time. This way the server will know which actions that device have not recieved yet. But you might come up with a better system

  7. #7
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleUnicode Add-onInstall Creator Pro
    StingRay's Avatar
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    1,052
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    for the game: would you prefer array (never used them already) or ini?

    or is this just a matter of taste?!?

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,365
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    It's probably best to load the data into arrays, although it sure is a matter of taste. I always use inis, although for a game like this I think I would use arrays.

  9. #9
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleUnicode Add-onInstall Creator Pro
    StingRay's Avatar
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    1,052
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    would you recommend to think about influences between the grid units?

    i just think of satisfied residents if a cafe/school is around. or less burning risk if there is a fire department around.

    this could end up huge and i'm not sure if it's clever to include (i think of a bunch of fastloops and i'm afraid that this will end up with killing framerate/user expierience)

    i can limit it of course to just test if a new building is created, but if you think of a maximum grid of 100x100 units this can real become a problem...

    or am I just anxious?

    EDIT:
    and if testing: should i use ini to check or array? speed?

  10. #10
    Clicker Multimedia Fusion 2 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleMac Export ModuleSWF Export ModuleXNA Export Module
    colej_uk's Avatar
    Join Date
    Nov 2006
    Location
    UK
    Posts
    739
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm developing something quite similar for the next megacity game.

    What I ended up doing is using a 3 dimensional array to store the city data, and the engine loads buildings on the fly as you scroll around. I'm not sure if you are better off with array or ini, but array made more sense to me.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Trying to set up an online high score database...
    By RGBreality in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 14th September 2010, 01:17 AM
  2. Online score with SQL database
    By Solgryn in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 11th February 2009, 08:47 PM
  3. receive/send Stuff to an Online Database or .ini
    By Raikyo in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 9th July 2008, 02:41 AM
  4. Online Database
    By TotalProjects in forum Multimedia Fusion 2 - Technical Support
    Replies: 23
    Last Post: 29th September 2007, 06:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •