Search Results

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

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

  • Calculating the rotational force of a 2D sprite

    - by Jon
    I am wondering if someone has an elegant way of calculating the following scenario. I have an object of (n) number of squares, random shapes, but we will pretend they are all rectangles. We are dealing with no gravity, so consider the object in space, from a top down perspective. I am applying a force to the object at a specific square (as illustrated below). How do I calculate the rotational angle, based on the force being applied, at the location being applied. If applied in the center square, it would go straight. How should it behave the further I move from the center? How do I calculate the rotational velocity?

    Read the article

  • What is the standard for naming variables and why?

    - by P.Brian.Mackey
    I'm going through some training on objective-c. The trainer suggests setting single character parameter names. The .NET developer in me is crying. Is this truly the convention? Why? For example, @interface Square : NSObject { int size; } -(void)setSize: (int)s; I've seen developers using underscores int _size to declar variables (I think people call the variable declared in @interface ivar for some unknown reason). Personally, I prefer to use descriptive names. E.G. @interface Square : NSObject { int Size; } -(void)setSize: (int)size; C, like C# is case sensitive. So why don't we use the same convention as .NET?

    Read the article

  • Theme is broken in some places

    - by RidiculeSwarm
    I am using a computer that started out on 11.10. I have since updated it several times, and installed and used a great number of WMs (Unity, XFCE, Gnome, KDE, Cinnamon). I am not sure how, but somewhere along the way (probably when I upgraded to Ubuntu 13.04), some parts of my desktop theme were broken. I have tried switching themes and installing new themes, but that does not work. Neither did a removal of (and log out/login cycle) the ~/.config/dconf folder work. Specifically: on several menus, the central part of a button icon is a "grey square" that doesn't fit in with the theme (picture below). the window and desktop right click menus looks ugly. The same kind of grey field covers the items, and the square checkbox looks weird (just filled with a uniform blue). The separator is a thick line that looks out of place. It seems to be a similar problem to that of window buttons (picture below).

    Read the article

  • Tiling Problem Solutions for Various Size "Dominoes"

    - by user67081
    I've got an interesting tiling problem, I have a large square image (size 128k so 131072 squares) with dimensons 256x512... I want to fill this image with certain grain types (a 1x1 tile, a 1x2 strip, a 2x1 strip, and 2x2 square) and have no overlap, no holes, and no extension past the image boundary. Given some probability for each of these grain types, a list of the number required to be placed is generated for each. Obviously an iterative/brute force method doesn't work well here if we just randomly place the pieces, instead a certain algorithm is required. 1) all 2x2 square grains are randomly placed until exhaustion. 2) 1x2 and 2x1 grains are randomly placed alternatively until exhaustion 3) the remaining 1x1 tiles are placed to fill in all holes. It turns out this algorithm works pretty well for some cases and has no problem filling the entire image, however as you might guess, increasing the probability (and thus number) of 1x2 and 2x1 grains eventually causes the placement to stall (since there are too many holes created by the strips and not all them can be placed). My approach to this solution has been as follows: 1) Create a mini-image of size 8x8 or 16x16. 2) Fill this image randomly and following the algorithm specified above so that the desired probability of the entire image is realized in the mini-image. 3) Create N of these mini-images and then randomly successively place them in the large image. Unfortunately there are some downfalls to this simplification. 1) given the small size of the mini-images, nailing an exact probability for the entire image is not possible. Example if I want p(2x1)=P(1x2)=0.4, the mini image may only give 0.41 as the closes probability. 2) The mini-images create a pseudo boundary where no overlaps occur which isn't really descriptive of the model this is being used for. 3) There is only a fixed number of mini-images so i'm not sure how random this really is. I'm really just looking to brainstorm about possible solutions to this. My main concern is really to nail down closer probabilities, now one might suggest I just increase the mini-image size. Well I have, and it turns out that in certain cases(p(1x2)=p(2x1)=0.5) the mini-image 16x16 isn't even iteratively solvable.. So it's pretty obvious how difficult it is to randomly solve this for anything greater than 8x8 sizes.. So I'd love to hear some ideas. Thanks

    Read the article

  • How to create a 2D map?

    - by Kaizer
    I'm new to game development and I want to try it out, like many others amongst us :) I need to create a gridmap. The map needs to be divided in squares. Each square represents a location. For example: x:10 - y:10 The width and height of the square should be able to be set. And offcourse also the amount of squared. I will develop in MVC .NET Can someone show me the right direction ? kind regards PS: Some nice tutorial links are always welcome :)

    Read the article

  • Maze not being random.

    - by Matt Habel
    Hey there, I am building a program that generates a maze so I can later translate the path to my graphical part. I have most of it working, however, every time you can just take the east and south routes, and you'll get to the end. Even if I set the width as high as 64, so the maze is 64*64, I'm able to choose those 2 options and get to the end every time. I really don't understand why it is doing that. The code is below, it's fairly easy to understand. import random width = 8 def check(x,y): """Figures out the directions that Gen can move while""" if x-1 == -1: maze[x][y][3] = 0 if x+1 == width + 1: maze[x][y][1] = 0 if y+1 == width + 1: maze[x][y][2] = 0 if y-1 == -1: maze[x][y][0] = 0 if x + 1 in range(0,width) and visited[x+1][y] == False: maze[x][y][1] = 2 if x - 1 in range(0,width) and visited[x-1][y] == False: maze[x][y][3] = 2 if y + 1 in range(0,width) and visited[x][y+1] == False: maze[x][y][2] = 2 if y - 1 in range(0,width) and visited[x][y-1] == False: maze[x][y][0] = 2 def possibleDirs(x,y): """Figures out the ways that the person can move in each square""" dirs = [] walls = maze[x][y] if walls[0] == 1: dirs.append('n') if walls[1] == 1: dirs.append('e') if walls[2] == 1: dirs.append('s') if walls[3] == 1: dirs.append('w') return dirs def Gen(x,y): """Generates the maze using a depth-first search and recursive backtracking.""" visited[x][y] = True dirs = [] check(x,y) if maze[x][y][0] == 2: dirs.append(0) if maze[x][y][1] == 2: dirs.append(1) if maze[x][y][2] == 2: dirs.append(2) if maze[x][y][3] == 2: dirs.append(3) print dirs if len(dirs): #Randonly selects a derection for the current square to move past.append(current[:]) pos = random.choice(dirs) maze[x][y][pos] = 1 if pos == 0: current[1] -= 1 maze[x][y-1][2] = 1 if pos == 1: current[0] += 1 maze[x+1][y][3] = 1 if pos == 2: current[1] += 1 maze[x][y+1][0] = 1 if pos == 3: current[0] -= 1 maze[x-1][y][1] = 1 else: #If there's nowhere to go, go back one square lastPlace = past.pop() current[0] = lastPlace[0] current[1] = lastPlace[1] #Build the initial values for the maze to be replaced later maze = [] visited = [] past = [] #Generate empty 2d list with a value for each of the xy coordinates for i in range(0,width): maze.append([]) for q in range(0, width): maze[i].append([]) for n in range(0, 4): maze[i][q].append(4) #Makes a list of falses for all the non visited places for x in range(0, width): visited.append([]) for y in range(0, width): visited[x].append(False) dirs = [] print dirs current = [0,0] #Generates the maze so every single square has been filled. I'm not sure how this works, as it is possible to only go south and east to get to the final position. while current != [width-1, width-1]: Gen(current[0], current[1]) #Getting the ways the person can move in each square for i in range(0,width): dirs.append([]) for n in range(0,width): dirs[i].append([]) dirs[i][n] = possibleDirs(i,n) print dirs print visited pos = [0,0] #The user input part of the maze while pos != [width - 1, width - 1]: dirs = [] print pos if maze[pos[0]][pos[1]][0] == 1: dirs.append('n') if maze[pos[0]][pos[1]][1] == 1: dirs.append('e') if maze[pos[0]][pos[1]][2] == 1: dirs.append('s') if maze[pos[0]][pos[1]][3] == 1: dirs.append('w') print dirs path = raw_input("What direction do you want to go: ") if path not in dirs: print "You can't go that way!" continue elif path.lower() == 'n': pos[1] -= 1 elif path.lower() == 'e': pos[0] += 1 elif path.lower() == 's': pos[1] += 1 elif path.lower() == 'w': pos[0] -= 1 print"Good job!" As you can see, I think the problem is at the point where I generate the maze, however, when I just have it go until the current point is at the end, it doesn't fill every maze and is usually just one straight path. Thanks for helping. Update: I have changed the for loop that generates the maze to a simple while loop and it seems to work much better. It seems that when the for loop ran, it didn't go recursively, however, in the while loop it's perfectly fine. However, now all the squares do not fill out.

    Read the article

  • Android - determine specific locations (X,Y coordinates) on a Bitmap on different resolutions?

    - by Mike
    My app that I am trying to create is a board game. It will have one bitmap as the board and pieces that will move to different locations on the board. The general design of the board is square, has a certain number of columns and rows and has a border for looks. Think of a chess board or scrabble board. Before using bitmaps, I first created the board and boarder by manually drawing it - drawLine & drawRect. I decided how many pixels in width the border would be based on the screen width and height passed in on "onSizeChanged". The remaining screen I divided by the number of columns or rows I needed. For examples sake, let's say the screen dimensions are 102 x 102. I may have chosen to set the border at 1 and set the number of rows & columns at 10. That would leave 100 x 100 left (reduced by two to account for the top & bottom border, as well as left/right border). Then with columns and rows set to 10, that would leave 10 pixels left for both height and width. No matter what screen size is passed in, I store exactly how many pixels in width the boarder is and the height & width of each square on the board. I know exactly what location on the screen to move the pieces to based on a simple formula and I know exactly what cell a user touched to make a move. Now how does that work with bitmaps? Meaning, if I create 3 different background bitmaps, once for each density, won't they still be resized to fit each devices screen resolution, because from what I read there were not just 3 screen resolutions, but 5 and now with tablets - even more. If I or Android scales the bitmaps up or down to fit the current devices screen size, how will I know how wide the border is scaled to and the dimensions of each square in order to figure out where to move a piece or calculate where a player touched. So far the examples I have looked at just show how to scale the overall bitmap and get the overall bitmaps width and height. But, I don't see how to tell how many pixels wide or tall each part of the board would be after it was scaled. When I draw each line and rectangle myself based in the screen dimensions from onSizeChanged, I always know these dimensions. If anyone has any sample code or a URL to point me to that I can a read about this with bitmaps, I would appreciate it. Thanks, --Mike BTW, here is some sample code (very simplified) on how I know the dimensions of my game board (border and squares) no matter the screen size. Now I just need to know how to do this with the board as a bitmap that gets scaled to any screen size. @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { intScreenWidth = w; intScreenHeight = h; // Set Border width - my real code changes this value based on the dimensions of w // and h that are passed in. In other words bigger screens get a slightly larger // border. intOuterBorder = 1; /** Reserve part of the board for the boardgame and part for player controls & score My real code forces this to be square, but this is good enough to get the point across. **/ floatBoardHeight = intScreenHeight / 4 * 3; // My real code actually causes floatCellWidth and floatCellHeight to // be equal (Square). floatCellWidth = (intScreenWidth - intOuterBorder * 2 ) / intNumColumns; floatCellHeight = (floatBoardHeight - intOuterBorder * 2) / intNumRows; super.onSizeChanged(w, h, oldw, oldh); }

    Read the article

  • Writing preprocessor directives to get string

    - by Dave18
    Can you write preprocessor directives to return you a std::string or char*? For example: In case of integers: #define square(x) (x*x) int main() { int x = square(5); } I'm looking to do the same but with strings like a switch-case pattern. if pass 1 it should return "One" and 2 for "Two" so on..

    Read the article

  • Illegal forward reference

    - by Troy
    When trying to declare a static array in my program I receive a static forward reference error, i'm not sure what I am doing wrong here... static Square fieldGrid [ ] [ ] = new Square [ ROWSIZE ] [ COLSIZE ]; this is what I am using.

    Read the article

  • Winforms Checkbox : CheckState property Indeterminate renders differently

    - by joedotnot
    In C# environment, setting a checkbox's CheckState property to Indeterminate displays a "green square" inside the checkbox. In VB environment, this displays as a "grayed out check" (which is less intuitive, even for "dummy" users). How do i make Indeterminate state look like a "green square" in VB.NET ? Btw, i am using VS2008, Winforms 2.0. (Btw2: I tried to create two tags CheckState Indeterminate, which is more appropriate to my question, but disallowed by StackOverflow due to points!)

    Read the article

  • white in the black

    - by gcc
    how can i detect white image surrounded by black image take input 000 000 000 000 000 255 255 255 000 000 255 255 255 000 000 255 255 255 000 000 000 000 000 000 000 make it simpliest form 0 0 0 0 0 2 2 2 0 0 2 2 2 0 0 2 2 2 0 0 that step i couldnot did then search for coordinate of leading entry x,y then determine are there any detection if not print no detection else go another step find length of the square and how can calculate length and widht of the square

    Read the article

  • shape fitting - gis

    - by csetzkorn
    Hi, Let us say I have two shapes. One is a polygon and the other a square. Each shape consists of lines which two points (a latitude/logitude pair). I would like to determine the degree to which the square is within the polygon (percentages 0 ... 100). Is this possible? Any pointers to relevant algorithms would be very much appreciated. Thanks. Christian

    Read the article

  • In blackberry Rounded Border of Manager display as a squre.

    - by Sachin
    Hello everybody I have created a table layout manager by extending a manager. Every thing is working fine but when I tried to create and set rounded border by using BorderFactory it is actually displaying a square instead of rounded square, please help me by send your valuable suggestions. Even though I have tried to add that border to a custom label field that also behave in a same manner.

    Read the article

  • Removing the transparency from image while keeping the actual image

    - by KPL
    Hello people, I have three images,and , they are not square or rectangular in shape. They are just like face of anyone. So, basically, my images are in the size 196x196 or anything like that, but complete square or rectangle with the face in the middle and transperant background in the rest of the portion. Now, I want to remove the transperant background too and just keep the faces. Don't know if this is possible and mind you, this isn't a programming question.

    Read the article

  • Snake App on Xcode

    - by Will Rose
    How do I make one square on a screen lead about 6 with more to be added as the game progresses and how do I control the direction of the lead square with buttons? I basically want to know how to make a "Snake" app for the iPhone, iPod and iPad Please answer!!!!!!

    Read the article

  • Removing the transperancy from image while keeping the actual image

    - by KPL
    Hello people, I have three images,and , they are not square or rectangular in shape. They are just like face of anyone. So,basically, my images are in the size 196x196 or anything like that, but complete square or rectangle with the face in the middle and transperant background in the rest of the portion. Now, I want to remove the transperant background too and just keep the faces. Don't know if this is possible and mind you, this isn't a programming question.

    Read the article

  • Finding a simple object in a low-quality image

    - by Ramon Snir
    Hi, I want to do this thing in C# (or any other .NET language), not sure how: I have an image I captured from webcam and I want to find a specific simple object in it (let's say a red circle with a black square in it). The red circle can be a bit different from time to time (because of shadows) and the square might be also a bit brighter sometimes and even rotated a bit. Please help me!

    Read the article

  • string function workout in php

    - by Karthik
    I have the string like this, $inp1 = "3 doses at 0[0,0], 1-2 and 6 Month[6,1] [3,2])"; in this internally, going to take the values of square bracket. How can i take this values in the square bracket? any function is there to return the string like this [0,0] [6,1] [3,2] Thanks in advance for help.

    Read the article

  • How can I move an object left and right with silverlight?

    - by Craig
    I currently have two buttons that say left and right, and I want them to move a square object left and right respectively. What its currently doing when i press left is moving the square to the left, and if I press left again, it resets from the center and goes left. I want it so that when I press left, from where ever it is currently to go left and right. I know the principle is something like get current objects position and add the canvas coordinates respectively but how do I do this?

    Read the article

  • Flex game to build a building

    - by johnraja
    I want to develop a game in flex to build a building. In canvas i want to spirit into number of squares and place a different type of building in that square(Using click and drag). If small building means its take two square and big building means its take four squares. Please anybody help me

    Read the article

  • Beginner iPhone Controller Question

    - by Besha
    I have a view that only has a button UIButton. First time clicking the button will draw a square above the button and the second time will replace the square with a circle. I need some help on writing the controller code. Please guide me to the right path. Thanks

    Read the article

  • Scaling vectors from a center point?

    - by user146780
    I'm trying to figure out if I have points that make for example a square: * * * * and let's say I know the center of this square. I want a formula that will make it for eample twice its size but from the center * * * * * * * * Therefore the new shape is twice as large and from the center of the polygon. It has to work for any shape not just squares. I'm looking more for the theory behind it more than the implementation. Thanks

    Read the article

  • Cleaning up images in matlab

    - by Taegeuk
    How would you use Matlab to do the following? I've got fuzzy square images about the same size and then inside the fuzzy square there's smaller fuzzy squares, and I want to clean up the larger squares - not the smaller ones - so that they are no longer blurred. It looks like I'd have to make some type of morphological mask, but I'm not sure how in this case.

    Read the article

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