Advanced C2 - Building a Online Browser Game With C2

0 favourites
From the Asset Store
A cool way for kids to write and practice English Alphabets
  • *Moderators - this is a How to thread but is ever evolving like a presentation thread. If you feel it is more appropriate elsewhere on this site feel free to move it.

    My Current Issue<< Starts on page 3

    Hello all its been a minute but let's get back into this. I have found a solution to how I want to handle the players unlocked items. Instead of a very large CSV file that I am pulling from my server. Which is both slow and expensive. I simply have a JSON of a C2 Dictionary that list which items are locked vs unlocked. I then after loading the dictionary use it to change a master CSV that I pull from the project folder that has everything locked as default. Seeing as right now my one faction has 125 characters one can choose from plus each having unique stats and abilities this I found is a great solution.

    Now the thing tripping me up at the moment is more basic to C2. In my menu I have six instances of my officers I can choose from. Also instances of text items for their name, various stats and abilities. This is something that I have always had a time of wrapping in my head. How does one translate how one object functions by using a different object?

    I have a "For each Row in Column" Loop with the Compaire Two Items "CSVOfficer.At("Unlocked",CSVOfficer.CurRow). I also have a Pick instance just selecting instance 0 of one of my six sprites that show the portrait of the officer in question. I then want to change the frame of that sprite to equal the row (which is indexed numerically) of my CSV.

    That works all well and good but now I am attempting to do the second sprite (the other five as well) Where it is the same only i Pick instance 1 of my sprite. But without knowing how to increment to the next option those five sprites end up being the same as Sprite number 0.

    I've tried adding the sprites IID number to the option when setting the frame but that will not work since it is possible for the next row to be false so if they were on row 3 and I add one it then would display row 4 but if row 4 was false then that is not right.

    And that is not even taking into account flipping through pages of all the officers.

    CrazyVulcan

    The Goal<<

    This is going to be a continuously updated thread as I have decided against making a number of different but related threads. I will do my best to keep this post Up to date on the current issue I am focusing on.

    My game is meant to bring the table top miniature war game to the easy access of the Internet. It is a Space Navy war game of my own original design meant to be played with two players using small to large scale fleets. Using a cost system I will hope to balance out players who bring powerful ships worth lots of points to any player who dose not have the rare or other wise expensive ships/officers/equipment

    The game will be free to play with a cash shop monitization system where players can chose to buy in game currency with cash. This currency will of course be grindable by players who chose to not pay for their items. Things you could buy are things like new ships, special crew, access to new factions, and other things that while game effecting. Will be assigned a apropate number of points to balance them. Players win currency for playing online match's and a auction house that will allow players to sell their won items for their value in currency.

    Players can gain new items for completing missions (more later) and winning games at random. These packs will be random and will need a key from the shop to open and unopened packs can be sold to earn currency faster. These packs will not be hard to come by so selling them is a viable option. Simply the more you play the more currency you get and buying currency for real money is simply a way to get what you want faster.

    The business aside the game will be a large undertaking and I intend to see that a alpha will be done within the end of the year. This game will take place on its own web site and I am learning to code HTML, CSS, PHP, and MySQL as fast as I have time to learn. Its frustrating at times and often I have run into problems that while I could ask for help I had determinedly stuck to my own ability. But I came around to not only wanting help but to share what I am working on as I really am trying to push C2 to its limit.

    Oh and for those that do not like to play online I intend to once I have the alpha done and move into beta I will make a single player campaign that you can play solo and even make your own ship and officers. that will then be available to use in online match's.

    And once all these "small" tasks are done I will be launching a physical version that will allow you to play with your friends in your own home. Hopefully will get the ball rolling on that by next summer.

    ps yes....yes I am crazy but it is what makes me so charming

  • Good luck! Its going to be tough especially the time it'll take for one person.

    I am working on a similar project, The website for my game is http://keo.land/ and a video at

    Subscribe to Construct videos now

    .

    I've tested passing data into the C2 game from the website as well as website data into C2. I purchased an icon pack and drew 800+ images to equip onto the avatar. The player's equipped items are in the database and the items on the inventory can be equipped. The "Explore" page shows a map that is map in C2.

    I've been working on this on and off casually for about 4 months and at this rate, its still going to be miles away!

  • Here is another similar topic.

  • Good luck! Its going to be tough especially the time it'll take for one person.

    I am working on a similar project, The website for my game is http://keo.land/ and a video at

    Subscribe to Construct videos now

    .

    I've tested passing data into the C2 game from the website as well as website data into C2. I purchased an icon pack and drew 800+ images to equip onto the avatar. The player's equipped items are in the database and the items on the inventory can be equipped. The "Explore" page shows a map that is map in C2.

    I've been working on this on and off casually for about 4 months and at this rate, its still going to be miles away!

    Looks great, This is very much what I am trying to accomplish. Think of each ship as a character with officers being equipped to it, and equipment equipped to it. And each officer is a character with Ability's, so its a group of characters grouped to another character, which is one of many characters you control. <img src="{SMILIES_PATH}/icon_e_confused.gif" alt=":?" title="Confused"> Its simpler than I am making it out to be but my game is a character Turduckin.

    Do you mind going into a little more detail on how you passed data into C2. Like For that Dragon Sword. What file type did you use and what were some difficulty's you came across.

    rexrainbow , I owe a big thanks to you as your CSV plugin has carried me this far. If I had a way to edit those CSV docs on the fly I would be in great shape but now I am ready to move on to more advanced means of data storage. Thank you for all the work you do here

  • CSV plugin 's "Action:Set entry" could change the value in event sheet.

  • This thread has some awesome links and info! thanks rex!

    [quote:2x3vhpux]Do you mind going into a little more detail on how you passed data into C2. Like For that Dragon Sword. What file type did you use and what were some difficulty's you came across.

    Right now it is only loaded into the C2 project with url parameters like?a=b&c=d. So it is a one time thing when loading the iframe url, if i can pass a userkey into the C2 file, then it should be enough to communicate from C2 to the server with the user's identity. Rex's plugin looks like it will work better than this method!

    The dragon sword isn't shown through C2, its just html+javascript+php, i changed the item system from database to json and back to database. Ultimately to do it properly, i guess a database would be the correct solution.

    My difficulty is the lack of planning. I just had the ideas in my head so i keep on changing stuff! I should really create a plan like you have

  • I need to move my first question to here so my first post would be just my game synopsis and the current question. The Op will have links to each subsequent question.

    03/06/2015 UPDATE[03/25]

    Thanks to Rex I have managed to use the CSVplugin with AJAX to upload a debug CSV with 10 people on it with their stats. I feel comfortable using the plug in to pull data and push updates back to that file. Problem is that it is stored with my website. And I still do not know how to make a system of user accounts who each have a copy's of master CSVsheets and be able to change them though their unique gameplay.

    I know I am on the right track with this but I must admit I am intimidated about MySQL. Currently I am using a simple note editor and bitballoon. I have on the top level all my web pages for my site with a sub folder for things like images and data, and another folder containing my latest version of my game. But where do I put all the users files? In a sub folder which each user having a folder of their own? I know that is wrong and way too big to work with hundreds of users.

    I am looking at firebase but I cant get files to upload (see below question). And I will not build it by hand when my whole goal is to automate it as much as I can.

    as always thank you all for your help.

  • Edit b: Solved! the JSON of a CSV should look like

    ,Skill01,Skill02
    Bob,AA,AB
    Ted,BA,BB
    Mike,CA,CB
    
    Needs to be
    
    {"table":{"Skill01":{"Bob":"AA","Ted":"BA","Mike":"CA"},"Skill02":{"Bob":"AB","Ted":"BB","Mike":"CB"}}}
    [/code:3mxalw8m]
    
    Edit a: I seem to be trying to put a JSON into Rex's CSV plugin which of course will not work. But I still have questions on how JSON should be formatted into C2
    
    JSON, after what seems like weeks of pondering and reading JSON's finally clicked and now I am able to wright them in theory. I however like many things seem to be running into a problem with syntax. I have a JSON file that I am loading into the CSVplugin Provided by Rex and I am running into issues with C2 reading the JSON. C2 wants a string containing the JSON but I have yet to figure on how it wants it.
    
    I have a JSON example of 
    CODE: SELECT ALL
    "Men":[
    {"Name":"Bob","Skill01":"AA",Skill02":"AB"},
    {Name":"Ted","Skill01":"BA",Skill02":"BB"},
    {Name":"Mike","Skill01":"CA",Skill02":"CB"},
    ]
    
    From my understanding this is a properly formatted JSON, but loading it raw into C2 gives me a number of errors mostly due to the double quotes ". After searching the forum and tutorials I am amazed that I can not find something that says simply "This is how a JSON should look when loading into C2". So either I needed to look for more than a hour or two. Or its such a simple thing that everyone knows it.
    ---
    Given my difficulty with loading it into firebase it has to be something wrong with my writing of the .json My thinking is that I should be able to have all my data in my website folder under their own subfolder. But they should be loading using the import button but alas it keeps saying my file is not validated
    ---
    Ignoring firebase for the time being I am simply trying to AJAX a JSON from the project folder then loading that string into the CSV table using the "Set from JSON" feature. I how ever keep getting javascript crashes once it loads because the JSON is not properly formatted for use in C2. So what should the above JSON look like if placed into any given C2 feature. 
    
    "{"Name0":"Key0","Name1":"Key1","Name2":"Key2"}"
    ?
    
    If i drop the " from the start and end it will not go though saying { is invalid. so confused
  • Working with Database along side C2

    I have migrated my site from Notepad++ to the more versatile WebMatrix3. Along with this comes with the feature that I am greatly needing and that is a database. I have made a table and have a good understanding on how to pars and edit it though my website. But getting it to work with C2 and in particular AJAX is giving me some trouble.

    Although it is a pain to export and upload to a 3rd party web hosting site like Bitbaloon I have been able to call a .txt file with a CSV in it and post back changes to my website with not too much difficulty. But I do not know how I can access this new table inside my website from within C2. I can seem to access the file using a MySQL query form with in the HTML page for the website but I do not see how I can do such a search in C2.

    And while on the topic of editing database tables can anyone tell me how I can make a user profile that when created makes a new entry of the table and creates a copy of the master tabel that they can then edit with their own unique player data? rexrainbow is there a way to use your firebase plugin without using the firebase site? If not do you have or know of a plugin that will allow C2 to make MySQL calls?

    I would like to just be able to use in C2

    AJAX get form URL> "../"&varusername&"mydata.txt" then load that JSON into my CSV?

    In this way each player when the make a account on my site in that first form they will choose a username and when registration is complete it makes a copy of my mastertable object and renames it to [playername]mastertable. I can then pass that into C2 AJAX calls.

    I am getting by right now just having AJAX call project files that have my CSV.txt files and am able to work on other parts of my game but I need to get this nailed down before I go too far into it as really this game is a website that happens to have a HTML5 game built in.

    Thanks for all the help.

    -CrazyVulcan

  • CrazyVulcan

    My firebase plugins only could work on firebase service.

    There are some services like parse which supports datebase-in-service.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • CrazyVulcan

    Use Yann 's JSON plugin to parse JSON string.

  • CrazyVulcan

    My firebase plugins only could work on firebase service.

    There are some services like parse which supports datebase-in-service.

    https://www.scirra.com/forum/plugin-parse-cloud-data_t115108

    So far this was the only plugin that looked like what I am wanting but the pricing is waaay out of my budget. And considering I can probably do much of that myself given time and a point in the right direction I need to look at other options

    Any one have any suggestions. I can do the coding myself if necessary and learning is not a issue. But I don't know exactly what I need to do first.

    Lets start with how do you call a database table in AJAX?

    -edit-

    Rex, thanks this seems to be something I can use. I will need a bit of time to learn it first but I dont see why it wont work. Downloading now

  • I posted this on Yanns page but mabe someone here can help,

    I seem to be having a issue with C2 working with JSON data. I am simply trying to load a JSON raw into your plugin

    {
    "Bob":{
         "Skill1":"AA",
         "Skill2":"BA",
         "Skill3":"CA"},
    "Ted":{
         "Skill1":"AB",
         "Skill2":"BB",
         "Skill3":"CB"},
    "Mike":{
         "Skill1":"AC",
         "Skill2":"BC",
         "Skill3":"CC"}
     }
    [/code:pz4qdmxu]
    
    What is wrong with this syntax? The first "{" has a red line under it so there has to be something wrong with how I am wighting this JSON. Your plugin seems to be just exactly what I need but I have no clue as to why my code is getting this error.
    
    I'm sure its something that I am doing stupid
    
    I can get it to work by changing it to
    
    [code:pz4qdmxu]
    "{
    ""Bob"":{
         ""Skill1"":""AA"",
         ""Skill2"":""BA"",
         ""Skill3"":""CA""},
    ""Ted"":{
         ""Skill1"":""AB"",
         ""Skill2"":""BB"",
         ""Skill3"":""CB""},
    ""Mike"":{
         ""Skill1"":""AC"",
         ""Skill2":""BC"",
         ""Skill3"":""CC""}
     }"
    [/code:pz4qdmxu]
    
    But then its not a JSON and having too many " means just that much more likely that I will miss one and screw the whole thing.
  • If you are putting the JSON into the C2 event sheet directly it has to be a string enclosed in quotation marks and so you have to escape any quotation marks inside the string with an extra pair. That's fine. If you load the JSON from a file, you don't need the extra quotation marks.

  • If you are putting the JSON into the C2 event sheet directly it has to be a string enclosed in quotation marks and so you have to escape any quotation marks inside the string with an extra pair. That's fine. If you load the JSON from a file, you don't need the extra quotation marks.

    Thanks ramones, AJAX is still something I am trying to get a handle on. I have the next two days off so I intend to get this nailed down by Thursday. Is their a particular way C2 wants to JSON formatted when it is brought in through AJAX? I have tried putting in a file in my projects folder and using Yann's plugin just use that to load the JSON. It however gives me errors when I try it. I will try to post a capax of what I am saying. That should help.

    I have tried pulling the file as both a .txt and .json with little success though in my browser preview debug I did see where AJAX managed to load the text. But getting that text to work with that plugin has been a we bit of a headache.

    Do I just have a .txt file with {"ThingOne":{"A":"1","B":"2"},"ThingTwo":{"Y":"1","Z":"1"}} ?

    I promise once this clicks I will wright a nice in depth tutorial about handling JSON as I can find little on it. This either means its not a common thing or its so simple that most assume that everyone knows it.

    !-- Edit

    Yey ok so I managed to get the AJAX to load into the JSON Plugin. Don't know what was not going right. Maybe just needed to look at it with tired eyes after a long shift, usually when I do my best work anyway.

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)