Search Results

Search found 7 results on 1 pages for 'thex'.

Page 1/1 | 1 

  • Why is my arrow texture being drawn in odd places?

    - by tyjkenn
    This is a script I wrote that places an arrow on the screen, pointing to an enemy off-screen, or, if the enemy is on-screen, it places an arrow hovering above the enemy. Everything seems to work, except for some odd reason, I see random arrows floating around, often skewed and resized (which I really don't understand, because I only rotate and place in this script). Even when I only have one enemy in the scene, I still see these random arrows. It should only be drawing one per enemy. Note: when all enemies are removed, no arrows appear. var arrow : Texture; var cam : Camera; var dim : int = 30; function OnGUI() { var objects = GameObject.FindGameObjectsWithTag("Enemy"); for(var ob : GameObject in objects) { var pos = cam.WorldToViewportPoint(ob.transform.position); if(gameObject.GetComponent(FollowCamera).target != null){ var tar = gameObject.GetComponent(FollowCamera).target.parent; } if(pos.z>1 && ob.transform != tar){ var xDiff = (pos.x*cam.pixelWidth)-(cam.pixelWidth/2); var yDiff = (pos.y*cam.pixelHeight)-(cam.pixelHeight/2); var angle = Mathf.Rad2Deg*Mathf.Atan(yDiff/xDiff)+180; if(xDiff>0) angle += 180; var dist = Mathf.Sqrt(xDiff*xDiff + yDiff*yDiff); var slope = yDiff/xDiff; var camSlope = cam.pixelHeight/cam.pixelWidth; var theX = -1000.0; var theY = -1000.0; var mult = 0; var temp; if(Mathf.Abs(xDiff)>(cam.pixelWidth/2)||Mathf.Abs(yDiff)>(cam.pixelHeight/2)){ //touching right if(slope<camSlope && slope>-camSlope) { if(xDiff>(cam.pixelWidth/2)) { theX = cam.pixelWidth - (dim/2); mult = -1; }else if(xDiff<-(cam.pixelWidth/2)) { theX = (dim/2); mult = 1; } temp = ((cam.pixelWidth/2)*yDiff)/xDiff; theY =(cam.pixelHeight/2)+(mult*temp); } else{ if(yDiff>(cam.pixelHeight/2)) { theY = (dim/2); mult = 1; }else if(yDiff<-(cam.pixelHeight/2)) { theY = cam.pixelHeight - (dim/2); mult = -1; } temp = ((cam.pixelHeight/2)*xDiff)/yDiff; theX =(cam.pixelWidth/2)+(mult*temp); } } else { angle = -90; theX = (cam.pixelWidth/2)+xDiff; theY = (cam.pixelHeight/2)-yDiff-dim; } GUIUtility.RotateAroundPivot(-angle, Vector2(theX, theY)); Graphics.DrawTexture(Rect(theX-(dim/2),theY-(dim/2),dim,dim),arrow,null); GUIUtility.RotateAroundPivot(angle, Vector2(theX, theY)); } } }

    Read the article

  • What's the best way to re-install Ubuntu on my triple-boot system?

    - by TheX
    I have a triple boot system with Windows, Ubuntu 10.10 and 11.04, installed in that order, plus a "Data" Partition that has all my data, what I want to do is remove the 11.04, because I haven't booted into it for over a month, and I am afraid if I try to do any updates it will bork the system... I would like to install a fresh copy of 11.04 and leave the rest of the system intact, what is the best way to do this?

    Read the article

  • Computer refuses to POST

    - by TheX
    Computer refuses to POST. What it will do is the fan spins up, and the lights come on on the motherboard, but other then that it just sits there and laughs in my face! Here is what I have done... I have tried 2 different video cards, both known to work, 4 different sticks of RAM in all four ram slots, 2 processors (known to work), and 2 power supplies (known to work). The only constant is the motherboard... The Motherboard is a Asus m3a3-mvp deluxe. Anyone have any other ideas? Also, I have bread boarded it to make sure there where no shorts (taken everything out of the case and tried again).

    Read the article

  • Add child to scene from within a class.

    - by Fecal Brunch
    Hi, I'm new to flash in general and have been writing a program with two classes that extend MovieClip (Stems and Star). I need to create a new Stems object as a child of the scene when the user stops dragging a Star object, but do not know how to reference the scene from within the Star class's code. I've tried passing the scene into the constructor of the Star and doing sometihng like: this.scene.addChild (new Stems ()); But apparently that's not how to do it... Below is the code for Stems and Stars, any advice would be appreciated greatly. package { import flash.display.MovieClip; import flash.events.*; import flash.utils.Timer; public class Stems extends MovieClip { public const centreX=1026/2; public const centreY=600/2; public var isFlowing:Boolean; public var flowerType:Number; public const outerLimit=210; public const innerLimit=100; public function Stems(fType:Number) { this.isFlowing=false; this.scaleX=this.scaleY= .0007* distanceFromCentre(this.x, this.y); this.setXY(); trace(distanceFromCentre(this.x, this.y)); if (fType==2) { gotoAndStop("Aplant"); } } public function distanceFromCentre(X:Number, Y:Number):int { return (Math.sqrt((X-centreX)*(X-centreX)+(Y-centreY)*(Y-centreY))); } public function rotateAwayFromCentre():void { var theX:int=centreX-this.x; var theY:int = (centreY - this.y) * -1; var angle = Math.atan(theY/theX)/(Math.PI/180); if (theX<0) { angle+=180; } if (theX>=0&&theY<0) { angle+=360; } this.rotation = ((angle*-1) + 90)+180; } public function setXY() { do { var tempX=Math.random()*centreX*2; var tempY=Math.random()*centreY*2; } while (distanceFromCentre (tempX, tempY)>this.outerLimit || distanceFromCentre (tempX, tempY)<this.innerLimit); this.x=tempX; this.y=tempY; rotateAwayFromCentre(); } public function getFlowerType():Number { return this.flowerType; } } } package { import flash.display.MovieClip; import flash.events.*; import flash.utils.Timer; public class Star extends MovieClip { public const sWide=1026; public const sTall=600; public var startingX:Number; public var startingY:Number; public var starColor:Number; public var flicker:Timer; public var canUpdatePos:Boolean=true; public const innerLimit=280; public function Star(color:Number, basefl:Number, factorial:Number) { this.setXY(); this.starColor=color; this.flicker = new Timer (basefl + factorial * (Math.ceil(100* Math.random ()))); this.flicker.addEventListener(TimerEvent.TIMER, this.tick); this.addEventListener(MouseEvent.MOUSE_OVER, this.hover); this.addEventListener(MouseEvent.MOUSE_UP, this.drop); this.addEventListener(MouseEvent.MOUSE_DOWN, this.drag); this.addChild (new Stems (2)); this.flicker.start(); this.updateAnimation(0, false); } public function distanceOK(X:Number, Y:Number):Boolean { if (Math.sqrt((X-(sWide/2))*(X-(sWide/2))+(Y-(sTall/2))*(Y-(sTall/2)))>innerLimit) { return true; } else { return false; } } public function setXY() { do { var tempX=this.x=Math.random()*sWide; var tempY=this.y=Math.random()*sTall; } while (distanceOK (tempX, tempY)==false); this.startingX=tempX; this.startingY=tempY; } public function tick(event:TimerEvent) { if (this.canUpdatePos) { this.setXY(); } this.updateAnimation(0, false); this.updateAnimation(this.starColor, false); } public function updateAnimation(color:Number, bright:Boolean) { var brightStr:String; if (bright) { brightStr="bright"; } else { brightStr="low"; } switch (color) { case 0 : this.gotoAndStop("none"); break; case 1 : this.gotoAndStop("N" + brightStr); break; case 2 : this.gotoAndStop("A" + brightStr); break; case 3 : this.gotoAndStop("F" + brightStr); break; case 4 : this.gotoAndStop("E" + brightStr); break; case 5 : this.gotoAndStop("S" + brightStr); break; } } public function hover(event:MouseEvent):void { this.updateAnimation(this.starColor, true); this.canUpdatePos=false; } public function drop(event:MouseEvent):void { this.stopDrag(); this.x=this.startingX; this.y=this.startingY; this.updateAnimation(0, false); this.canUpdatePos=true; } public function drag(event:MouseEvent):void { this.startDrag(false); this.canUpdatePos=false; } } }

    Read the article

  • Managing text-maps in a 2D array on to be painted on HTML5 Canvas

    - by weka
    So, I'm making a HTML5 RPG just for fun. The map is a <canvas> (512px width, 352px height | 16 tiles across, 11 tiles top to bottom). I want to know if there's a more efficient way to paint the <canvas>. Here's how I have it right now. How tiles are loaded and painted on map The map is being painted by tiles (32x32) using the Image() piece. The image files are loaded through a simple for loop and put into an array called tiles[] to be PAINTED on using drawImage(). First, we load the tiles... and here's how it's being done: // SET UP THE & DRAW THE MAP TILES tiles = []; var loadedImagesCount = 0; for (x = 0; x <= NUM_OF_TILES; x++) { var imageObj = new Image(); // new instance for each image imageObj.src = "js/tiles/t" + x + ".png"; imageObj.onload = function () { console.log("Added tile ... " + loadedImagesCount); loadedImagesCount++; if (loadedImagesCount == NUM_OF_TILES) { // Onces all tiles are loaded ... // We paint the map for (y = 0; y <= 15; y++) { for (x = 0; x <= 10; x++) { theX = x * 32; theY = y * 32; context.drawImage(tiles[5], theY, theX, 32, 32); } } } }; tiles.push(imageObj); } Naturally, when a player starts a game it loads the map they last left off. But for here, it an all-grass map. Right now, the maps use 2D arrays. Here's an example map. [[4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 1, 1, 1, 1], [1, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 13, 13, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 13, 13, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 13, 13, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 13, 13, 13, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 13, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 1], [1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1, 1, 1]]; I get different maps using a simple if structure. Once the 2d array above is return, the corresponding number in each array will be painted according to Image() stored inside tile[]. Then drawImage() will occur and paint according to the x and y and times it by 32 to paint on the correct x-y coordinate. How multiple map switching occurs With my game, maps have five things to keep track of: currentID, leftID, rightID, upID, and bottomID. currentID: The current ID of the map you are on. leftID: What ID of currentID to load when you exit on the left of current map. rightID: What ID of currentID to load when you exit on the right of current map. downID: What ID of currentID to load when you exit on the bottom of current map. upID: What ID of currentID to load when you exit on the top of current map. Something to note: If either leftID, rightID, upID, or bottomID are NOT specific, that means they are a 0. That means they cannot leave that side of the map. It is merely an invisible blockade. So, once a person exits a side of the map, depending on where they exited... for example if they exited on the bottom, bottomID will the number of the map to load and thus be painted on the map. Here's a representational .GIF to help you better visualize: As you can see, sooner or later, with many maps I will be dealing with many IDs. And that can possibly get a little confusing and hectic. The obvious pros is that it load 176 tiles at a time, refresh a small 512x352 canvas, and handles one map at time. The con is that the MAP ids, when dealing with many maps, may get confusing at times. My question Is this an efficient way to store maps (given the usage of tiles), or is there a better way to handle maps? I was thinking along the lines of a giant map. The map-size is big and it's all one 2D array. The viewport, however, is still 512x352 pixels. Here's another .gif I made (for this question) to help visualize: Sorry if you cannot understand my English. Please ask anything you have trouble understanding. Hopefully, I made it clear. Thanks.

    Read the article

  • How do I set an event off when player is on certain tile?

    - by Tom Burman
    Here is the code I use to create and print my map to the canvas: var board = []; function loadMap(map) { if (map == 1) { return [ [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2], [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2], [2,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2], [2,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2], [2,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,3,0,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,2], [2,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0,0,0,0,0,0,2], [2,0,0,0,0,3,3,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,3,0,0,2], [2,0,0,0,0,0,0,3,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,2], [2,0,0,0,0,0,0,3,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,2], [2,0,0,0,0,0,0,0,3,3,0,0,0,0,3,0,0,0,0,0,0,0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] ]; } } board = loadMap(1); enterfor (y = 0; y <= viewHeight; y++) { for (x = 0; x <= viewWidth; x++) { var theX = x * 32; var theY = y * 32; context.drawImage(mapTiles[board[y+viewY][x+viewX]], theX, theY, 32, 32); } } And here is the code I use for player movement: canvas.addEventListener('keydown', function(e) { console.log(e); var key = null; switch (e.which) { case 37: // Left if (playerX > 0) playerX--; break; case 38: // Up if (playerY > 0) playerY--; break; case 39: // Right if (playerX < worldWidth) playerX++; break; case 40: // Down if (playerY < worldHeight) playerY++; break; } viewX = playerX - Math.floor(0.5 * viewWidth); if (viewX < 0) viewX = 0; if (viewX+viewWidth > worldWidth) viewX = worldWidth - viewWidth; viewY = playerY - Math.floor(0.5 * viewHeight); if (viewY < 0) viewY = 0; if (viewY+viewHeight > worldHeight) viewY = worldHeight - viewHeight; }, false); What I am looking for is a method for when the player lands on tile 3 he loses health. I have tried to use this in the player movement but it doesnt seem to work e.g the left movement: case 37: // Left if (playerX > 0) playerX--; if(board[x2 - 1] == 3) { health--; playerX--; }

    Read the article

  • Custom Expression in Linq-to-Sql Designer

    - by csharpnoob
    According to Microsoft: http://msdn.microsoft.com/de-de/library/system.data.linq.mapping.columnattribute.expression.aspx It's possible to add expression to the Linq-to-SQL Mapping. But how to configure or add them in Visual Studio in the Designer? Problem, when I add it manual to thex XYZ.designer.cs it on change it will be lost. //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:2.0.50727.4927 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ This is generated: [Column(Name="id", Storage="_id", DbType="Int")] public System.Nullable<int> id { ... But i need something like this [Column(Name="id", Storage="_id", DbType="Int", Expression="Max(id)")] public System.Nullable<int> id { ... Thanks.

    Read the article

1