Hii,
I want to calculate time taken by the player for making his move. My player can pick his coin and make his move to a box(like in chess). If my player pick his coin early but make his move very lately, then how to calculate time between AI and player move
One option is to reset/abort the move action if it is not finished after a certain amount of time, say 5 secs or whatever is reasonable to your game.
Related
This question may be a duplicate of nested for loops/if statements, but please bear with me. I'm walking through the process of making a tower defense, and I will need to check if the enemy is within range of a tower. I could do some sort of physics circle, but I feel the best way is to check the distance of a tower for each enemy to see if it's within a radius. The thing is, if there's 500 'enemies' and 30 towers, that's 15,000 if statements per frame. Would this be performance heavy? The only way I know to make this any easier is to try these:
Only check every x frame (do the if loop 10 times a second instead of 100)
Do some guessing - nearby towers will use the same tower as theirs
Is there any other way to do any of this or am I on a good track?
Is it likely that all enemies will have moved each time you check? You could just recalculate each time an enemy moves, which towers are within the radius of that particular enemy, then update the list of enemies for just those towers that have either moved into the radius of the enemy, or out of it. You'd need to map each enemy to a list of towers, as well as each tower to a list of enemies.
I got the reference from here User have to apply a force to the character to push him down. That will make him go quickly down slopes, giving him velocity that will make him fly up .But with the figures provided there, When character runs down the slopes it speeds up way too fast and the user does not get much time to release the button. Like in tiny wings, bird moves around hills in good speed not too fast and user gets enough time to release the button and get perfect fly.
Basically how can i store the energy of bird without moving fast along slopes, so that it can fly at the right time.
Any suggestion why it's happening.
Try to check if the bird is colliding with the slopes. If YES, don't apply the force in the dive method... Instead, store energy and apply it when bird leave the slope.
One of the powerups in my game is a vortex that attracts all coins. I know I have any cocos2d's moveto/bezierto methods available, but I don't know how to make them have tangential and radial speed.
The extra difficulty is that the vortex center can change in every step, so all movement has to be readjusted.
One way to achieve this without a physics engine is to use the rotation around point algorithm.
That covers the rotation around the vortex center. Once an object is rotation around the vortex, all you need to do is to reduce that object's distance from the center by a certain amount every frame. That way it will continue to move inwards.
The only tricky part then is to get the object from its initial position being "sucked into" the vortex. There's going to be a lot of tweaking needed. With a physics engine, that part would come natural from the physics itself and it would always look right.
This is not guaranteed for the manual solution and definitely not for actions, which aren't designed to track moving targets. For example, if you change a move action every frame by replacing the existing one with a new one, your object won't move at all. Every time you do that, there's a 1-frame delay before the new action does its work.
I've started developing a small multiplayer racing game, obviously we're using all the player prediction, dead reckoninng and lag compensation techniques that Half Life, Quake and Unreal use - however we plan on having dozens of AI cars in the game as well.
Initially we decided to simply send a random seed to all clients and they will calculate AI positions, etc - however, we've reached the following problem:
All clients receive a seed to run AI cars
Clients only receive movement updates for players within their line of sight
Player A hits an NPC car
Player B enters player A's frame
Now since player B didn't receive player A's movement, he'll assume the AI car is still moving as it should, and wouldn't calculate in the fact that player A hit one of those cars...
So long story short - how can you synchronize AI units that were affected by players?
Presumably, your server is aware of any collisions. In that case, simply notify all your clients of collision results--essentially re-seeding the AI on the clients, at the point of the collision, with the new directions, velocities, RNG seeds, etc.
I'm in the process of developing a 2D fighting game in the same style as Capcom's Street Fighter Alpha for the iPhone. For collision detection, I'm thinking about creating several hit boxes per sprite frame in an animation and checking for collisions between them in the main game loop. Are there any tools for creating hit boxes on sprites and generating this metadata (say in a .plist or .xml)?
How have other 2D fighting games developed by the cocos2d iPhone community handled collision detection and the generation of useful metadata?
Thanks for the forthcoming responses.
In a fighting game, collision detection is actually not performed (or should not be performed, that is).
What you would want to do is determine the distance of Player A from Player B when Player A performs an "attack". Player A's attacks are "static":
High Punch = 64px reach
Low Punch = 54px reach
Mid Punch = 45px reach
High Kick = 64px reach
etc, etc, etc
You would then determine, based on the attack performed and the distance to Player B, and the current state of Player B - whether the attack "landed", was "blocked" or "missed" (High Kick Attack against Crouched Enemy is "miss", while Low Kick Attach with Crouched Enemy NOT in Block is a "hit").
It's a series of "rules" - if the two players are within a specific distance of each other, and the states of each player are correct for the attack, then the attacker "lands", or the defender "blocks" or the attacker "misses".