scidave's Forum Posts

  • I don't know exactly what the problem is based on your screenshot and description, but in general you shouldn't use the layer number you should use the layer name. I've run into bugs in the past when using the number.

    It might help if you posted a .cap.

  • Thanks Rojo! That worked. Now I'm trying to do it just by the index to improve performance.

    Looks like I might just be able to do a:

    players[data['player'] - 1].SetPosition(data['playerx'],data['playery'])

    Thanks for the help! It's great having more Python guys around here.

  • I am working on making the 2 player net pong game be four player but don't want to have to do it the tedious way of duplicating code for each player (in this case it is not really tedious, but wouldn't be practical for a 20+ person game which is the point of the exercise):

    Here is Python function that updates the player position only if the player number is not yourself.

    def Network_move(self, data):
          if ((data['player'] == 1) and (System.globalvar("myPlayer") != 1)):
             player1.SetPosition(data['playerx'],data['playery'])   
          elif ((data['player'] == 2) and (System.globalvar("myPlayer") != 2)):
             player2.SetPosition(data['playerx'],data['playery'])[/code:34szvw2l]
    
    For example, to make the above support 4 players I would have to double the code. Instead I would like to do something like (with all players in a Family) :
    
    [code:34szvw2l]
    if data['player'] != System.globalvar("myPlayer") :
       Pick players by players PV == data['player']
       players.SetPosition(data['playerx'],data['playery']) [/code:34szvw2l]  
    
    So something like the above where you pick a player based on their Private Variable (or something else) being the correct match.  Now the above three or so lines are sufficient to handle 2, 4, 50 players.
    
    Any ideas?
    Thanks!
  • ONLINE GAMES: As it happens, I'm currently working on a plugin for this

    btw.. this is really awesome Dataflashbot. Any status on how it's coming along? What networking library did you decide to go with? This will be a huge plus when it comes out!!!

  • I uploaded a new version which improves collisions and increases ball max speed (felt a little slow last time I tested). Working on 4 player version now.

  • I really liked Guyon's idea about the paddles so I implemented the game using mouse control, only for 2 players at the moment.

    <img src="http://i40.tinypic.com/2vsgndy.jpg">

    You can get the server and client here:

    http://www.box.net/shared/5703uihspa

    Some quirks:

    1. You can swing the paddle really fast and go through the ball. For simplicity sake I have not addressed this. For now, you have to resist the temptation to swing at the ball. then please let me know and I'll incorporate it.

    2. Over internet. My guess is there will be lots of lag with players moving their mouse so quick. I plan on releasing the tutorial then looking at another library (plus interpolation/prediction) to handle online lag.

  • What exactly do persist files do?

    If all they do is keep track of what is open and what is closed then I would MUCH rather not have them at all.

  • In danger of completely becoming the 'Python Guy' I should point out that you can use a gamepad in Construct using Python and Pygame:

    http://www.pygame.org/docs/ref/joystick.html

    At some point in the future after doing the network stuff, I'll show an example with Pygame and joystick/gamepad control.

    Although, it would be nicer to have an actual plugin for generic gamepads.

  • Can you not just copy and paste it from one layout to the next?

  • Yeah, that would be a good joke.

  • That looks awesome. I'd pay for this game.. seriously. Hands down the best Construct game yet.

  • Thanks Sagal for the info. I did some network testing and I'm getting the following info for latency:

    - Lan: .4 ms

    - google: 25ms

    - scirra: 46ms

    I'm on a cable connection as well. Since the ball location only updates once a game loop my guess is everything is fine in the LAN case since it is well under the 10 ms event loop time. However, the internet latency is at best 2-4x over over so it might cause some lag for the ball. Also, I have the ball going pretty fast and I might want to slow it down some as well.

    I have a couple of ideas on how to minimize internet lag it so hopefully I'll get a new version out that fixes this.

  • Thanks everybody for the feedback.

    though the game itself was a bit boring as ball didn't have any randominess (yes im fully aware that this is more like a technology demo)

    You mean you don't like aimlessly bouncing a ball endlessly back and forth??! You can affect the direction of the ball by moving your paddle quickly up or down as it contacts the ball. Yeah, I never really meant it to be all that exciting, but maybe I'll jazz it up a bit with randomness or with what Guyon suggested which would be kinda cool. I like the idea of using the mouse for control.

    though connection was laggy (might been my fault but can't be sure or PR's or the program itself)

    Were you playing over the internet or on a Lan? Do you both have high-speed connections or dialup? I didn't notice any lag on the Lan when I tested it, but I could see it having potential lag over internet. It would be good to know if there were issues with this library, because I can always go with another one if the performance is not good enough.

    I'm hoping a new version of Construct will come out with a bunch of Python fixes (editor and private variable access) before I start on the tut. I also want to wait just in case another library might be better.

  • Thanks for the example! I figured there would be syntax issues since the way Construct specifies Behaviors would clash with Python syntax, so this is a pretty good work around.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is another simple network program with Construct and Python. This time it is a 2 player online/lan Pong game. After struggling with how to implement it and running into a few bugs I finally came up with a real simple solution. I'm using the PodSixNet Python Library which handles and hides all of the complex logic behind the scenes.

    Pong isn't all that exciting, but it is online!!

    Run it the same way as the chat program. In a later variation I might add exception handling but for now pick a high port for the server like 5000. See the discussion in the chat program thread about ports. The controls for each player are Up/Down arrow keys.

    Get it here (need Construct .99.84):

    http://www.box.net/shared/rvyryttyzx

    This version uses the mouse for Control instead (need .99.84 as well):

    http://www.box.net/shared/5703uihspa

    This is the latest version which supports 2 or 4 players (need .99.84 as well):

    http://www.box.net/shared/spoafestsh

    <img src="http://i42.tinypic.com/657hbc.jpg">

    Next, I'll work on a N-player or 4-8 player networked game. Once, I finish that then I think I'll be ready to write the tut. I'll walk through the PodSixNet library and how to integrate it with Construct to make online multiplayer games.