aceofpack's Forum Posts

  • erhaps I need to clarify this. What happens is that my server code uses NowJS callbacks that are implemented in the C2 runtime. There's no code from the runtime that runs on the server.

    Ah yes sorry. This is all bespoke. I see now how this works after delving deeper. I was looking at c2runtime.js to see if there could be a way to lift code from it for the server but there are some serious arrays within arrays in there! Not sure how it's structured.

  • Whilst UDP is all well and good. ..Is there perhaps some confusion between that and well designed architecture.

    I believe good multi-player gaming can be achieved with TCP.

    First off all, we need a optimised methods of transit and a means - socket.io. Many guys here have already demo'd the use of this.

    We should, in theory (and with some mods), be able to use c2runtime.js on both server and client side with some 'middleware' that deals with Client Side Prediction and Entity Interpolation.

    gabrielgambetta.com

    buildnewgames.com/real-time-multiplayer

    What's interesting about the above article is the structure of the game:

    client.js - The logic for the game client setup in the browser.

    app.js - The server side app to run on node. This handles all the node/express/socket.io set up and code.

    game.server.js - The logic for the game server (?lobby?).

    game.core.js - The logic for the game play itself, both server and client.

    Until I've created for myself and failed or seen a game output here with these methodologies, I can't believe it can't be done (double negative ;))

  • Sorry, if they need to be 4 different sprites then that wont work. When you say controller? Is this 4 people with control pads on the same computer or over a network?

  • You can spawn 4 instances of the same Object (player sprite) which have instance variable: playerNumber which you make sure is distinct for each player.

    You can then assign control to the instance of an Object that has playerNumber x.

  • Velojet

    No worries, I'm going to explore your code and aim to help you achieve this goal.

    There's good and bad news around this:

    For the non-technical - server software such has node.js has allowed developers to use the same code client and server side. This means that a method of generating code to be inserted server side can be dreamt of. This is what velojet is actually doing here. He's used code from the runtime that he could run on the server.

    However, you need a server for multiplayer.

    Latency and lag needs to be managed effectively with a few methods:

    • The design of your data for the game
    • The amount of players you want on any screen at one time
    • Optimisation to be sent via binary means (this is your data broken down into its component parts with no 'bloat' added)

    Your game needs to design against cheats:

    • Only send a 'request to perform an action' to the server
    • Client makes the move to avoid lag whilst waits for server
    • Server works out where it expects the player should be/what status they are at etc when the message is receivied
    • Client checks if the move is inline with the server when the response comes through and corrects it to the expectation if wildly different

    This is prediction correction. en.wikipedia.org/wiki/Client-side_prediction

    So, there's a few things here that make multi-player not so simple as a plugin. You need to be able to design your game in a way to be optimised for multi-player.

    Cheaters especially need to be quelled if you want to do in-app purchasing developers.google.com/commerce/wallet/digital

    I'm working on all this and like velojet, it's important to get an example working with the steps you take to even think about what elements are needed to give a true multiplayer plugin.

  • Huge thanks for this.

    I've been doing some research into this too in the hope to build a fast multiplayer game...partially using construct 2.

    This article is excellent: buildnewgames.com/optimizing-websockets-bandwidth

    It discusses using binary to send game data which I think is a big consideration in improving the plugins created.

    You also need a way to port code to a server side environment so construct 2 would need a way to export in that way to avoid cheating.

    I look forward to seeing what comes of it in the near future :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here you go:

    dropbox.com/s/zvfs608yj6uizoo/circleSpawn.capx

    I've put -200 in the formulas to get the spawn point on screen. Of course you can manipulate this to do any circular spawning around a point. This is just one application of it.

  • Ok I found the answer. Posting in case useful for anyone:

    The 'should of been obvious' answer was that I was using a random(360) for both x and y which of course would have been different!

    So, here's the process:

    1. Create a global variable 'randomAngle'

    2. On the event of creating an object, set randomAngle to random(360)

    3. Set X value of object to:

    (sin(randomAngle)*((sqrt((windowWidth*windowWidth)+(windowHeight*windowHeight))/2)+100))+(windowWidth/2)

    4. Set Y value of object to:

    (cos(randomAngle)*((sqrt((windowWidth*windowWidth)+(windowHeight*windowHeight))/2)+100))+(windowHeight/2)

    The +100 in the equations provides some extra clearance off screen, can be whatever you want.

    If you created a 1000 objects and tested this it should draw a circle of them around the central point of your screen.

    • The equation uses Pythagoras equation (h? = x? + y?) to get the distance from top-left corner to bottom-right corner of the screen.
    • Then halves it (/2) to get central point to corner of the screen.
    • sin(angle) x hypot = opposite side (x) for X (s& = o/h)
    • cos(angle) x hypot = adjacent side (y) for Y (c& = a/h)

    The X & Y values at this point would be offset around the 0,0 coordinate so now it's a case of adding half the width and height to offset around the center of the screen.

    Of course, you might be able to store much of these calculations at app start to reduce computations.

    Hope that helps anyone having a similar issue :)

  • Hello all,

    This is my first post so nice to meet you <img src="smileys/smiley1.gif" border="0" align="middle" />

    I'm looking to spawn objects in a circle x distance away from the central point of the screen (x:windowWidth/2, y:windowHeight/2).

    The angle being random(360).

    I had this working in normal javascript like this:

    enemy.x = (Math.sin(randomAngle * TO_RADIANS) * clearance) + (canvas.width/2) - (enemy.width/2);

    enemy.y = (Math.cos(randomAngle * TO_RADIANS) * clearance) + (canvas.height/2) - (enemy.height/2);

    Where clearance was the length of the centre point to the corner + some extra pixels to make sure they spawn off screen.

    I just can't seem to replicate this in Construct 2 when adding this to Create Object event:

    X: sin(random(360))*((sqrt((windowWidth*windowWidth)+(windowHeight*windowHeight))/2)+100)+(windowWidth/2)

    Y:cos(random(360))*((sqrt((windowWidth*windowWidth)+(windowHeight*windowHeight))/2)+100)+(windowHeight/2)

    Could anyone help me out with this? I noticed the asteroid tutorial just spawns random width and then choose() between a few offscreen Y values.

    Thanks