Search Results

Search found 1174 results on 47 pages for 'square'.

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

  • checking whether 4 points in a plane define a square ??

    - by osabri
    how to check whether 4 points in the plane define a square? what's the function which given a point and a value of the area of a square as input parameters returns four squares(define a corresponding type) with sides parallel to the x axis and y axis this how i start: #include <stdio.h> #include<math.h> struct point{ float x; float y; } typedef struct point POINT; struct square{ struct point p1; struct point p2; struct point p3; struct point p4; } typedef struct square SQUARE; int main() { int point; printf("point coordinate"); printf("\n\n"); printf("enter data\n");

    Read the article

  • 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

  • function which given a point and a value of the area of a square as input parameter returns four squ

    - by osabri
    in this code i don't understand why teacher used sometimes +value, - value; /******************************************/ // function void returnSquares(POINT point, int value) void returnSquares(POINT point, int value) { SQUARE tabSquares[4]; // table of squares that we are creating int i; // getting points of 4 squares // for first square input point is point C tabSquares[0].pointA.dimX = point.dimX - value; tabSquares[0].pointA.dimY = point.dimY + value; tabSquares[0].pointB.dimX = point.dimX; tabSquares[0].pointB.dimY = point.dimY + value; tabSquares[0].pointC.dimX = point.dimX; tabSquares[0].pointC.dimY = point.dimY; tabSquares[0].pointD.dimX = point.dimX - value; tabSquares[0].pointD.dimY = point.dimY; // for 2nd square input point is point D tabSquares[1].pointA.dimX = point.dimX; tabSquares[1].pointA.dimY = point.dimY + value; tabSquares[1].pointB.dimX = point.dimX + value; tabSquares[1].pointB.dimY = point.dimY + value; tabSquares[1].pointC.dimX = point.dimX + value; tabSquares[1].pointC.dimY = point.dimY; tabSquares[1].pointD.dimX = point.dimX; tabSquares[1].pointD.dimY = point.dimY; // for 3rd square input point is point A tabSquares[2].pointA.dimX = point.dimX; tabSquares[2].pointA.dimY = point.dimY; tabSquares[2].pointB.dimX = point.dimX + value; tabSquares[2].pointB.dimY = point.dimY; tabSquares[2].pointC.dimX = point.dimX + value; tabSquares[2].pointC.dimY = point.dimY - value; tabSquares[2].pointD.dimX = point.dimX; tabSquares[2].pointD.dimY = point.dimY - value; // for 4th square input point is point B tabSquares[3].pointA.dimX = point.dimX - value; tabSquares[3].pointA.dimY = point.dimY; tabSquares[3].pointB.dimX = point.dimX; tabSquares[3].pointB.dimY = point.dimY; tabSquares[3].pointC.dimX = point.dimX; tabSquares[3].pointC.dimY = point.dimY - value; tabSquares[3].pointD.dimX = point.dimX - value; tabSquares[3].pointD.dimY = point.dimY - value; for (i=0; i<4; i++) { printf("Square number %d\n",i); // now we print parameters of each point in current Square printf("point A x= %0.2f y= %0.2f\n",tabSquares[i].pointA.dimX,tabSquares[i].pointA.dimY); printf("point B x= %0.2f y= %0.2f\n",tabSquares[i].pointB.dimX,tabSquares[i].pointB.dimY); printf("point C x= %0.2f y= %0.2f\n",tabSquares[i].pointC.dimX,tabSquares[i].pointC.dimY); printf("point D x= %0.2f y= %0.2f\n",tabSquares[i].pointD.dimX,tabSquares[i].pointD.dimY); } }

    Read the article

  • Take input through Buttons in java

    - by stash211
    I understand that the title might not be descriptive enough, but I'm making a magic square game in Java and basically, I'm trying to replicate user input as found in the sudoku game here: http://www.websudoku.com/. What I have is a n x n grid of Buttons (not JButton) as the board and what I want the user to be able to do is when the user clicks on one of the buttons, similar to the game above, it allows the user to type in his guess in the button itself instead of popping up a dialog box with an input field of some sort. I don't know where to start, I am a beginner in Java (not very beginner, but my knowledge with the various Java APIs is very limited), so I'm trying to find out if this would be possible and if it is, how would I go about doing it? Thanks for any help.

    Read the article

  • What algorithm to use to fill a KenKen square board with cages?

    - by JimmyBoh
    I am working on recreating KenKen, a popular math puzzle involving a blank grid that is divided into "cages". Each cage is just a collection of adjacent squares and has a clue which is generally a number and an operand, shown below: What type of algorithm would be best to fill the square with cages? Assume the maximum number of cells per cage would be 3 and the board is 4x4 in size, like in the example above.

    Read the article

  • Add kilometers to a map point

    - by proveyourselfthom
    Good morning. I would like to know how do I add kilometers to a map point (latitude / longitude). For example: The city Jaraguá do Sul is in latitude -26.462049, longitude -49.059448. I want to add 100 kilometers up, down, and on the sides. I want to do a square and get the new points. How do I do that? I tried it: <?php $distance = 100; $earthRadius = 6371; $lat1 = -26.4853239150483; $lon1 = -49.075927734375; $bearing = 0; $lat2 = asin(sin($lat1) * cos($distance / $earthRadius) + cos($lat1) * sin($distance / $earthRadius) * cos($bearing)); $lon2 = $lon1 + atan2(sin($bearing) * sin($distance / $earthRadius) * cos($lat1), cos($distance / $earthRadius) - sin($lat1) * sin($lat2)); echo 'LAT: ' . $lat2 . '<br >'; echo 'LNG: ' . $lon2; ?> But it's returning wrong cordinates. Thank you! Thank you very much.

    Read the article

  • Is the Asus Lion Square compatible with an AMD Athlon II AM3?

    - by wag2639
    I bought an Asus Lion Square compatible with a AMD Athlon II X3 435 Socket AM3 processor? I know strictly speaking, the Lion Square specifies AM2 but I'm a little confused since AM2 and AM3 are suppose to be socket compatible (I'm a little confused here as well but I assume it means an AM3 board will support AM2/AM2+ CPUs). However, will there be a problem with chip height and spacing? Or do people have experience asking ASUS for a standoff adapter?

    Read the article

  • Retrieving an element by array index in jQuery vs the each() function.

    - by Alex Ciminian
    I was writing a "pluginable" function when I noticed the following behavior (tested in FF 3.5.9 with Firebug 1.5.3). $.fn.computerMove = function () { var board = $(this); var emptySquares = board.find('div.clickable'); var randPosition = Math.floor(Math.random() * emptySquares.length); emptySquares.each(function (index) { if (index === randPosition) { // logs a jQuery object console.log($(this)); } }); target = emptySquares[randPosition]; // logs a non-jQuery object console.log(target); // throws error: attr() not a function for target board.placeMark({'position' : target.attr('id')}); } I noticed the problem when the script threw an error at target.attr('id') (attr not a function). When I checked the log, I noticed that the output (in Firebug) for target was: <div style="width: 97px; height: 97px;" class="square clickable" id="8"></div> If I output $(target), or $(this) from the each() function, I get a nice jQuery object: [ div#8.square ] Now here comes my question: why does this happen, considering that find() seems to return an array of jQuery objects? Why do I have to do $() to target all over again? [div#0.square, div#1.square, div#2.square, div#3.square, div#4.square, div#5.square, div#6.square, div#7.square, div#8.square] Just a curiosity :).

    Read the article

  • Python beautifulsoup trying to remove html tags 'span'

    - by Michelle Jun Lee
    I am trying to remove [<span class="street-address"> 510 E Airline Way </span>] and I have used this clean function to remove the one that is in between < > def clean(val): if type(val) is not StringType: val = str(val) val = re.sub(r'<.*?>', '',val) val = re.sub("\s+" , " ", val) return val.strip() and it produces [ 510 E Airline Way ]` i am trying to add within "clean" function to remove the char '[' and ']' and basically i just want to get the "510 E Airline Way". anyone has any clue what can i add to clean function? thank you

    Read the article

  • Making Visual C++ DLL from C++ class

    - by prosseek
    I have the following C++ code to make dll (Visual Studio 2010). class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; }; class __declspec(dllexport) Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area(void); virtual double perimeter(void); }; class __declspec(dllexport) Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area(void); virtual double perimeter(void); }; I have the __declspec, class __declspec(dllexport) Circle I could build a dll with the following command CL.exe /c example.cxx link.exe /OUT:"example.dll" /DLL example.obj When I tried to use the library, Square* square; square->area() I got the error messages. What's wrong or missing? example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall ... Square::area(void)" (?area@Square@@UAENXZ) ADDED Following wengseng's answer, I modified the header file, and for DLL C++ code, I added #define XYZLIBRARY_EXPORT However, I still got errors. example_unittest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __th iscall Circle::Circle(double)" (__imp_??0Circle@@QAE@N@Z) referenced in function "protected: virtual void __thiscall TestOne::SetUp(void)" (?SetUp@TestOne@@MAEXXZ) example_unittest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __th iscall Square::Square(double)" (__imp_??0Square@@QAE@N@Z) referenced in function "protected: virtual void __thiscall TestOne::SetUp(void)" (?SetUp@TestOne@@MAEXXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Square::area(void)" (?area@Square@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Square::perimeter(void)" (?perimeter@Square@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Circle::area(void)" (?area@Circle@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Circle::perimeter(void)" (?perimeter@Circle@@UAENXZ)

    Read the article

  • C++ beginner question regarding chars

    - by Samwhoo
    I'm just messing around with some C++ at the moment trying to make a simple tic-tac-toe game and I'm running into a bit of a problem. This is my code: #include <iostream> using namespace std; class Square { public: char getState() const; void setState(char); Square(); ~Square(); private: char * pState; }; class Board { public: Board(); ~Board(); void printBoard() const; Square getSquare(short x, short y) const; private: Square board[3][3]; }; int main() { Board board; board.getSquare(1,2).setState('1'); board.printBoard(); return 0; } Square::Square() { pState = new char; *pState = ' '; } Square::~Square() { delete pState; } char Square::getState() const { return *pState; } void Square::setState(char set) { *pState = set; } Board::~Board() { } Board::Board() { } void Board::printBoard() const { for (int x = 0; x < 3; x++) { cout << "|"; for (int y = 0; y < 3; y++) { cout << board[x][y].getState(); } cout << "|" << endl; } } Square Board::getSquare(short x, short y) const { return board[x][y]; } Forgive me if there are blatantly obvious problems with it or it's stupidly written, this is my first program in C++ :p However, the problem is that when I try and set the square 1,2 to the char '1', it doesn't print out as a 1, it prints out as some strange character I didn't recognise. Can anyone tell me why? :) Thanks in advance.

    Read the article

  • Parenting Opengl with Groups in LibGDX

    - by Rudy_TM
    I am trying to make an object child of a Group, but this object has a draw method that calls opengl to draw in the screen. Its class its this public class OpenGLSquare extends Actor { private static final ImmediateModeRenderer renderer = new ImmediateModeRenderer10(); private static Matrix4 matrix = null; private static Vector2 temp = new Vector2(); public static void setMatrix4(Matrix4 mat) { matrix = mat; } @Override public void draw(SpriteBatch batch, float arg1) { // TODO Auto-generated method stub renderer.begin(matrix, GL10.GL_TRIANGLES); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x0, y0, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x0, y1, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x1, y1, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x1, y1, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x1, y0, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x0, y0, 0f); renderer.end(); } } In my screen class I have this, i call it in the constructor MyGroupClass spriteLab = new MyGroupClass(spriteSheetLab); OpenGLSquare square = new OpenGLSquare(); square.setX0(100); square.setY0(200); square.setX1(400); square.setY1(280); square.color.set(Color.BLUE); square.setSize(); //spriteLab.addActorAt(0, clock); spriteLab.addActor(square); stage.addActor(spriteLab); And the render in the screen I have @Override public void render(float arg0) { this.gl.glClear(GL10.GL_COLOR_BUFFER_BIT |GL10.GL_DEPTH_BUFFER_BIT); stage.draw(); stage.act(Gdx.graphics.getDeltaTime()); } The problem its that when i use opengl with parent, it resets all the other chldren to position 0,0 and the opengl renderer paints the square in the exact position of the screen and not relative to the parent. I tried using batch.enableBlending() and batch.disableBlending() that fixes the position problem of the other children, but not the relative position of the opengl drawing and it also puts alpha to the glDrawing. What am i doing wrong?:/

    Read the article

  • GAME MAKER Problem with sprites! Can't see the sprite after mouse action

    - by user46882
    I have got a problem in Game Maker Pro: http://www.directupload.net/file/d/3646/egdpdu6u_gif.htm At the start we see a white square moving. If I press a key the square stop to move and the background changes to white. If the background changes to white a new animation/sprite should play on the same position where the white square was. BUT IT DOESNT! (Actually it is still there! It just does not move and this is fine) The animation is basically a sprite animation with some outlines of the square. If I press a key again, the background changes to white and we see the animation of the sprite.. but we do not see the animation of the sprites when it does not move. And this is strange!! I want to have the animation of the square when it doesn't move. But I don't get it.. by the way.. the .gif is a old version. I allready fixed the problem with the moving animation.. but I am still not able to play the animation if the square does not fly. The color of the animation is allready set to green or something! for better contrast. But still.. can't see it. Here is the code: obj.weisse.kugel.stepevent = the white square with the movements and sprite animations etc. if (global.kweiss == 1 ) { // vspeed = 8; //visible = true // sprite_index=spr_weisse_kugel; image_speed = 0; image_index = 0; } else if (global.kweiss == 0) { sprite_index=spr_animation_fade_out; image_speed =0.2; image_index=image_number-1 vspeed = 0; //visible = false // } then I have 1 create event for all the global.variables obj.global_var globalvar kweiss; kweiss = 1; globalvar kschwarz; kschwarz = 0; and then I have 1 controll stepevent in a new obj: if device_mouse_check_button_pressed (0, mb_left) { if background_color = c_black { background_color = c_white } else { background_color = c_black } // change of the square to white if (global.kweiss = 0) { global.kweiss = 1; } else { global.kweiss = 0; } if (global.kschwarz = 0) // change the square to black (other bullets.. we do not need this at the moment!) { global.kschwarz = 1; } else { global.kschwarz = 0; } Many thanks in advance

    Read the article

  • AS3 URLRequest in for Loop problem

    - by Adrian
    Hi guys, I read some data from a xml file, everything works great besides urls. I can't figure what's the problem with the "navigateURL" function or with the eventListener... on which square I click it opens the last url from the xml file for(var i:Number = 0; i <= gamesInput.game.length() -1; i++) { var square:square_mc = new square_mc(); //xml values var tGame_name:String = gamesInput.game.name.text()[i];//game name var tGame_id:Number = gamesInput.children()[i].attributes()[2].toXMLString();//game id var tGame_thumbnail:String = thumbPath + gamesInput.game.thumbnail.text()[i];//thumb path var tGame_url:String = gamesInput.game.url.text()[i];//game url addChild(square); square.tgname_txt.text = tGame_name; square.tgurl_txt.text = tGame_url; //load & attach game thumb var getThumb:URLRequest = new URLRequest(tGame_thumbnail); var loadThumb:Loader = new Loader(); loadThumb.load(getThumb); square.addChild(loadThumb); // square.y = squareY; square.x = squareX; squareX += square.width + 10; square.buttonMode = true; this.addEventListener(MouseEvent.CLICK, navigateURL); } function navigateURL(event:MouseEvent):void { var url:URLRequest = new URLRequest(tGame_url); navigateToURL(url, "_blank"); trace(tGame_url); } Many thanks!

    Read the article

  • C# iterator is executed twice when composing two IEnumerable methods

    - by achristoph
    I just started learning about C# iterator but got confused with the flow of the program after reading the output of the program. The foreach with uniqueVals seems to be executed twice. My understanding is that the first few lines up to the line before "Nums in Square: 3" should not be there. Can anyone help to explain why this happens? The output is: Unique: 1 Adding to uniqueVals: 1 Unique: 2 Adding to uniqueVals: 2 Unique: 2 Unique: 3 Adding to uniqueVals: 3 Nums in Square: 3 Unique: 1 Adding to uniqueVals: 1 Square: 1 Number returned from Unique: 1 Unique: 2 Adding to uniqueVals: 2 Square: 2 Number returned from Unique: 4 Unique: 2 Unique: 3 Adding to uniqueVals: 3 Square: 3 Number returned from Unique: 9 static class Program { public static IEnumerable<T> Unique<T>(IEnumerable<T> sequence) { Dictionary<T, T> uniqueVals = new Dictionary<T, T>(); foreach (T item in sequence) { Console.WriteLine("Unique: {0}", item); if (!uniqueVals.ContainsKey(item)) { Console.WriteLine("Adding to uniqueVals: {0}", item); uniqueVals.Add(item, item); yield return item; Console.WriteLine("After Unique yield: {0}", item); } } } public static IEnumerable<int> Square(IEnumerable<int> nums) { Console.WriteLine("Nums in Square: {0}", nums.Count()); foreach (int num in nums) { Console.WriteLine("Square: {0}", num); yield return num * num; Console.WriteLine("After Square yield: {0}", num); } } static void Main(string[] args) { var nums = new int[] { 1, 2, 2, 3 }; foreach (int num in Square(Unique(nums))) Console.WriteLine("Number returned from Unique: {0}", num); Console.Read(); } }

    Read the article

  • How to make smooth movements in OpenGL?

    - by thyrgle
    So this kind of on topic to my other OpenGL question (not my OpenGL ES question but OpenGL the desktop version). If you have someone press a key to move a square how do you make the square movement naturally and less jumpy but also at the same speed I have it now? This is my code for the glutKeyboardFunc() function: void handleKeypress(unsigned char key, int x, int y) { if (key == 'w') { for (int i = 0; i < 12; i++) { if (i == 1 || i == 7 || i == 10 || i == 4) { square[i] = square[i] + 1; } } glutPostRedisplay(); } if (key == 'd') { for (int i = 0; i < 12; i++) { if (i == 0 || i % 3 == 0) { square[i] = square[i] + 1; } } glutPostRedisplay(); } if (key == 's') { for (int i = 0; i < 12; i++) { if (i == 1 || i == 7 || i == 10 || i == 4) { square[i] = square[i] - 1; } } glutPostRedisplay(); } if (key == 'a') { for (int i = 0; i < 12; i++) { if (i == 0 || i % 3 == 0) { square[i] = square[i] - 1; } } glutPostRedisplay(); } } I'm sorry if this doesn't quite make sense I'll try to rephrase it in a better way if it doesn't make sense.

    Read the article

  • How to draw an unfilled square on top of a stream video using a mouse and track the object enclosed

    - by Haxed
    Hi, I am making an object tracking application. I have used Emgucv 2.1.0.0 to load a video file to a picturebox. I have also taken the video stream from a web camera. Now, I want to draw an unfilled square on the video stream using a mouse and then track the object enclosed by the unfilled square as the video continues to stream. This is what people have suggested so far:- (1) .NET Video overlay drawing(DirectX) - but this is for C++ users, the suggester said that there are .NET wrappers, but I had a hard time finding any. (2) DxLogo sample DxLogo – A sample application showing how to superimpose a logo on a data stream. It uses a capture device for the video source, and outputs the result to a file. Sadly, this does not use a mouse. (3) GDI+ and mouse handling - this area I do not have a clue. And for tracking the object in the square, I would appreciate if someone give me some research paper links to read. Any help as to using the mouse to draw on a video is greatly appreciated. Thank you for taking the time to read this. Many Thanks

    Read the article

  • Define a positive number to be isolated if none of the digits in its square are in its cube [closed]

    - by proglaxmi
    Define a positive number to be isolated if none of the digits in its square are in its cube. For example 163 is n isolated number because 69*69 = 26569 and 69*69*69 = 4330747 and the square does not contain any of the digits 0, 3, 4 and 7 which are the digits used in the cube. On the other hand 162 is not an isolated number because 162*162=26244 and 162*162*162 = 4251528 and the digits 2 and 4 which appear in the square are also in the cube. Write a function named isIsolated that returns 1 if its argument is an isolated number, it returns 0 if its not an isolated number and it returns -1 if it cannot determine whether it is isolated or not (see the note below). The function signature is: int isIsolated(long n) Note that the type of the input parameter is long. The maximum positive number that can be represented as a long is 63 bits long. This allows us to test numbers up to 2,097,151 because the cube of 2,097,151 can be represented as a long. However, the cube of 2,097,152 requires more than 63 bits to represent it and hence cannot be computed without extra effort. Therefore, your function should test if n is larger than 2,097,151 and return -1 if it is. If n is less than 1 your function should also return -1. Hint: n % 10 is the rightmost digit of n, n = n/10 shifts the digits of n one place to the right. The first 10 isolated numbers are N n*n n*n*n 2 4 8 3 9 27 8 64 512 9 81 729 14 196 2744 24 576 13824 28 784 21952 34 1156 39304 58 3364 195112 63 3969 250047

    Read the article

  • Technical differences between square and hexagon for a grid?

    - by Marlon Dias
    I'm developing a 2D city-building game and trying to decide on the type of grid. There will be vehicles, so the unit movement is important too. I know there are visual differences for using Squares or Hexagons, what I want know is: What are the issues for programming each type of grid regarding implementation and performance? Is there a tradeoff or specific benefit for using one of them in a game context?

    Read the article

  • How can I create a square 10x10 grid using nested for loops in Java? [migrated]

    - by help
    I'm trying to create a 10x10 grid using for loops in Java. I'm able to create rows going up and down but not repeating. for(int i = 1; i < temperatures.length; i++) { temperatures[i] = (temperatures[i-1] + 12) / 2; //takes average of 12 and previous temp } } public void paint(Graphics g) { for(int y = 1; y < 9; y++) { g.setColor(Color.black); g.drawRect(10, 10, 10, 10); g.drawRect(10, 10, 10, 20); g.drawRect(10, 10, 10, 30); g.drawRect(10, 10, 10, 40); g.drawRect(10, 10, 10, 50); g.drawRect(10, 10, 10, 60); g.drawRect(10, 10, 10, 70); g.drawRect(10, 10, 10, 80); g.drawRect(10, 10, 10, 90); g.drawRect(10, 10, 10, 100); for(int x = 1; x < 9; x++) { g.setColor(Color.black); g.drawRect(10, 10, 10, 10); g.drawRect(10, 10, 20, 10); g.drawRect(10, 10, 30, 10); g.drawRect(10, 10, 40, 10); g.drawRect(10, 10, 50, 10); g.drawRect(10, 10, 60, 10); g.drawRect(10, 10, 70, 10); g.drawRect(10, 10, 80, 10); g.drawRect(10, 10, 90, 10); g.drawRect(10, 10, 100, 10); } } } }

    Read the article

  • Why are textures always square powers of two? What if they aren't?

    - by Keavon
    Why are the resolution of textures in games always a power of two (128x128, 256x256, 512x512, 1024x1024, etc.)? Wouldn't it be smart to save on the game's file size and make the texture exactly fit the UV unwrapped model? What would happen if there was a texture that was not a power of two? Would it be incorrect to have a texture be something like 256x512, or 512x1024? Or would this cause the problems that non-power-of-two textures may cause?

    Read the article

  • Why is my primitive xna square not drawn/shown?

    - by Mech0z
    I have made this class to draw a rectangle, but I cant get it to be drawn, I have no issues displaying a 3d model created in 3dmax, but shown these primitives seems much harder I use this to create it board = new Board(Vector3.Zero, 1000, 1000, Color.Yellow); And here is the implementation using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Shapes; using Quadro.Models; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace Quadro { public class Board : IGraphicObject { //Private Fields private Vector3 modelPosition; private BasicEffect effect; private VertexPositionColor[] vertices; private Matrix rotationMatrix; private GraphicsDevice graphicsDevice; private Matrix cameraProjection; //Constructor public Board(Vector3 position, float length, float width, Color color) { var _color = color; vertices = new VertexPositionColor[6]; vertices[0].Position = new Vector3(position.X, position.Y, position.Z); vertices[1].Position = new Vector3(position.X, position.Y + width, position.Z); vertices[2].Position = new Vector3(position.X + length, position.Y, position.Z); vertices[3].Position = new Vector3(position.X + length, position.Y, position.Z); vertices[4].Position = new Vector3(position.X, position.Y + width, position.Z); vertices[5].Position = new Vector3(position.X + length, position.Y + width, position.Z); for(int i = 0; i < vertices.Length; i++) { vertices[i].Color = color; } initFields(); } private void initFields() { graphicsDevice = SharedGraphicsDeviceManager.Current.GraphicsDevice; effect = new BasicEffect(graphicsDevice); modelPosition = Vector3.Zero; float screenWidth = (float)graphicsDevice.Viewport.Width; float screenHeight = (float)graphicsDevice.Viewport.Height; float aspectRatio = screenWidth / screenHeight; this.cameraProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f); this.rotationMatrix = Matrix.Identity; } //Public Methods public void Update(GameTimerEventArgs e) { } public void Draw(Vector3 cameraPosition, GameTimerEventArgs e) { Matrix cameraView = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); effect.World = rotationMatrix * Matrix.CreateTranslation(modelPosition); effect.View = cameraView; effect.Projection = cameraProjection; graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 2, VertexPositionColor.VertexDeclaration); } } public void Rotate(Matrix rotationMatrix) { this.rotationMatrix = rotationMatrix; } public void Move(Vector3 moveVector) { this.modelPosition += moveVector; } } }

    Read the article

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