• Content Count

  • Joined

  • Last visited

About Ralph

  • Rank
    Advanced Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Not really a bump, but since I'm curios on others thoughts still go ahead and shoot a reply if you have some input. Either way though, I've kind of already moved forward with moving everything into the loop. Some events remain but they're there now mostly for readability and simply set a flag that tells the loop to handle the event on the next tick. Just a word of advice to if anyone sees this in the future, save yourself the trouble of even attempting an event-driven game (unless your game really caters to event based logic). It will work and work great at small scales but it simply isn't practical or worth the effort for anything other than a proof of concept.
  2. Hey all, I'm currently in the process of re-writing my authoritative server from one that was completely event driven to one that relies heavily on a game loop and I had some questions I'm sure some people can answer. To give some insight for my question, the way the old event-based system worked was basically the client would do something, then send tell the server what it was trying to do. The server would then check if this was legal if it was, do nothing but tell other players what that client did, if not legal, would set the client back to its previous state. For example, movement was handled by the client telling the server where it was a few times a second. The server would make sure it's getting consistent updates from the client and calculate if its velocity and other parts of its movement was legal, if so the server would accept that update and store it and push it to other clients. Similarly, shooting was handled in the same way. (Bullets do not travel btw, shooting would essentially just spawn a point of damage wherever you clicked) Client would tell the server where it wants to shoot, server would give it the okay or not then push that info to everyone else and calculate damage if it hit someone etc. Now, I'm switching to a game loop so that my entities can have a more robust "ai" behind them. While in the process of this I've moved a lot of the server logic (like movement) to the loop and it seems to be much more functional (and authoritative) to do it this way. I always knew the loop made more sense, I just didn't want to hassle myself with it yet. Now the main question I have is should I be handling things like shooting in the game loop too, or is it okay to keep them event driven. Do I lose anything by having half the game event driven and the other half of the game ran in the loop? Since bullets aren't a traveling entity and is just damage at a point and all the server needs to do is calculate if you can shoot there, and if there is a player there, then damage them. Should I move this logic into the loop for cleanness/speed/efficiency? Same thing with other things like opening an inventory screen. When you open your inventory on the client, the client requests the server for its items, the server just immediately sends the client the info it needs (while doing some other logic obv). Should I move this to the loop and set like a flag that says on the next loop serve this client their inventory? Or does it really not matter at all and whatever makes sense to me? Let me know if I need to elaborate some more, I'm sometimes not too clear hahaha. Thanks!
  3. So to preface this, I've already looked through the docs for something that could do what I want but I couldn't find anything too useful. So I'm trying to make a sprite grow cracks over time (think like in minecraft when you mine), except I don't want to have to create a spritesheet of no cracks to cracks and have to loop it for every sprite texture. I'm looking for someway to play a standard opaque animation over each item I want cracks to form on. Is there anyway to do this? The only method I could think of would be to at the time I want the cracks to appear, to spawn a sprite right on top of the current sprite that is just a opaque cracking animation. This would work, but creates the challenge of having to deal with these opaque cracked-animation sprites now, especially in a multiplayer settings when I'm trying to run as efficiently as possible. If it comes to it I'll use this system and figure out a way to handle them but would rather have something that I can tie to the sprite that self destroys like an animation of its texture would. Let me know if I need to be clear, kind of rushed this. Thank you!
  4. So this is basically what I have right now. The server is essentially fully handling the movement, but the client just assumes all moves are legal to remove the need for the server to send back to the client what it needs to do.
  5. The reason I went with a monitoring approach over a fully server handled movement system is that i could never drop the lag. The movement lag from the server handling movement was too annoying for me, and I couldn't reduce it by much. The server does monitor by update, not by FPS, but currently the client doesn't move by update, it moves by frames, if that makes sense? So the server is calculating distance based on updates, but the clients move based on frames. An easy fix I just haven't gotten around to (I just need to make speed the client moves at proportional with their FPS). To be honest, after I wrote this post, I found the real issue that was causing this movement bug, it was unrelated, but this is still something I know I will have to deal with in the future. So your recommendation is to fully switch to a server sided movement system?
  6. Sup guys, I'm back and once again working on my side project now that school is out. I recently rewrote some of my server sided code, specifically the pieces that handle anti-cheat. One problem I ran into is my anti speed hack mechanism. Prior to my rewrite (which was more of a cleanup) the way I handled movement on the server was I allowed the client to move however it liked. It would then send its new position (after ever frame) to the server. The server would then check to see how far the client moved (based on its last position which is saved on the server) and made sure that the client didn't move more than a certain amount of pixels each frame. If it moved legally, then it's "last" position would be updated with the new position the client provided and the client legitimately moved. If it moved too fast, the clients old position is kept as its server position, ensuring that sure the client isn't speed hacking (at least on the server side, can't stop the client from moving anywhere really). Anyway, that's how the system works, and it works great, until I ran into the problem of different frame rates (at least I think that's what's causing the issue). After the rewrite of this system, clients are moving too fast to the server, and I think it could be because of slower fps'? Like Ill move right, but now instead of moving say 5 pixels per frame like the pre-rewrite code would detect, im getting 6, and 8 and 15 and other higher random numbers, as if the server was missing some calls. Regardless of the cause, I was wondering, how do people usually handle movement on servers. Am I going about this correctly? Any suggestions? What other ways can I verify a player isn't teleportating or speed hacking? Thanks.
  7. Yeah, a few days after I posted this I fixed the issue by changing all sprites body shape. By shifting the Z offset of each sprite to negative sprite's Z value plus 1, everything was 1 unit off of the "floor" and collided properly then. The issue arises because if you set the z value of a sprite to be 0, it doesnt actually change the height, it just pushes it through the floor it seems. I ran across another issue with anchors, which i also fixed, but that required a source change that I documented on the open issues of the plugin. Overall great plugin, even with the dying support, no worries though, all projects must come to an end sometime.
  8. I would recommend you change the player "object" to a single variable, and set children. That way you can modify it all as 1 object in relation to each other. Rather than 3/4 separate sprites. Also, io.socket.broadcast is a tool you can use, (I think that's the syntax, idk look it up), so you can send a socket message to all clients EXCEPT the one that caused the call in the first place, so you dont have to check ID's if you have no reason to upon receiving a message. (at the top of the very first code you posted)
  9. No need for real synchronization if actions are all standardized. For movement have your client update its position on the server every tick in the update funciton, have the server send that to all other clients, and all other clients just keep setting that players position. (Just set it, rather than set velocities and such). If you have a function to say shoot. Have the function that handle's it for your client be the same thing that handles it when another client shoots. So its all standardized and you dont ahve to worry about syncing it up perfectly. Really this question is just too broad for a good answer. Read some tutorials and think logically about how you could have the same thing happen on multiple screens. All the tools you need are there.
  10. Hey all, So I recently switched my entire game over to Phaser Isometric by @lewster32 and now I keep running into an issue with collision. With just spawning a sprite in and not chaning any of its body properties, collision happens when the TOP of my player's body box reaches the TOP of the sprite's body box. This is a problem because it allows me to just walk through the sprite diagonally, which is not what I want. In fact, what I want is for collision to happen when the BOTTOM of the body boxes touch. (Sidenote: when I say body box I'm referring to the the 3d body shown through a body debug). Here is an example of how it works with no changes made to the body of either sprite. This is collision happening with no modifications: image - side note I am moving up and to the left in this picture, not down and to the left. This is after some changes to the body, the same thing happens too but it more closely represents what I *want* to happen, except it's still happening only with the top of the player sprite and tree sprite. image 2 Similarly, when I go to the top right side of the tree and move down into it, my body will go through the body box until the top of the body box hits the tree's box. When I mess with the Z values it all breaks and no collision will happen either. On top of that, changing the sprites anchors PAST (.5, .49999) also breaks something. Collision will happen at an anchor of (.5, .4999) but not at (.5, .5), it's very strange. Edit: Also, if i set the anchor to greater than (.5, .5) AFTER I enable isoPhysics on the body, the sprite's position gets moved thousands away and sometimes into the negative's. Here is my code to spawn the sprite and player. There is much more that goes into spawning the sprites, but this is anything that could even be related to the issue at hand. player1 = game.add.isoSprite(1000, 1000, 0, 'person'); game.physics.isoArcade.enable(player1); game.physics.isoArcade.collide(player1, itemGroup, null, null, this); createSprite = game.add.isoSprite(1250, 1250, 0, itemGet(chunks.chunks[i][slot]), null, itemGroup); //the anchor and body.setSize code here draws what you see in image 2. With these lines commented out, it outputs image 1. createSprite.anchor.setTo(.5, .49); game.physics.isoArcade.enable(createSprite); createSprite.body.setSize(40, 40, 0, 27, 27); createSprite.body.immovable = true; Any help is GREATLY appreciated. Ive been trying to fix this for a few days now, nothing I do works.
  11. My system in a nutshell is you spawn in, client is sent data of their portion of the map, the client draws it all. Its around a 3k by 2k px draw around the player using 32x32 tiles for everything drawn (except the ground/grass which is a repeating tilesprite). Then when they walk to a point where they need to see more of the map, the server sends more map data, the old map is destroyed and the new chunks are restored. The system is really fast actually, fast enough that you cant see the flicker (but you can feel it while walking, but cant visually see it), that or I made it so that it draws the new sprites before it wipes the old lol, I dont remember its been a while since I wrote it. If you would like to see the game PM me, I would be happy to send you the ip. You need to have a steam account to login though. Edit: Lol, forgot why I was describing my system to begin with. I couldn't use the isometric plugin because it would still be too many sprites generated because I use small tiles. And I never got an answer, is it the phaser isometric plugin or your own system?
  12. Yeah I remembered after I posted that there was a way to change the shape of the phsyics body but I cant remember how. Do I need to use p2 to do it?
  13. Hey just out of curiosity, are you using the phaser isometric plugin by lewster22 on that example of the the noise map? If so, or even not so, how large is the map? Ive been trying to switch my WIP to an isometric view like that but I couldn't quite get it with the phaser isometric plugin because I have too many sprites loaded at once for it to be viable. I tried making a tilesprite that looked isometric to match with the pieces that are actually isoSprites but I couldnt get it to match up and it was pretty buggy. Any suggestions? Edit: Also to piggy-back here, I too have a perlin-noise tiled map generator, but since I built it specific for my WIP it generates a 2000x2000 array, each entry with a number that corresponds with a specific kind of block. It's already packaged nicely since it builds into into a database. If anyone wants it, or if you want it, Ill be happy to drop the source.
  14. Hi there, basically Im planning on switching the tree's in my game to larger more extravagant trees and what I wanted to do was to be able to walk through the top of the sprite, giving the appearance that you are walking behind the tree, but not let them walk through the base of the tree. I couldn't think of a way to do this. I was thinking I would do it with 2 spites maybe? But i thought that was too redundant. I know other frameworks like RPGJS has this but I don't know if phaser does. Thanks for any help in advanced.