Search Results

Search found 1061 results on 43 pages for 'movement'.

Page 10/43 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • javascript div movement not working

    - by William
    For some reason I can't move this div at all. Can anyone help me out with why this won't work? <!DOCTYPE html> <html lang="en"> <head> <title>Move Div Test</title> <meta charset="utf-8" /> <link href="/bms/style.css" rel="stylesheet" /> <style> body { text-align: center; background-color: #ffffff;} #box { position: absolute; left: 610px; top: 80px; height: 50px; width: 50px; background-color: #ff0000;} </style> <script type="text/javascript"> document.onkeydown=function(event){keyDown(event)}; document.onkeyup=function(event){keyUp(event)}; var box = document.getElementById('box'); var speed = 5; var keys = new Array(256); var i = 0; for (i = 0;i <= 256; i++){ keys[i] = false; } function keyDown(event){ if(!event){ //for IE event = window.event; } keys[event.keyCode] = true; } function keyUp(event){ if(!event){ //for IE event = window.event; } keys[event.keyCode] = false; } function update(){ if(keys[37]) box.style.left = parseInt(box.style.left) - speed + "px"; if(keys[39]) box.style.left = parseInt(box.style.left) + speed + "px"; if(keys[38]) box.style.top = parseInt(box.style.top) - speed + "px"; if(keys[40]) box.style.top = parseInt(box.style.top) + speed + "px"; } setInterval('update();', 1000/60); </script> </head> <body> <div id="box">blah</div> </body> </html>

    Read the article

  • 3d movement around a sphere

    - by user578954
    Hey guys, Im working in 3d for the first time in a long time. Basically im rotating a sphere and projecting x y z cords to place things on the surface based on the spheres X and Y rotation. Heres the code im using: #define piover180 0.01745329252f GLfloat cosy = cos(yrot * piover180); island[i].x = rad * sin(xrot * piover180)* cosy; island[i].y = rad * sin(yrot * piover180); island[i].z = rad * cos(xrot * piover180) * cosy; Problem is the Xrot positioning works fine but the Yrot placement always draw the objects into the north and south pole so they all cross at the top, which isnt correct for rotating. I need a way to solve this. Heres a picture to help explain http://llllost.com/shuttle/47bcde62.jpg Any help would be greatly appreciated, let me know if you need any more information

    Read the article

  • JQuyer slide and stop issues: animated element freezes with quick mouse movement

    - by sherlock
    Here is Zi JsFiddle. In order to replicate my issue you have to hover over the link that says 'javascript', then mouseout that, then mouseback in. If you do this before the animation is complete, the pink slidedown #subMenu will freeze midway through sliding. Is there a way to prevent this from happening? I have tried some .stop()s , but i really don't want the animation to re-start every time you mouseenter or leave the .navLink . The animation should begin from where it left off. In other words, if the pink section is halfway down, and a slideDown() gets executed, the pink should not dissappear and then slide down, it should slide down from where it is. Thanks!! JS: $('header#subHeader').hide(); $('.navLink').hover(function () { if ($(this).children('div').length > 0) { var subMenu = $(this).find('.subMenu').html(); $('header#subHeader').empty().append('<div>' + subMenu + '</div>').stop().slideDown(); } else { $('header#subHeader').stop().slideUp(); } }); $('hgroup:first').on('mouseleave', function(){ $('header#subHeader').slideUp(); });

    Read the article

  • How To Alter This Code So That It Only Redirects If There Is No Mouse Movement

    - by user1426261
    I have the following java script which redirects the user to another website (google in this case). <script type="text/JavaScript"> window.setTimeout("location=('http://www.google.com');",5000); </script> However, although i want the website to redirect to another website, i dont want it to redirect for no reason. My aim is for the website to redirect automatically on the condition that the cursor hasnt been moved for a little while. is this possible?

    Read the article

  • Is good practice to optimize FPS even when it's above the lower limit to give illusion of movement?

    - by rraallvv
    I started over 50 FPS on the iPhone, but now I'm bellow 30 PFS, I've seen most iPhone games clamped to either 60 or 30 FPS, even when 24 or less would give the illusion of movement. I've concidered my limit to be a little bit over 15 FPS, in fact my physics simulation is updated at that rate (15.84 steps/s) as that is the lowest that still give fluid movement, a bit lower gives jerky motion. Is there a practical reason why to clamp FPS way above the lower limit? Update: The following image could help to clarify I can independently set the physic simulation step, frame rate, and simulation interval update. My concern is why should I clamp any of those to values greater than the minimum? For instance to conserve battery life I could just to choose the lower limits, but it seems that 60 or 30 FPS are the most used values.

    Read the article

  • How can I tweak this A* search pathfinding algorithm to handle different terrain movement values?

    - by user422318
    I'm creating a 2D map-based action game with similar interaction design as Diablo II. In other words, the player clicks around a map to move their player. I just finished player movement and am moving on to pathfinding. In the game, enemies should charge the player's character. There are also five different terrain types that give different movement bonuses. I want the AI to take advantage of these terrain bonuses as they try to reach the player. I was told to check out the A* search algorithm (http://en.wikipedia.org/wiki/A*_search_algorithm). I'm doing this game in HTML5 and JavaScript, and found a version in JavaScript: http://www.briangrinstead.com/blog/astar-search-algorithm-in-javascript I'm trying to figure out how to tweak it though. Below are my ideas about what I need to change. What else do I need to worry about? When I create a graph, I will need to initialize the 2D array I pass in passed on with a traversal of a map that corresponds to the different terrain types. in graph.js: "GraphNodeType" definition needs to be modified to handle the 5 terrain types. There will be no walls. in astar.js: The g and h scoring will need to be modified. How should I do this? in astar.js: isWall() should probably be removed. My game doesn't have walls. in astar.js: I'm not sure what this is. I think it indicates a node that isn't valid to be processed. When would this happen, though? At a high level, how do I change this algorithm from "oh, is there a wall there?" to "will this terrain get me to the player faster than the terrain around me?" Because of time, I'm also debating reusing my Bresenham algorithm for the enemies. Unfortunately, the different terrain movement bonuses won't be used by the AI, which will make the game suck. :/ I'd really like to have this in for the prototype, but I'm not a developer by trade nor am I a computer scientist. :D If you know of any code that does what I'm looking for, please share! Sanity check tips for this are also appreciated.

    Read the article

  • How can I imitate interaction and movement in Diablo II?

    - by user422318
    I'm prototyping a simple browser-based game. It's played from a top down perspective on a 2d canvas. You left-click on a point on the map, and your character will begin walking to it. If you click on a different point on the map, then your character will begin walking to the new point. It's similar to Diablo II: http://www.youtube.com/watch?v=EvDKt-To6K0&feature=related How can I best imitate this movement system for a player? Ideas... Track current coords and target coords If target coords are exactly up, left, right, or down, then increment appropriate direction until you get there Implied else: target coords are in a quadrant. To make this movement look natural, character will have to move diagonally. For example, pretend the target is to the northeast. For each game frame, alternate incrementing current coordinates in the north and then east directions.

    Read the article

  • How to move a directional light according to the camera movement?

    - by Andrea Benedetti
    Given a light direction, how can I move it according to the camera movement, in a shader? Think that an artist has setup a scene (e.g., in 3DSMax) with a mesh in center of that and a directional light with a position and a target. From this position and target I've calculated the light direction. Now I want to use the same direction in my lighting equation but, obviously, I want that this light moves correctly with the camera. Thanks.

    Read the article

  • Is it possible to move the stage in actionscript 3.0?

    - by Joe.F
    Hi to keep it short and simple let's say I have a stage with 400x400 size in pixels, but I've drawn a map of 1000x1000 size in pixels. I want my player to be able to "walk" about the stage, but it appears stage.x and stage.y are read-only? Is there any method or way to have the stage "scroll" about, without having to move each object on the map? Thanks!

    Read the article

  • Visual Studio ate my toobar :'(

    - by j-t-s
    Visual Studio ate my toolbar, I opened a solution for a project I've been working on for a few months, and the toolbar has 135 buttons on it, and while it was loading, the whole toolbar flickered like it was trying to give me a seizure or something, and then it dissappeared. Now when I click Debug, it won't let me do it because all the resources are missing!? I'm using: Visual Studio 2010 C# Express Windows 7 Home Premium 64-bit. I have searched Google and found nothing related. I'm hoping that Visual Studio can also somehow make bowel movements so I can find those missing resources and put everything back together again, but I don't think that's a likely scenario... Has anybody ever experienced this before, and if so, are there any updates/fixes for this?

    Read the article

  • How do I implement smooth movement in a Box2D platform game?

    - by Romeo
    I have implemented a character in JBox2D which moves with the help of a wheel rotating at the bottom of it. The movement is the best result I've had 'till now but it's a little glitchy when the character stands on the edge. So I am thinking should I use five smaller wheels instead of a big wheel. The wheel/wheels will not be visible in the finished product, now they are drawn for debugging. Here is a video. Is there a better way to do this using JBox2D?

    Read the article

  • How can I render player movement on a 2d plane efficiently?

    - by user422318
    I'm prototyping a 2d HTML5 game with similar interaction to Diablo II. (See an older post of mine describing the interaction here: How can I imitate interaction and movement in Diablo II?) I just got the player click-to-move system working using the Bresenham algorithm but I can't figure out how to efficiently render the player's avatar as he moves across the screen. By the time redraw() is called, the player has already finished moving to the target point. If I try to call redraw() more frequently (based on my game timer), there's incredible system lag and I don't even see the avatar image glide across the screen. I have a game timer based off this awesome timer class: http://www.dailycoding.com/Posts/object_oriented_programming_with_javascript__timer_class.aspx In the future, there will be multiple enemies chasing the player. Fast pace is essential to the experience. What should I do?

    Read the article

  • Box2D platformer movement. Should i mess with velocity?

    - by Romeo
    I have a platformer game in which I implemented the movement using a wheel attached to the hero. For jumping I use this: player.body.applyLinearImpulse(new Vec2(0, 30000000), player.body.getPosition()); The problem is that the xVelocity doesn't remain the same during the jump so it isn't looking natural. Is there any way to modify only the x velocity of the body so that before jumping I store it in a variable and after jumping I apply it to the body? I hope you understand what I am trying to say.

    Read the article

  • Box2D platformer movement. Are joints a good idea?

    - by Romeo
    So i smashed my brains trying to make my character move. As i wanted later in the game to add explosions and bullets it wasn't a good idea to mess with the velocity and the forces/impulses didn't work as i expected so something stuck in my mind: Is it a good idea to put at his bottom a wheel(circle) which is invisible to the player that will do the movement by rotation? I will attach this to my main body with a revolute joint but i don't really know how to make the main body and wheel body to don't collide one with each other since funny things can happen. What is your oppinion?

    Read the article

  • How to solve problems with movement in simple tile based multiplayer game?

    - by Murlo
    I'm making a simple tile based 2D multiplayer game in JavaScript using socket.io where you can move one tile every 200 ms. The two solutions I've tried are as follows: The client sends "walk one tile north" every 200 ms. Problem: People can easily hack the client to send the action more often. The client sends "walking north" and "stopped walking". Problem: Sometimes the player moves extra steps when "stopped walking" doesn't arrive in time. Do you know a way around these problems or is there a better way to do it? EDIT: Regarding the first solution I've tried adding validation on the server to check if it has been 200 ms since last movement. The problem is that latency still encourages people just to spam the action as much as possible, giving them an unfair advantage.

    Read the article

  • How do I implement input and movement with characters that get into vehicles?

    - by Xkynar
    I'm making a game similar to GTA2. When the player enters the vehicle, what happens in terms of logic? Does the player becomes the vehicle? Does the vehicle override the player movement? The main question is how should it look at a vehicle? I want to understand if the player becomes the car or if the player has a "motion state" like "driving, walking, flying" depending on what he is doing in a moment, I know there are tons of ways to implement vehicles in a game.

    Read the article

  • Why compiz or unity refresh screen by every movement I do? [closed]

    - by Behzadsh
    It's getting me crazy! compiz or unity refresh screen (like I run compiz --replace or unity --replace) by every movement I do (e.g ctrl+tab, super+w) and somehow unexpectedly! sometimes it failed to reload title bar and keyboard functions like ctrl+tab and alt+F2 stop working, and I had no chance but reboot! Sometimes it work without any problem. I couldn't found any reason why this happen. I wanted to report a bug but I don't have enough information about it.

    Read the article

  • Moving UIButton around

    - by pbcoder
    I've tried to move a UIButton up and down in a menu. The problem I've got with the following solution is that the timer is not accurate. Sometimes the Button is moved up 122px, sometimes only 120px. How I can fix this? -(IBAction)marketTabClicked:(id)sender { if (marketTabExtended) { NSLog(@"marketTabExtended = YES"); return; } else { if (iPhoneAppsExtended) { timer = [NSTimer scheduledTimerWithTimeInterval:0.005 target: self selector: @selector(animateItemApps) userInfo: nil repeats: YES]; } else { if (homepageExtended) { timer = [NSTimer scheduledTimerWithTimeInterval:0.005 target: self selector: @selector(animateItemHomepage) userInfo: nil repeats: YES]; } else { timer = [NSTimer scheduledTimerWithTimeInterval:0.005 target: self selector: @selector(animateItemMarketing) userInfo: nil repeats: YES]; } } } [self performSelector:@selector(stopTimer) withObject:self afterDelay:0.605]; iPhoneAppsExtended = NO; homepageExtended = NO; marketTabExtended = NO; marketTabExtended = YES; } -(void)animateItemApps { CGPoint movement; movement = CGPointMake(0, -1); homepage.center = CGPointMake(homepage.center.x, homepage.center.y + movement.y); } -(void)animateItemHomepage { CGPoint movement; movement = CGPointMake(0, 1); homepage.center = CGPointMake(homepage.center.x, homepage.center.y + movement.y); //marketTab.center = CGPointMake(marketTab.center.x, marketTab.center.y + movement.y); } -(void)animateItemMarketing { CGPoint movement; movement = CGPointMake(0, -1); //marketTab.center = CGPointMake(marketTab.center.x, marketTab.center.y + movement.y); homepage.center = CGPointMake(homepage.center.x, homepage.center.y + movement.y); } -(void)stopTimer { [timer invalidate]; }

    Read the article

  • How do I have to take into account the direction in which the camera is facing when creating a first person strafe (left/right) movement

    - by Chris
    This is the code I am currently using, and it works great, except for the strafe always causes the camera to move along the X axis which is not relative to the direction in which the camera is actually facing. As you can see currently only the x location is updated: [delta * -1, 0, 0] How should I take into account the direction in which the camera is facing (I have the camera's target x,y,z) when creating a first person strafe (left/right) movement? case 'a': var eyeOriginal = g_eye; var targetOriginal = g_target; var viewEye = g_math.subVector(g_eye, g_target); var viewTarget = g_math.subVector(g_target, g_eye); viewEye = g_math.addVector([delta * -1, 0, 0], viewEye); viewTarget = g_math.addVector([delta * -1, 0, 0], viewTarget); g_eye = g_math.addVector(viewEye, targetOriginal); g_target = g_math.addVector(viewTarget, eyeOriginal); break; case 'd': var eyeOriginal = g_eye; var targetOriginal = g_target; var viewEye = g_math.subVector(g_eye, g_target); var viewTarget = g_math.subVector(g_target, g_eye); viewEye = g_math.addVector([delta, 0, 0], viewEye); viewTarget = g_math.addVector([delta, 0, 0], viewTarget); g_eye = g_math.addVector(viewEye, targetOriginal); g_target = g_math.addVector(viewTarget, eyeOriginal); break;

    Read the article

  • Simulating smooth movement along a line after calculating a collision containing a restitution of zero in 2D

    - by Casey
    [for tl;dr see after listing] //...Code to determine shapes types involved in collision here... //...Rectangle-Line collision detected. if(_rbTest->GetCollisionShape()->Intersects(*_ground->GetCollisionShape())) { //Convert incoming shape to a line. a2de::Line l(*dynamic_cast<a2de::Line*>(_ground->GetCollisionShape())); //Get line's normal. a2de::Vector2D normal_vector(l.GetSlope().GetY(), -l.GetSlope().GetX()); a2de::Vector2D::Normalize(normal_vector); //Accumulate forces involved. a2de::Vector2D intermediate_forces; a2de::Vector2D normal_force = normal_vector * _rbTest->GetMass() * _world->GetGravityHandler()->GetGravityValue(); intermediate_forces += normal_force; //Calculate final velocity: See [1] double Ma = _rbTest->GetMass(); a2de::Vector2D Ua = _rbTest->GetVelocity(); double Mb = _ground->GetMass(); a2de::Vector2D Ub = _ground->GetVelocity(); double mCr = Mb * _ground->GetRestitution(); a2de::Vector2D collision_velocity( ((Ma * Ua) + (Mb * Ub) + ((mCr * Ub) - (mCr * Ua))) / (Ma + Mb)); //Calculate reflection vector: See [2] a2de::Vector2D reflect_velocity( -collision_velocity + 2 * (a2de::Vector2D::DotProduct(collision_velocity, normal_vector)) * normal_vector ); //Affect velocity to account for restitution of colliding bodies. reflect_velocity *= (_ground->GetRestitution() * _rbTest->GetRestitution()); _rbTest->SetVelocity(reflect_velocity); //THE ULTIMATE ISSUE STEMS FROM THE FOLLOWING LINE: //Move object away from collision one pixel to prevent constant collision. _rbTest->SetPosition(_rbTest->GetPosition() + normal_vector); _rbTest->ApplyImpulse(intermediate_forces); } Sources: (1) Wikipedia: Coefficient of Restitution: Speeds after impact (2) Wikipedia: Specular Reflection: Direction of reflection First, I have a system in place to account for friction (that is, a coefficient of friction) but is not used right now (in addition, it is zero, which should not affect the math anyway). I'll deal with that after I get this working. Anyway, when the restitution of either object involved in the collision is zero the object stops as required, but if movement along the same direction (again, irrespective of the friction value that isn't used) as the line is attempted the object moves as if slogging through knee deep snow. If I remove the line of code in question and the object is not push away one pixel the object barely moves at all. All because the object collides, is stopped, is pushed up, collides, is stopped...etc. OR collides, is stopped, collides, is stopped, etc... TL;DR How do I only account for a collision ONCE for restitution purposes (BONUS: but CONTINUALLY for frictional purposes, to be implemented later)

    Read the article

  • How to implement a multi-part snake with smooth movement? [closed]

    - by Jamie
    Sorry that i couldnt answer on my previous post but it got closed. I couldnt answer because i had to prepair for my finals. As there were problems with understanding of what im trying to achieve, im going to describe a little bit more in depth. Im creating a game in which you steer a snake. I assume everybody knows how that works. But in my case the snake isnt just propagating in an array element by element. Imagine a 2Dgrid on which the snake moves. Its 10x10 tiles. Lets say one tile is 4x4 meters. The snakes head spawns in the middle of the (3,2) tile (beginning with (0,0)), so its position is (4*3+2,4*2+2)(the 2's are so that the snake is in the middle of the 4x4 tile). And heres where the fun begins. when the snake moves, it doesnt jump to next tile. Instead it moves a fraction of the way there. So lets say the snake is heading to tile (4,2). After it moved once, its position is (4*3+2+0.1,4*2+2), where 0.1 is the fraction of the way it moved. This is done to achieve smooth movement. So now im adding the rest of the body. The rest is supposed to move along the exact same path as the head did. I implemented it so that each part of the body has its own position and direction. Then i apply this algorithm: 1.Move each part in its direction. 2.If a part is in the middle of the tile(which implies all of them are), change each parts direction to the direction of the part proceeding it. As i said before i could make this work, but i cant stop thinking that im overlooking a much easier and cleaner solution. So this is my question. Is there any easier/better/faster way to do this?

    Read the article

  • how do I match movement of an object from 2d video into a 3d package ?

    - by George Profenza
    I'm trying to add objects in a 3d package(Blender) using recorded footage. I've played with Icarus and it's great to capture the camera movement. Also the Blender 2.41 importer script works in Blender 2.49 as well. The problem is I can't seem to get 3d coordinates for objects. I have tried Autodesk(RealVIZ) MatchMover 2011 and gone through the tutorials. Tutorial 3 shows how to link a vertex from a 3d mesh to a 2d trackpoint, but the setup is for camera movement. Tutorial 4 goes into Motion capture, but it uses 2 videos of the same motion taken with 2 cameras from different viewpoints. I've tried to bypass that using the same footage twice, but that failed, as the 3d coordinate system ends up messed up. What software do you recommend for this (mapping 3d coordinates to 2d tracked points and importing them into a 3d package) ? What is the recommended technique ? Any good examples out there ? Thanks, George

    Read the article

  • How can I reverse mouse movement (X & Y axis) system-wide? (Win 7 x64)

    - by Scivitri
    Short Version I'm looking for a way to reverse the X and Y mouse axis movements. The computer is running Windows 7, x64 and Logitech SetPoint 6.32. I would like a system-level, permanent fix; such as a mouse driver modification or a registry tweak. Does anyone know of a solid way of implementing this, or how to find the registry values to change this? I'll settle quite happily for how to enable the orientation feature in SetPoint 6.32 for mice as well as trackballs. Long Version People seem never to understand why I would want this, and I commonly hear "just use the mouse right-side up!" advice. Dyslexia is not something which can be cured by "just reading things right." While I appreciate the attempts to help, I'm hoping some background may help people understand. I have a user with an unusual form of dyslexia, for whom mouse movements are backward. If she wants to move her cursor left, she will move the mouse right. If she wants the cursor to move up, she'll move the mouse down. She used to hold her mouse upside-down, which makes sophisticated clicking difficult, is terrible for ergonomics, and makes multi-button mice completely useless. In olden times, mouse drivers included an orientation feature (typically a hot-air balloon you dragged upward to set the mouse movement orientation) which could be used to set the relationship between mouse movement and cursor movement. Several years ago, mouse drivers were "improved" and this feature has since been limited to trackballs. After losing the orientation feature she went back to upside-down mousing for a bit, until finding UberOptions, a tweak for Logitech SetPoint, which would enable all features for all pointing devices. This included the orientation feature. And there was much rejoicing. Now her mouse has died, and current Logitech mice require a newer version of SetPoint for which UberOptions has not been updated. We've also seen MAF-Mouse (the developer indicated the version for 64-bit Windows does not support USB mice, yet) and Sakasa (while it works, commentary on the web indicate it tends to break randomly and often. It's also just a running program, so not system-wide.). I have seen some very sophisticated registry hacks. For example, I used to use a hack which would change the codes created by the F1-F12 keys when the F-Lock key was invented and defaulted to screwing my keyboard up. I'm hoping there's a way to flip X and Y in the registry; or some other, similar, system-level tweak out there. Another solution could be re-enabling the orientation feature for mice, as well as trackballs. It's very frustrating that input device drivers include the functionality we desperately need for an accessibilty concern, but it's been disabled in the name of making the drivers more idiot-proof.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >