rogerfgay's Forum Posts

  • I've set up another server and am modifying the responses. If I'm not mistaken, the JSON command is in the form Keyboard.OnKeyPressed.Right or something like that.

  • Your games hang when waiting for a tcp response? That sounds like the days before browsers supported AJAX?

    RTC is for media files.

    UDP has packets up to 64K for IPv4 and greater for IPv6, which is way more than needed for most command transfers. So ... I won't be waiting for anything more than a packet, a single packet, which if lost is gone. You don't want that. it means the other players' moves are not recognized.

    I don't think TCP is the problem.

  • this sounds juicy...

    :) .... Seems to be getting there.

    step by agonizing step (lol)

  • Maybe this is why I was getting the infinite loop. The first version used dictionary definitions. Merely defining right, left, up, and down = 0 was enough to create the loop. That could show it's on the right track, but I need to be able to stop the loop. It could be stopped by the server if there is more than on sprite (or player). The server could match sprite with sender and not pass information back if they don't match. But that's less efficient than dealing with it on the browser end, because it would produce a lot of unnecessary sends.

  • thanks for responding newt;

    Keeping in mind that I don't use JSON (normally, but will this time and happy to learn if this is what's needed) and am new to Construct 2.

    I'm clicking Add action next to On start of Layout and selecting dictionary, and then .... ???    JSON Load??? enter string above?

    Then what I need to receive is; for example ??

    {"c2dictionary":true,"data":{"right"}} ????

    Or is there some way for me to enter my own logic to do that concatanation ....

    Or does it just know because "right" is now defined in the dictionary?

  • One small step for mankind: Added Sprite rotate 45 degrees to Websocket onmessage. That works. So, I am sending and receiving from the server and getting a response on receiving. Need to know I can control specifics better than this of course. :)

  • Well if the return string was already formatted to "{"c2dictionary":true,"data":{}}" then when you received the message you could just load it into the dictionary object, and compare known keys, or do a for each key.

    I would assume there shouldn't be many issues reloading the dictionary that way.

    Newt:

    Could you give a more complete example of the JSON string? I think the only condition is that the string doesn't simulate clicking an arrow key. Since I use arrow keys (keyboard) to trigger sending the message to the server, seems like that would put it in an infinite loop.

    If there's a manual section that gets into this detail, that would be great. But for starters, I could use any response except right, left, up, down arrow keys.

  • Time to switch over to what the input from the server should look like.

  • Perfect.

  • OK, Keyboard installed. It's easy once you know how. Now I just have to figure out how to use it.

  • 8Direction is moving isn't specific. Seems like if I could get keyboard installed, it work ... could specify right, left, etc. with that and it might fire only once per trigger.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think I'm making progress. I deleted all the dictionary definitions from On Start of Layout and all the Simulate 8 Direction from dictionary key actions. I added Sprite 8Direction is moving event with a websocket text message action. Now the sprite action works and I get the text message at the server each time I move the sprite. I actually get the text message 7 times, each time I click an arrow; but it actually looks like one click of an arrow might respond with several movements in the same direction.

    I've seen the instructions for drop-n-drag adding addons, but don't know where to find the mouse, keyboard, etc. to add them. I found them under templates, but those are not .c2.... files.

  • Why don't I have keyboard events? Wouldn't that be the most straight-forward way to do this?

  • I stopped the loop by setting key event values to 1 (leaving the initial dictionary settings at 0). I just imagined this representing 0 for false and 1 for true. Then the sprite works properly. But not only did the message to server loop stop, but now no messages are received at all; indicating that it's no longer executing the websocket text message sends that I added.

    I keep scrolling through the beginners tutorial and documentation in an effort to get a hint. But beyond generalities ... like add events and actions, then set values for parameters, they don't seem to get into much detail.

  • OK, the fog has started to clear a bit perhaps. I added a websocket action to each of the key events; sending a simple text message "right" "left" "up" and "down" to the server. Problem is, that there is a loop. When I start running it, it connects to the server and then sends text messages "right" "left" "up" and "down" over and over ad infinitum, even though I haven't pressed any of the keys.

    So far, I'm just doing this with my demo server app ... which is nothing more than a simple echo server. So, the server does send back "right" "left" "up" and "down" in response to receiving those ... it just echos back what it receives. There is an exception. At first, I separately send back some text commenting on the WebSocket server, but I don't think there's any way for the app to respond to any of that ... it would just be uninterpretable text input to the app.

    There may be no way for me to do this without studying the documentation and really understanding it all better.