farflamex's Recent Forum Activity

  • I know this should be fairly basic so I must be doing something wrong.

    I'm sending a json_encoded string from my php file to C2. The string shows [4,3,1,3,1,2,1,1,0,3] when C2 receives it (when set in a text object). It's just 10 numbers in PHP.

    I then try to load it into my C2 array with Array -> Load from JSON string (String).

    The array is still empty, so I'm doing something wrong. Any ideas?

  • I'm fairly sure in my case it was because I was trying to use them in the same event after creating them from a function. Although they still wouldn't work in sub-events. But when I set up the same structure in a few project, it did work, so something must've been wrong with my code somewhere.

  • In C2 it's very easy to go through your objects, which is probably my favourite thing about C2. Once you've created your object it lasts for the length of your project, unless you destroy it, and to select certain objects it's very easy to 'pick' the ones you want. It's not so straightforward in other languages, including PHP, but it's not really that hard either. It just feels like a step back to old-fashioned languages.

    So for example, if you had 20 objects and you want to select any object which has a certain value, let's say variable A = 1. You just 'pick' them with 'Object A = 1', then anything you do after that only works on those objects. In PHP, you'd need an array of objects and then you need to loop through them, checking each one with 'If A = 1 then'.... it's not really much harder, it just feels a bit more fiddly. There may be a simpler way too but I don't know of one yet.

    I was definitely tempted to send all of my database information to C2, do all the processing in C2, then send it back to PHP to save to the database. But it's an extra step when I could just do the whole thing in PHP. Also, I can automate my PHP program to run my game every hour or so (it's turn based).

  • I've also worked out my problem too

    I'm used to C2, where I create an object and it just remains in memory as an object forever. I think PHP works like other languages, where the object will be garbage-collected unless you still have at least one reference to it. So in my case, I'm creating an array of objects and then looping through the array to find what I need. It's not as easy as C2 or BASIC but it's useful to learn anyway. I might make most of my game in PHP and just the front-end in C2.

  • If it's your first game, I wouldn't worry about logging in and stuff yet. If you're looking to make a quiz game, start with getting the quiz screen done first. Is that what you're aiming at?

  • My game is turn-based, so PHP should be adequate for processing the logic of the game. One huge advantage also is that I can auto-run my PHP logic file as a Cron-Job which will be one less thing for me to do. If I made a sort of control panel, similar to how my game runs right now, I have to log in at the right time and set it running.

    The advantages of C2 are that I know the language very well and find it easier to manipulate objects. But I'm sure I can get the hang of it in PHP. Luckily, I'm in no rush, so what I think I'll do is, keep plodding away and see where it leads me.

    I have worked out that if I fetch my data with FETCH_CLASS, it puts it directly into a class, and then I keep an array of those objects and work my way through those. It's not quite as easy as C2 and reminds me of the 'good old days', looping through arrays etc, but it's fairly simple. I am a bit confused that my player object doesn't have certain values but it just adds them from the database anyway. E.G My players in the database have about 10 ratings, but in my class, I only added about 3 of them for testing. When I fetch the data with FETCH_CLASS, it creates the object from my class, fills the properties I've created and then just creates the others too. Making me think that I could actually just skip the properties and allow it to fill automatically anyway.

    Anyway, learning and enjoying myself as I go, it's fun

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Which part isn't working? How are you retrieving the C2 post, are you using isset? I always post my data in the 'data' part of the AJAX box, and then retrieve it in PHP with something like $data = file_get_contents("php://input"); which will put the C2 'data' box in a variable called '$data'. Then I split it to retrieve what I need.

    As I said, I'm new to this, spent the entire day trying to work out how I manipulate my loaded objects in PHP (I can retrieve them from my database and put them into objects, but I can't work out how to select different objects in PHP).

  • Wrote out a long description but it just makes it more confusing. I'll try to do a short and clear answer.

    Say you have 20 objects, and you 'pick' 10 of them due to some condition, e.g Pick all objects who's X coord < 100. The events only run once per frame, and anything that applies to this type of object will apply to ALL PICKED objects, ONCE. So for example, say you wanted to change their X coord to 200. You just need to say 'Set X to 200' and it would apply to all of the 10 objects you just picked. No for-each needed.

    When you DO need a for-each is if, for some reason, you want to run the events once for each picked object. So in our example above, we have 10 picked objects, and you want to run the events 10 times, for example, you want to create a text object for each picked object. You can't just put 'Create text object' in your events as that would just create one object (the event only runs once usually). So you do a for-each, run it 10 times, create a text object inside the loop and you're now working with an individual object on each loop pass.

    There are probably better and simpler explanations but hopefully it helps a bit.

  • I'm just learning this stuff myself, so yes, you need to create PHP scripts to deal with your data as you post it to and from your server. I can't help at all with Node-Webkit though as I've never used it, but I am just learning PHP myself and it's a very easy language, just different syntax and flow. A few days of tutorials is all you need for this basic stuff, though I'm thinking of having my entire game processed on my server, so might even develop the whole thing in PHP (it's a turn-based game) and just use C2 for the player front-end.

  • In terms of the product being too big for the team, perhaps that's true, but it's a very complete tool in my opinion. It's quite possible to make huge/complex games with it, but there are some minor issues... then again, there are issues with any coding tool right? I assume your initial question was whether or not anyone has completed any serious projects, to which the answer is yes, though it's true that most C2 games tend to be small and simple, because it's just so easy to make small games (with any tool) and it tends to attract newer programmers for obvious reasons.

  • Certainly possible. To log on and store their data, you'll need a database, so probably need to do some PHP/AJAX stuff. All fairly easy and there are some tutorials for that. The quiz part shouldn't be difficult. But you'll have to let us know where you're up to, so what you need help with specifically.

  • Have you tried the 'rotate toward angle' expression? So it will rotate TOWARDS the angle, not just jerk straight to it.

farflamex's avatar

farflamex

Member since 7 Oct, 2012

Twitter
farflamex has 15 followers

Trophy Case

  • 12-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies