Jump to content
  • Advertisement

zqf

Member
  • Content Count

    33
  • Joined

  • Last visited

Community Reputation

388 Neutral

About zqf

  • Rank
    Member

Personal Information

  • Role
    Programmer
  • Interests
    Design
    Programming
  1. I've been trying to understand how jitter is handled myself after reading Gaffer's article on state sync. He explains the reasons why he delays but nothing specifically about how the client chooses it's time base. Could you elaborate on how you do this a little? eg what amount of time you spending choosing the right number and how you handle resolving if the time drifts and the client is ahead/behind?
  2. hmm, okay. I will have a go at implementing something like that and see Thanks!
  3. When you say multiple steps are you referring to the frame updates the server has run? As I understand so far I need a queue of events each with a serial number and frame number to play back on the client, with events transmitted redundantly until acknowledgment?
  4. Fair enough I understand there is the UDP MTU which dictates the maximum safe size for a single packet, but how many packets would generally be sent. Is it generally one per client per server tick okay? Interesting. I'll look into that.
  5. Would this serial number effectively be another sequence number? Seems like you wouldn't want such events to be out of order (eg a spawn being read after it's own death, given how fast things are moving) ?
  6. Hello. I'm working on a project to teach myself network programming and the little game I have in mind is a coop arena shooter. A fast moving game, lots of simple enemies and projectiles frequently spawning and dying. I've been reading what I can find about synchronising the game state (snapshots, delta compression, update prioritisation), but this mostly relates to objects that already exist, not how to deal with a high volume of new objects coming and going. Does anyone have any suggestions/advice relating to this kind of problem? My thoughts so far are based on using what determinism I can and playing the game back as as sequence of events as best I can. Eg if I want to spawn a spread of a dozen projectiles I can reconstruct all of them from the initial condition of the first plus a random seed or index to some kind of predefined pattern that might deterministically recreate the whole group. This combined with trying to do as much movement as possible via paths that can be interpolated (so a spawn event can be played up to the right position on the client when received and just played forward with every tick without direct synchronisation except in the case of death) so even if the event is received late it can be easily wound forward If I'm barking up the wrong alley here I'd love to know! Thanks.
  7. I'm sure someone else would have something more elegant but this is some code I dug up out of an old project of my own for what sounds like a similar game, so it does work :p // This rectangle defines your screen size. Replace 640x480 with the size of your Flash app. // We will spawn enemies just outside this rectangle. var _screenRect:Rectangle = new Rectangle(0, 0, 640, 480); // This rectangle defines the range of positions enemies should spawn in. It will be adjusted // to match the size of the enemy being spawned during the set position method. var _spawnRect:Rectangle = new Rectangle(); // Return a random number between min and max. private function RandomWithinRange(min:Number, max:Number):Number { return Math.random() * (max - min) + min; } // Send a sprite class to this to move it off the screen. private function MoveOffscreen(enemy:Sprite):void { var spawnX:Number; var spawnY:Number; // We set the spawn rectangle to the size of the screen but // expand it out by the size of the object being spawned. // This will allow enemies of any size to always be moved off screen. var padX:Number = enemy.width; var padY:Number = enemy.height; _spawnRect.x = _screenRect.x - padX; _spawnRect.width = _screenRect.width + padX; _spawnRect.y = _screenRect.y - padY; _spawnRect.height = _screenRect.height + padY; // Pick randomly between X and Y, and move the spawn position to the full extent on // that axis. Then randomise the other axis. if (Math.random() > 0.5) { // We are setting the X to its full distance on the left or right, randomly pick which if (Math.random() > 0.5) { // left spawnX = _spawnRect.x; } else { // right spawnX = _spawnRect.width; } // Randomise the other axis. spawnY = RandomWithinRange(_spawnRect.y, _spawnRect.height); } else { // We are setting the Y to its full distance up or down, randomly pick which if (Math.random() > 0.5) { // Up spawnY = _spawnRect.y; } else { // down spawnY = _spawnRect.height; } // Randomise the other axis. spawnX = RandomWithinRange(_spawnRect.x, _spawnRect.width); } // Move the enemy to the new position enemy.x = spawnX; enemy.y = spawnY; }
  8. In a component based system how should I give sub-components references that their parent shouldn't have? eg: An Entity: maybe a monster, creates a Ray attack class for itself. The Ray Attack: This will cast the ray and receive the hit callbacks from the world, calculating the nearest hit (or more if the attack can penetrate) and hitting them. The World: which in my case at the moment is a box2D simulation. I want the child object, the ray attack to have access to the world (or more specifically, access to a single world method: 'QueryRay'. I don't want the parent entity to however. Should I pass it into some controller that will call a setup method on the ray attack that gives it the reference it needs perhaps...? At the moment my game passes around a 'services' class, containing interfaces to sub-controllers. This defines the capacity entities have to act outside of themselves. One of these is a 'rayAttack' controller that handles EVERY ray attack from anything, with the highly elegant: var rayAttack = services.rayAttack; rayAttack.Setup(a whole bunch of params); rayAttack.Fire(x0, y0, x1, y1); This is one example, I have all these central controllers bloating up with specific methods and I'd like to turn them into components but keep references tight to where they're needed only.
  9. zqf

    Flash Blitting Flicker

    Cleaned up a bit here it is. Language is Actionscript 3, only libraries used are Box2D for physics/collision, the rest is my own or standard Flash stuff. // On Frame draw call in Main public function Render():void { canvas.lock(); canvas.fillRect(canvas.rect, 0xff000000); _manager.currentState.Render(canvas); canvas.unlock(); } // In GameState public function Render(canvas:BitmapData):void { var mapRendPoint:Point = _gameModel.mapRenderPoint; // Position is taken from the box2D physics position of a camera entity tracking the player. // Subtract half screen width to get the top left point of the screen. var scrX:Number = _gameModel.camera.position.x * Main.PIXELS_PER_METRE - screenInfo.halfWidth; var scrY:Number = _gameModel.camera.position.y * Main.PIXELS_PER_METRE - screenInfo.halfHeight; scrX = Math.round(scrX); scrY = Math.round(scrY); mapRenderPoint.x = scrX; mapRenderPoint.y = scrY; // Render point is kept within the bounds of the tile map _gameModel.TileMap.CapRenderPoint(mapRenderPoint); // TileMap is given map position and adds every Tile to be drawn to the Draw List. _gameModel.TileMap.Render(mapRenderPoint); /* Game objects are added to the list */ // display list is called, this will actually run the calls to copy to canvas. draw list is then wiped _blitter.RenderFrame(canvas, mapRenderPoint); } // In Tile class, called from _blitter after TileMap has added all the tiles to be drawn public function Render(canvas:BitmapData, topLeft:Point):void {     // Translate to screen position     _rendPosition.x = _position.x - topLeft.x;     _rendPosition.y = _position.y - topLeft.y;     // Draw     canvas.copyPixels(_curFrame, _rendRect, _rendPosition, null, null, true); }
  10. Edit: Sorry I meant to post this in Beginners forum. I am creating a platformer where the entire game is blitted. The tile map seemed to be fine, however certain tiles with transparent pixels flicker very badly when the screen moves, appearing to change brightness rapidly, whilst other parts remain okay (I think). Please check out this little demo to see the effect (use WASD to move around). http://www.dampdogdev.com/devDemos/rngFlicker/flicker.html I've tried rounding the exact render position, flooring it, and double buffering but nothing I've tried seems to affect it.
  11. I dunno if this is helpful, and maybe this is covered by code you've removed to make your example smaller but an observation: Your renderer is defaulting to using the screen canvas as a source... public function Renderer(bitmapdata) { mBitmapData = bitmapdata; this.mDisplayBD = bitmapdata; ...If your Loader doesn't complete and replace the source then it will be copying the canvas onto itself and there's no load failure listener so if it fails you won't know about it.
  12. Hello there. This question is about a platform game in box2D but I assume that it would be applicable to any platform game. At the moment my character jumps by setting his vertical velocity, but I'm at a point where I want to tweak the gravity of the game but not affect the actual distance the player will jump, so I can adjust the feel of the gravity without constantly have to alter the player jump strength. Gravity force vector in box2D is currently +22 on y. I want the player body to be pushed upward exactly 3 metres. The player can double jump, and I want this to happen regardless of what the current velocity of the player is. If the player is falling very quickly, hitting jump will cause them to stop and pop up 3 metres. Thanks
  13. I understand the desire to keeping game actors from seeing these large data structures, but I'm still trying to see what would be considered a safe way to bring them together? Is this where it is simplest to just make position and collision shape public variables or getters? Using movement and collision as an example still: The world loops through all actors, sends them to a collision class that can move the actor and call them when collisions occur? The collision class doesn't see all of the world, and can see the required details of the actor it's moving? In this way objects don't control exactly how they are moved, or see any world information, they just have a velocity and a shape, and methods for responding to a collision.
  14. Thanks for your replies. I'm mainly just paranoid about getting into bad habits
  15. How about the world holding a list of movers that it calls when it updates? Objects that want to move would add themselves to this list, that sort of thing?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!