Search Results

Search found 8232 results on 330 pages for 'the mcmanus position'.

Page 1/330 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Shuffle tiles position in the beginning of the game XNA Csharp

    - by GalneGunnar
    Im trying to create a puzzlegame where you move tiles to certain positions to make a whole image. I need help with randomizing the tiles startposition so that they don't create the whole image at the beginning. There is also something wrong with my offset, that's why it's set to (0,0). I know my code is not good, but Im just starting to learn :] Thanks in advance My Game1 class: { public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D PictureTexture; Texture2D FrameTexture; // Offset för bildgraff Vector2 Offset = new Vector2(0,0); //skapar en array som ska hålla delar av den stora bilden Square[,] squareArray = new Square[4, 4]; // Random randomeraBilder = new Random(); //Width och Height för bilden int pictureHeight = 95; int pictureWidth = 144; Random randomera = new Random(); int index = 0; MouseState oldMouseState; int WindowHeight; int WindowWidth; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; //scalar Window till 800x 600y graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; graphics.ApplyChanges(); } protected override void Initialize() { IsMouseVisible = true; base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); PictureTexture = Content.Load<Texture2D>(@"Images/bildgraff"); FrameTexture = Content.Load<Texture2D>(@"Images/framer"); //Laddar in varje liten bild av den stora bilden i en array for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { Vector2 position = new Vector2(x * pictureWidth, y * pictureHeight); position = position + Offset; Rectangle square = new Rectangle(x * pictureWidth, y * pictureHeight, pictureWidth, pictureHeight); Square frame = new Square(position, PictureTexture, square, Offset, index); squareArray[x, y] = frame; index++; } } } protected override void UnloadContent() { } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); MouseState ms = Mouse.GetState(); if (oldMouseState.LeftButton == ButtonState.Pressed && ms.LeftButton == ButtonState.Released) { // ta reda på vilken position vi har tryckt på int col = ms.X / pictureWidth; int row = ms.Y / pictureHeight; for (int x = 0; x < squareArray.GetLength(0); x++) { for (int y = 0; y < squareArray.GetLength(1); y++) { // kollar om rutan är tom och så att indexet inte går utanför för "col" och "row" if (squareArray[x, y].index == 0 && col >= 0 && row >= 0 && col <= 3 && row <= 3) { if (squareArray[x, y].index == 0 * col) { //kollar om rutan brevid mouseclick är tom if (col > 0 && squareArray[col - 1, row].index == 0 || row > 0 && squareArray[col, row - 1].index == 0 || col < 3 && squareArray[col + 1, row].index == 0 || row < 3 && squareArray[col, row + 1].index == 0) { Square sqaure = squareArray[col, row]; Square hal = squareArray[x, y]; squareArray[x, y] = sqaure; squareArray[col, row] = hal; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { Vector2 goalPosition = new Vector2(x * pictureWidth, y * pictureHeight); squareArray[x, y].Swap(goalPosition); } } } } } } } } //if (oldMouseState.RightButton == ButtonState.Pressed && ms.RightButton == ButtonState.Released) //{ // for (int x = 0; x < 4; x++) // { // for (int y = 0; y < 4; y++) // { // } // } //} oldMouseState = ms; base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); WindowHeight = Window.ClientBounds.Height; WindowWidth = Window.ClientBounds.Width; Rectangle screenPosition = new Rectangle(0,0, WindowWidth, WindowHeight); spriteBatch.Begin(); spriteBatch.Draw(FrameTexture, screenPosition, Color.White); //Ritar ut alla brickorna förutom den som har index 0 for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { if (squareArray[x, y].index != 0) { squareArray[x, y].Draw(spriteBatch); } } } spriteBatch.End(); base.Draw(gameTime); } } } My square class: class Square { public Vector2 position; public Texture2D grafTexture; public Rectangle square; public Vector2 offset; public int index; public Square(Vector2 position, Texture2D grafTexture, Rectangle square, Vector2 offset, int index) { this.position = position; this.grafTexture = grafTexture; this.square = square; this.offset = offset; this.index = index; } public void Draw(SpriteBatch spritebatch) { spritebatch.Draw(grafTexture, position, square, Color.White); } public void RandomPosition() { } public void Swap(Vector2 Goal ) { if (Goal.X > position.X) { position.X = position.X + 144; } else if (Goal.X < position.X) { position.X = position.X - 144; } else if (Goal.Y < position.Y) { position.Y = position.Y - 95; } else if (Goal.Y > position.Y) { position.Y = position.Y + 95; } } } }

    Read the article

  • XNA move from start position to target position exactly in 3D

    - by robasaurus
    If I have a list of positions that map out a path a character should follow. What would be the best way to move at a constant speed to each position making sure the character lands exactly at each position before moving onto the next? For example the character is at position A, we then queue up position B and position C. The character cannot move towards position C until it reaches position B exactly. It would be great if the solution worked at slower frame rates/update speeds as well.

    Read the article

  • Maintain scroll position in ASP.NET

    - by nikolaosk
    One of the most common questions I get is " How to maintain the scroll position-location when a postback occurs in our ASP.NET application? " A lot of times when we click on a e.g a button in our application and a postback occurs, our application "loses" its scroll position. The default behaviour is to go back to the top of the page. There is a very nice feature in ASP.NET that enables us to maintain the scroll position in ASP.NET. The name of this attribute is MaintainScrollPositionOnPostBack ....(read more)

    Read the article

  • Maintain scroll position in ASP.NET

    - by nikolaosk
    One of the most common questions I get is " How to maintain the scroll position-location when a postback occurs in our ASP.NET application? " A lot of times when we click on a e.g a button in our application and a postback occurs, our application "loses" its scroll position. The default behaviour is to go back to the top of the page. There is a very nice feature in ASP.NET that enables us to maintain the scroll position in ASP.NET. The name of this attribute is MaintainScrollPositionOnPostBack ....(read more)

    Read the article

  • Fixed Position div Vertical Only

    - by user720033
    I have a current web build with a right sidebar that is a fixed position. I have tried to positioning from the right but don't want it overlapping other divs content. What I am looking for is to have the content scrollable horizontally to the right when it is out of the viewport window. Any help would be greatly appreciated. similarly to this: http://demo.rickyh.co.uk/css-position-x-and-position-y/ however I can not get this working. This has been solved by alternative method. Thanks for those who actually considered helping.

    Read the article

  • Position Reconstruction from Depth by inverting Perspective Projection

    - by user1294203
    I had some trouble reconstructing position from depth sampled from the depth buffer. I use the equivalent of gluPerspective in GLM. The code in GLM is: template GLM_FUNC_QUALIFIER detail::tmat4x4 perspective ( valType const & fovy, valType const & aspect, valType const & zNear, valType const & zFar ) { valType range = tan(radians(fovy / valType(2))) * zNear; valType left = -range * aspect; valType right = range * aspect; valType bottom = -range; valType top = range; detail::tmat4x4 Result(valType(0)); Result[0][0] = (valType(2) * zNear) / (right - left); Result[1][2] = (valType(2) * zNear) / (top - bottom); Result[2][3] = - (zFar + zNear) / (zFar - zNear); Result[2][4] = - valType(1); Result[3][5] = - (valType(2) * zFar * zNear) / (zFar - zNear); return Result; } There doesn't seem to be any errors in the code. So I tried to invert the projection, the formula for the z and w coordinates after projection are: and dividing z' with w' gives the post-projective depth (which lies in the depth buffer), so I need to solve for z, which finally gives: Now, the problem is I don't get the correct position (I have compared the one reconstructed with a rendered position). I then tried using the respective formula I get by doing the same for this Matrix. The corresponding formula is: For some reason, using the above formula gives me the correct position. I really don't understand why this is the case. Have I done something wrong? Could someone enlighten me please?

    Read the article

  • Kepler orbit : get position on the orbit over time

    - by Artefact2
    I'm developing a space-simulation related game, and I am having some trouble implementing the movement of binary stars, like this: The two stars orbit their centroid, and their trajectories are ellipses. I basically know how to determine the angular velocity at any position, but not the angular velocity over time. So, for a given angle, I can very easily compute the stars position (cf. http://en.wikipedia.org/wiki/Orbit_equation). I'd want to get the stars position over time. The parametric equations of the ellipse works but doesn't give the correct speed : { X(t) = a×cos(t) ; Y(t) = b×sin(t) }. Is it possible, and how can it be done?

    Read the article

  • Calculating the position of an object with regards to current position using OpenGL like matrices

    - by spartan2417
    i have a 1st person camera that collides with walls, i also have a small sphere in front of my camera denoted by the camera position plus the distance ahead. I cannot get the postion of the sphere but i have the position of my camera. e.g. i need to find the position of the point or at the very least find away of calculating the position using the camera positions. code: static Float P_z = 0; P_z = -15; PushMatrix(); LoadMatrix(&Inv); Material(SCEGU_AMBIENT, 0x00000066); TranslateXYZ(0,0,P_z); ScaleXYZ(0.1f,0.1f,0.1f); pointer.Render(); PopMatrix(); where Inv is the camera positions (Inv.w.x,Inv.w.z), pointer is the sphere.

    Read the article

  • Horizontally-centering an absolute position to match a relative position

    - by Chris Vandevelde
    I'm trying to make a div box, containing various elements, fixed at the top of the page once the page has been scrolled so that the box would normally be out of view, but scroll normally until that point (like the behaviour at http://perldoc.perl.org/perl.html). The conditionally-fixed part is pretty simple to implement (set the position to "fixed" once the user has scrolled past a certain point, and "static" once it's scrolled back up), but I'm having trouble with the positioning and dimensions; it screws up if I'm not specifying an absolute position (if I'm using % or "auto", rather than px, em, cm, etc.) or it, confusingly, left-aligns if the box is less than the width of the page. I can understand why, more or less, I'm just trying to fix it. My strategy right now is to have an invisible DIV hold the place of the box and use Prototype's clonePosition() function to hold its position, but it doesn't seem to work for some reason. Neither does copying the margin from one element to the other. Any ideas? Bonus points and eternal gratitude if you can come up with an idea that will adjust itself with the browser window (like auto margins) without setting an onresize event.

    Read the article

  • Retrieving model position after applying modeltransforms in XNA

    - by Glen Dekker
    For this method that the goingBeyond XNA tutorial provides, it would be really convenient if I could retrieve the new position of the model after I apply all the transforms to the mesh. I have edited the method a little for what I need. Does anyone know a way I can do this? public void DrawModel( Camera camera ) { Matrix scaleY = Matrix.CreateScale(new Vector3(1, 2, 1)); Matrix temp = Matrix.CreateScale(100f) * scaleY * rotationMatrix * translationMatrix * Matrix.CreateRotationY(MathHelper.Pi / 6) * translationMatrix2; Matrix[] modelTransforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(modelTransforms); if (camera.getDistanceFromPlayer(position+position1) > 3000) return; foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = modelTransforms[mesh.ParentBone.Index] * temp * worldMatrix; effect.View = camera.viewMatrix; effect.Projection = camera.projectionMatrix; } mesh.Draw(); } }

    Read the article

  • how to transform child elements position into a world position

    - by MrGreg
    So Im making a 2d space game and I have a bunch of spaceships that have turrets. Objects have a position and orientation, the ships being in world coordinates while the turrets are children and coordinates are relative to their parents. How do I efficiently calculate the position of a turret in world coordinates (i.e. when it fires and I need to know where to place a bullet in the world)? Calculating the turrets orientation is trivial - I just add the turrets relative angle to its parents. For position though, I guess I could do a bunch of trigonometry but this MUST be a common problem with a good/fast general solution? Should I be relearning how to do matrix math again? :) btw - Im creating the game in javascript+canvas but its the math/algorithm im interested in here Cheers, Greg

    Read the article

  • Hashing 3D position into 2D position

    - by notabene
    I am doing volumetric raycasting and curently working on depth jitter. I have 3D position on ray and want to sample 2D noise texture to jitter the depth. Function for converting (or hashing) 3D position to 2D have to produce absolutely different numbers for a little changes (especialy because i am sampling in texture space so sample values differs very very little) and have to be "shader-wise" - so forget about branches, cycles etc. I'm looking forward for yours nice and fast solutions.

    Read the article

  • jQuery background-position animation

    - by depi
    Hi guys, I've created an image which is basically a CSS sprite of 3 images together. It's size is 278x123 so they are basically 3 images of 278x41. What I am trying to do is to make an animation of that by changing the background position. I've tried many things, one of my not very working solution is the following: var $slogan = $('#header h2 span'); $slogan.css({backgroundPosition: '0px 0px'}); function slogan_animation() { if ($slogan.css('background-position') == '0px 0px') { $slogan.fadeIn('slow').css('background-position', '0px -41px').fadeOut('slow'); } else if ($slogan.css('background-position') == '0px -41px') { $slogan.fadeIn('slow').css('background-position', '0px -82px').fadeOut('slow'); } else if ($slogan.css('background-position') == '0px -82px') { $slogan.fadeIn('slow').css('background-position', '0px 0px').fadeOut('slow'); } } setInterval(slogan_animation, 2000); Any ideas how could I do that? Basically I just need to: - set my background position to "0px 0px", then move it to "0px -41px", then "0px -82px" and then loop it again from "0px 0px". It would be also great to have fadeIn() effect between those. Any ideas? Thank you.

    Read the article

  • how to deal with the position in a c# stream

    - by CapsicumDreams
    The (entire) documentation for the position property on a stream says: When overridden in a derived class, gets or sets the position within the current stream. The Position property does not keep track of the number of bytes from the stream that have been consumed, skipped, or both. That's it. OK, so we're fairly clear on what it doesn't tell us, but I'd really like to know what it in fact does stand for. What is 'the position' for? Why would we want to alter or read it? If we change it - what happens? In a pratical example, I have a a stream that periodically gets written to, and I have a thread that attempts to read from it (ideally ASAP). From reading many SO issues, I reset the position field to zero to start my reading. Once this is done: Does this affect where the writer to this stream is going to attempt to put the data? Do I need to keep track of the last write position myself? (ie if I set the position to zero to read, does the writer begin to overwrite everything from the first byte?) If so, do I need a semaphore/lock around this 'position' field (subclassing, perhaps?) due to my two threads accessing it? If I don't handle this property, does the writer just overflow the buffer? Perhaps I don't understand the Stream itself - I'm regarding it as a FIFO pipe: shove data in at one end, and suck it out at the other. If it's not like this, then do I have to keep copying the data past my last read (ie from position 0x84 on) back to the start of my buffer? I've seriously tried to research all of this for quite some time - but I'm new to .NET. Perhaps the Streams have a long, proud (undocumented) history that everyone else implicitly understands. But for a newcomer, it's like reading the manual to your car, and finding out: The accelerator pedal affects the volume of fuel and air sent to the fuel injectors. It does not affect the volume of the entertainment system, or the air pressure in any of the tires, if fitted. Technically true, but seriously, what we want to know is that if we mash it to the floor you go faster..

    Read the article

  • Program for scanning, saving and restoring window position?

    - by hellbell.myopenid.com
    Is there some program for scanning, saving and restoring last window position? For example at this moment i have opened five window first is google chrome which is not opened at full screean but at half of display, second is notepad which is on right side, and third is cmd which is under notepad. So I want to use this combination of "layout" when primary using google chrome (surfing at internet), but if working primary at other program let's say word (writting text) i want to use other program and at different position (cause is effectivly). So the point is to easy switching from one "layout" to another. (Like in many program that support more modes, for example visual studio - debug layout, - coding layout, etc ...)

    Read the article

  • How to obtain position in file (byte-position) from java scanner?

    - by september2010
    How to obtain a position in file (byte-position) from the java scanner? Scanner scanner = new Scanner(new File("file")); scanner.useDelimiter("abc"); scanner.hasNext(); String result = scanner.next(); and now: how to get the position of result in file (in bytes)? Using scanner.match().start() is not the answer, because it gives the position within internal buffer.

    Read the article

  • How To Smoothly Animate From One Camera Position To Another

    - by www.Sillitoy.com
    The Question is basically self explanatory. I have a scene with many cameras and I'd like to smoothly switch from one to another. I am not looking for a cross fade effect but more to a camera moving and rotating the view in order to reach the next camera point of view and so on. To this end I have tried the following code: firstCamera.transform.position.x = Mathf.Lerp(firstCamera.transform.position.x, nextCamer.transform.position.x,Time.deltaTime*smooth); firstCamera.transform.position.y = Mathf.Lerp(firstCamera.transform.position.y, nextCamera.transform.position.y,Time.deltaTime*smooth); firstCamera.transform.position.z = Mathf.Lerp(firstCamera.transform.position.z, nextCamera.transform.position.z,Time.deltaTime*smooth); firstCamera.transform.rotation.x = Mathf.Lerp(firstCamera.transform.rotation.x, nextCamera.transform.rotation.x,Time.deltaTime*smooth); firstCamera.transform.rotation.z = Mathf.Lerp(firstCamera.transform.rotation.z, nextCamera.transform.rotation.z,Time.deltaTime*smooth); firstCamera.transform.rotation.y = Mathf.Lerp(firstCamera.transform.rotation.y, nextCamera.transform.rotation.y,Time.deltaTime*smooth); But the result is actually not that good.

    Read the article

  • Efficiently using position to control actions

    - by John Ashmore
    I want to use position (returned from a gridview for e.g.) or a similar numeric integer to do various things, e.g. create a sprite, or in any command that wants something other than a number, e.g. I want to use something like: sprites.add(createSprite(R.drawable.image(position)); , where createSprite creates a sprite using the image supplied, instead of: if (position == 1) {sprites.add(createSprite(R.drawable.image1);} if (position == 2) {sprites.add(createSprite(R.drawable.image2);} ...etc There is an easy solution for strings: Most efficient method to use position to open a .java but what about for situations like this one?

    Read the article

  • Problem on "Finding cursor position" function

    - by sanceray3
    Hi all, Few days ago, I have found a solution to obtain the cursor position on a div with contentedit="true". I use the solution defined on this web site : Finding cursor position in a contenteditable div function getCursorPos() { var cursorPos; if (window.getSelection) { var selObj = window.getSelection(); var selRange = selObj.getRangeAt(0); cursorPos = findNode(selObj.anchorNode.parentNode.childNodes, selObj.anchorNode) + selObj.anchorOffset; /* FIXME the following works wrong in Opera when the document is longer than 32767 chars */ } else if (document.selection) { var range = document.selection.createRange(); var bookmark = range.getBookmark(); /* FIXME the following works wrong when the document is longer than 65535 chars */ cursorPos = bookmark.charCodeAt(2) - 11; /* Undocumented function [3] */ } return cursorPos; } function findNode(list, node) { for (var i = 0; i < list.length; i++) { if (list[i] == node) { return i; } } return -1; } It functions well, but when I use html tags inside the div the pointer doesnt show the correct position. For example if I try to find cursor position on the <strong>cat</strong> is black, the function doesn't return me the good position. But if I try on the cat is black, it functions. Any ideas how to get the position with html tags ? Thanks for your help.

    Read the article

  • Silverlight horizontal stretch and get position issue

    - by David
    I have a Grid (container) wich in turn has several grids(subContainers) arranged by rows. Each one of those "subContainers" has diferent columns and controls. And each of those "subContainers" has the horizontal alignment set to stretch, and it has to stay that way, since the layout this viewer depends on it. I use the "container" to set each control on it's adequate position. So far so good. Now comes my headache... I want to remove the control from the grid and put it in a canvas, at the same exact position, only, the position it returns is as if the control is set to the beggining of the grid and not it's true position. For testing purposes, I've set the "subContainters" horizontal alignment to center and (despite the layout is totally wrong) every control is in it's right position when sent to a canvas, wich it doesn't happen when HA = stretch. Here's the code I'm using to get position: GeneralTransform gt = nc.TransformToVisual(gridZoom); Point offset = gt.Transform(new Point()); So you can understand, for example, my first control should be somewhere like (80, 1090), but the point that I get is (3,3). Can anyone help me? Thanks

    Read the article

  • Can Windows XP remember file icon position?

    - by g .
    Windows allows you to arrange icons however you like in a window. However after some time when I go back to the window, it has forgotten the icon positions and has completely rearranged the icons. Is there a way to preserve the icon positions? In the previous version of Windows I used, this would happen on rare occasions (about 6 months) and it might only move a couple of icons. Now it is happening practically every day and it is every single icon. Attempts to rearrange them manually are futile and it is increasingly maddening. Searching Google, I have found a number of programs that allow you to save and restore icon position on the desktop. But, this is just a regular folder window so I am not sure if any of those would even work. Some details: Windows XP SP 3 running in Parallels 5 virtual machine Auto Arrange and Align to Grid are NOT turned on Fresh OS install and only setting icon positions in one window

    Read the article

  • Calculating a child Position, Rotation and Scale values?

    - by Sergio Plascencia
    I am making my own game editor(just for fun) anyway I have problem that I had several days trying to resolve but I have been unsuccessful. Here goes... I have an object "A": Position: (3,3,3), Rotation: (45,10,0), Scale(1,2,2.5) And an object "B": Position: (1,1,1), Rotation: (10,34,18), Scale(1.5,2,1) I now make a parent/child relationship. "B" is a child of "A": A |--B When I do the relationship I need to re-calculate the Child("B") Position, Rotation and Scale such that it maintains its current position, rotation and scale(Location in world). So for child position "B" it would now be (-2, -2, -2) since now "A" it is center and (-2, -2, -2) will keep the object in its same position. I think I got the Position and scale figure out, but rotation I cant. So I was trying to figure out what to do and what I did is opened Unity and run the same example and I did noticed that when making an abject a child object the child object did not moved at all but had its Position, Rotation and Scale values changed(Related to the parent). For example: Unity (Parent Object "A"): Position: (0,0,0) Rotation: (45,10,0) Scale: (1,1,1) Unity (Child Object "B"): Position: (0,0,0) Rotation: (0,0,0) Scale: (1,1,1) When making it a parent child relation("B" is a child of "A") the child object("B") in its Rotation values now has: X: -44.13605 Y: -14.00195 Z: 9.851074 If I plug the same values to my editor(To the child "B" rotation X, Y, Z values) the object does not move at all. So I basically need to know how did Unity arrive at those rotation values for the child(What are the calculations?). If you can help and put all the equations for the Position, Rotation or Scale then I can double check I am doing it correctly but with the Rotation I really need help. Thanks!

    Read the article

  • Calculate new position of player

    - by user1439111
    Edit: I will summerize my question since it is very long (Thanks Len for pointing it out) What I'm trying to find out is to get a new position of a player after an X amount of time. The following variables are known: - Speed - Length between the 2 points - Source position (X, Y) - Destination position (X, Y) How can I calculate a position between the source and destion with these variables given? For example: source: 0, 0 destination: 10, 0 speed: 1 so after 1 second the players position would be 1, 0 The code below works but it's quite long so I'm looking for something shorter/more logical ====================================================================== I'm having a hard time figuring out how to calculate a new position of a player ingame. This code is server sided used to track a player(It's a emulator so I don't have access to the clients code). The collision detection of the server works fine I'm using bresenham's line algorithm and a raycast to determine at which point a collision happens. Once I deteremined the collision I calculate the length of the path the player is about to walk and also the total time. I would like to know the new position of a player each second. This is the code I'm currently using. It's in C++ but I am porting the server to C# and I haven't written the code in C# yet. // Difference between the source X - destination X //and source y - destionation Y float xDiff, yDiff; xDiff = xDes - xSrc; yDiff = yDes - ySrc; float walkingLength = 0.00F; float NewX = xDiff * xDiff; float NewY = yDiff * yDiff; walkingLength = NewX + NewY; walkingLength = sqrt(walkingLength); const float PI = 3.14159265F; float Angle = 0.00F; if(xDes >= xSrc && yDes >= ySrc) { Angle = atanf((yDiff / xDiff)); Angle = Angle * 180 / PI; } else if(xDes < xSrc && yDes >= ySrc) { Angle = atanf((-xDiff / yDiff)); Angle = Angle * 180 / PI; Angle += 90.00F; } else if(xDes < xSrc && yDes < ySrc) { Angle = atanf((yDiff / xDiff)); Angle = Angle * 180 / PI; Angle += 180.00F; } else if(xDes >= xSrc && yDes < ySrc) { Angle = atanf((xDiff / -yDiff)); Angle = Angle * 180 / PI; Angle += 270.00F; } float WalkingTime = (float)walkingLength / (float)speed; bool Done = false; float i = 0; while(i < walkingLength) { if(Done == true) { break; } if(WalkingTime >= 1000) { Sleep(1000); i += speed; WalkTime -= 1000; } else { Sleep(WalkTime); i += speed * WalkTime; WalkTime -= 1000; Done = true; } if(Angle >= 0 && Angle < 90) { float xNew = cosf(Angle * PI / 180) * i; float yNew = sinf(Angle * PI / 180) * i; float NewCharacterX = xSrc + xNew; float NewCharacterY = ySrc + yNew; } I have cut the last part of the loop since it's just 3 other else if statements with 3 other angle conditions and the only change is the sin and cos. The given speed parameter is the speed/second. The code above works but as you can see it's quite long so I'm looking for a new way to calculate this. btw, don't mind the while loop to calculate each new position I'm going to use a timer in C# Thank you very much

    Read the article

  • How to position an element next to another an element of undefined position?

    - by allin
    Hi, I am very new to html/xml/css and I'm trying my best to teach myself. However, I have run into a problem that a Google search could not solve. I would like to position a small image in a fixed location relative to another element(?) I believe this is the code of the element i want to position the second element relative to. #wrap { width:550px; background-color:#fff; margin:0 auto; padding:0; border-right:1px solid #ccc; border-left:1px solid #ccc; } #container { width: 500px; margin:0 auto; padding: 25px; font-size:.85em; background-color: #fff; } and this is partial code I'm trying to edit to position .xyz to the right of "#wrap" .xyz { position: ???; top: 200px; right: ???; _position: ???; _margin: ???; _text-align: right; z-index: 1337; } my search of SOF has lead me to believe i'm supposed to do something along the lines of this - http://stackoverflow.com/questions/104953/position-an-html-element-relative-to-its-container-using-css - but i haven't been able to. I greatly appreciate any help you may offer. Hopefully I've explained my problem properly.

    Read the article

  • CSS Position Help (horizontal sidebar showing up when animate content over)

    - by jstacks
    Let me try my best to explain what I'd like to have happen, show you the code I have an hopefully I can get some help. So, I'm trying to do a sliding navigation UI from the left side of the screen (like a lot of mobile apps). The main content slides over, displaying the navigation menu beneath. Right now the browser thinks the screen is getting wider and introduces a horizontal scroll bar. However, I don't want that to happen... How do I get the div to animate off screen but not enlarge the width of the screen (i.e. keep it partially off screen)? Anyway here is my fiddle: http://jsfiddle.net/2vP67/6/ And here is the code within the post: HTML <div id='wrapper'> <div id='navWide'> </div> <div id='containerWide'> </div> <div id='containerTall'> <div id='container'> <div id='nav'> <div id='navNavigate'> Open Menu </div> <div id='navNavigateHide'> Close Menu </div> </div> </div> </div> <div id='sideContainerTall'> <div id='sideContainer'> <div id='sideNav'>Side Navigation </div> </div> </div> </div> CSS #wrapper { width:100%; min-width:1000px; height:100%; min-height:100%; position:relative; top:0; left:0; z-index:0; } #navWide { color: #ffffff; background:#222222; width:100%; min-width:1000px; height:45px; position:fixed; top:0; left:0; z-index:100; } #containerWide { width:100%; min-width:1000px; min-height:100%; position:absolute; top:45px; z-index:100; } #containerTall { color: #000000; background:#dadada; width:960px; min-height:100%; margin-left:-480px; position:absolute; top:0; left:50%; z-index:1000; } /***** main container *****/ #container { width:960px; min-height:585px; } #nav { color: #ffffff; background:#222222; width:960px; height:45px; position:fixed; top:0; z-index:10000; } #navNavigate { background:yellow; font-size:10px; color:#888888; width:32px; height:32px; padding:7px 6px 6px 6px; float:left; cursor:pointer; } #navNavigateHide { background:yellow; font-size:10px; color:#888888; width:32px; height:32px; padding:7px 6px 6px 6px; float:left; cursor:pointer; display:none; } #sideContainerTall { background:#888888; width:264px; min-height:100%; margin-left:-480px; position:absolute; top:0; left:50%; z-index:500; } #sideContainer { width:264px; min-height:585px; display:none; } #sideContainerTall { background:#888888; width:264px; min-height:100%; margin-left:-480px; position:absolute; top:0; left:50%; z-index:500; } #sideContainer { width:264px; min-height:585px; display:none; } #sideNav { width:264px; height:648px; float:left; } Javascript $(document).ready(function() { $('div#navNavigate').click(function() { $('div#navNavigate').hide(); $('div#navNavigateHide').show(); $('div#sideContainer').show(); $('div#containerTall').animate({ 'left': '+=264px' }); }); $('div#navNavigateHide').click(function() { $('div#navNavigate').show(); $('div#navNavigateHide').hide(); $('div#containerTall').animate({ 'left': '-=264px' }, function() { $('div#sideContainer').hide(); }); }); });

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >