CrazyVulcan's Forum Posts

  • OK I have a interesting issue as I dont seem to understand how pathing works. After much effort I have finally managed to get WebMatrix and Google Chrome to run locally and now don't need to upload to a external server every time I wish to run my game. Now there are just two things left for me to understand and then I feel I can move on.

    First, I have managed to use AJAX and get it to load a JSON from my project file just fine and now need the next step. I need to be able to pull this JSON from a folder that contains the website, C2 Game, and the database. Currently my folder hierarchies looks something like this

    [My Game]     [Images]
         index.html
    [UserData]
         MyData.json
    index.html
    gamewindow.html
    mainCSS.css
    gamewindow.html
    [/code:3t27umc3]
    
    So naturally my site launches index.html and there is a link that takes you to gamewindow.html that has a iframe embedded to play index.html form within the folder [My Game]. Right now my game plays just fine but I cant seem to figure how AJAX finds the MyData.json in the folder.
    
    I have tried
    "http://localhost:50000/Debug.json" As well as "http://localhost:50000/Desktop/MyGame/UserData/Debug.json"
    "http://localhost:55707/Debug.json" (which is the port number showing up when I look at my website in WebMatrix. My thinking is that since the game index.html is in a sub folder and I need to get at a different folder I have tried "http://localhost:50000/../UserData/Debug.json" So what is it that I am missing? Where dose the file path start. I have looked over the tutorial [url]https://www.scirra.com/tutorials/393/ajax-in-local-preview-on-localhost50000[/url]
    
    His example simply says "http://localhost:8080/scirraTest/myGame/xml/dataIWantToGet.xml" But where would "scirraTest" reside? The Desktop? the C:drive?
  • CrazyVulcan

    That's because C2 expects a string, a string in C2 is some characters (or none) surrounded by double quotes (")

    Problem is, what happens if you want you string to contains double quotes?

    Answer: you need to escape them.

    How to escape them?

    some languages use \" C2 use double double quote ""

    As a small remark, C2 isn't THAT weird in this area, you also do that if you want to escape double quotes in verbatim string literals in C#

    http://stackoverflow.com/questions/1928909/can-i-escape-a-double-quote-in-a-verbatim-string-literal

    Now, one way to avoid this messy escaping is to put your pretty json inside a file you import in the project, and you get retreive it using Ajax.

    Thanks Yann, sure enough using AJAX did the trick. Quick question how big a JSON file can your plugin handle out of curiosity? Im sure I will find out but in my game each player has the ability to unlock various things as well as saving user created items that they can use later. I would love to just put all of it in one JSON using various tables if posable. Dose that seem doable?

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

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

    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:179ffpjs]
    
    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:179ffpjs]
    "{
    ""Bob"":{
         ""Skill1"":""AA"",
         ""Skill2"":""BA"",
         ""Skill3"":""CA""},
    ""Ted"":{
         ""Skill1"":""AB"",
         ""Skill2"":""BB"",
         ""Skill3"":""CB""},
    ""Mike"":{
         ""Skill1"":""AC"",
         ""Skill2":""BC"",
         ""Skill3"":""CC""}
     }"
    [/code:179ffpjs]
    
    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.
  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • I am doing some world building and have come to a interesting problem that I am sure everyone who has tried to make a complex world has encountered. I am noodling out races for my game that takes place in space. And keep coming time and time again to old cliches form greedy corporations and militaristic empires. To machines and genetic experiments gon awry with pirates and other rebel riff raft.

    So what do you think are the most over used archetypes in SciFi and Fantasy? Or what is your idea that gives these a new spin?

  • To add to above. To get actions to happen when you do your dice role you will want to make a function.

    When action calls for the dice to be thrown do function "dice roll"

    Then in another event you will have On function "roll dice" set a var to int(random(1-111) then in sub events you will want the use the compare value event. in the first one you will want to compare var dice roll = range(1-49) then do action 1. the same for the other sub events but make sure they are on the same level as the first one

    Function

    event

    event

    event

    not

    Function

    event

    event

  • I have done this in my game for zooming in and out of the layout. You really don't need image points at all. Have your map sprite as a background and set the layout scale to zoom in and out.

    I simply had if mouse real gos up change layout scale to ' current layout scale +1 ' and added a compair conditions saying the scale had to be larger than a number. Same with zooming out only reversed. doing this will zoom into the center of the screen.

    The grab and scroll is a little more tricky but just say if mouse btn is down then set the scrollx and scrolly to mousex and mousey

    I think that will work. My scrolling was done by moving the cursor to the edge of the screen but the above method should work.

    <><><><><><><><>

    here is a quick demo. Its rough but it is just to give you some ideas

    https://www.dropbox.com/s/d2spgthpiw84nsq/ZoomDemo.capx?dl=0

  • As far as placing var in text strings is rather straight forward but will require a bit of labor.

    var "Apple_Red" = 10

    Start of Layout > Set text for Textbox to "Have you collected all the apples?"

    If Yes_btn is clicked

    "Apple_Red" >= 8

    set Textbox to "Great now I can make that pie"

    "Apple_Red" < 8 then

    set Textbox to "Oops, You need to collect "& 8-"Apple_Red" & "Red Apples. Please look for them"

    So it can be done but you need to edit the string to have the variable in it instead of a string. '&' is what you use to bind two things together so all you need is to have "The text string" & variable & "last text string."

  • Tottaly feasible! Using tile maps will be ideal and also know that you dont have to even have all the map loaded at once. you dont even really need instanced layouts that you jump back and forth. you could just be able to establish chunks in a manner similar to minecraft. In a 2d game draw distance is not really a issue that the player would notice given that they cant see the landscape popping into existence as they near.

    I would not know but likely you could just have a array with all the tiles planed out and tell the game to render them when you get within a x distance from the edge. Actually you then would not need a large layout as your player could remain within the center area and every 300 tiles just pop him back to the center with all the tiles moving with him. A "If Mohammad wont go to the mountain, the mountain will go to him" kind of thing. But I dont know what kind of load that would lay on the game. Id say go with it, it looks worth investigating and you can then let us know how that turns out.

  • Why even bother with gamification? Just provide the data, and create a system to allow a player to fake-trade.

    They can then track the money they didn't make... or loose.

    Well I laughed at the idea of "Fantasy Football" when I first heard of it. And now it is growing into a multi million sub genera of online gambling. I will watch this but I don't think id be ready to jump in bed with them just yet.

  • 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
  • Hi. What you can do is that when the ball contacts with the object in the wall, the system creates a new instance of the ball and then sets the direction in a random number between 0 and 180 (if you set it that appears in the upper centre).

    You dont even need a new instance. Just set the ball to stop, move to the center, turn in the new direction, and then start moving again.

    If I were making a pong clone my solution to do it in as few events as possable would be to simply use the math expressions

    A = Current angle the ball is moving Ball.angle

    B = random(-60,60) <-this is absolute and not depended on the balls current angle ie 0deg is pointing right. depending on the min/max angel you want your ball to move

    When the game starts or the Ball hits a paddle simply enter the new angle of movement as

    (90+(90(Ball.angle-(Ball.angle+1))+random(-60,60)

    there are four quadrants that a angel falls into, this equation will tell the ball to turn ether true left or right 0deg vs 180deg depending on which direction it was moving to begin with. Then pick a new angel between what range you wish the ball to move.

    For hitting the wall just make change it to Ball.angle(Ball.angel-(Ball.angel+1)) which will bounce the ball in the same angle but reversed in positive or negative. A ball hitting the bottom wall at -30deg will then move at +30deg

    There is probably a less mathy way tough events but I love my one step events.

    And for starting a new round just have a boolen var for "YouScore"=True. If the ball scores a point for you leave it true and if true start the ball moveing to the right. And if the Ai scores turn it False and move it left. +/- any random angle, just instead of the expreshion Ball.angle just use 180 to move it to you or 0 to move it to the Ai. In just 3 or 4 events

    Vulcan

    #TrigLife

    ps you need two events for when the ball hits a wall and for when it hits a paddle