2d

What is the best approach to 2D collision detection on the iPhone?

Been working on this problem of collision detection and there appears to be 3 main approaches I could take: Sprite and mask approach. (AND the overlap of the sprites and check for a non-zero number in the resulting sprite pixel data). Bounding circles, rectangles or polygons. (Create one or more shapes that enclose the sprites and do...

Does anyone know of a simple yet flexible 2d scene graph in c++?

I'm searching a simple 2d scene graph written in c++, possibly on top of OpenGL but that's not mandatory: the perfect thing would be the Cocos2d/Cocos2d-iphone scenegraph in c++. Do you know of any existing implementations? ...

How can you animate a sprite in SFML (C++)

Lets say I have 4 images and I want to use these 4 images to animate a character. The 4 images represent the character walking. I want the animation to repeat itself as long as I press the key to move but to stop right when I unpress it. It doesn't need to be SFML specific if you don't know it, just basic theory would really help me....

How do i tint an image with HTML5 Canvas ?

My question is, what is the best way to tint an image that is drawn using the drawImage method. The target useage for this is advanced 2d particle-effects (game development) where particles change colors over time etc. I am not asking how to tint the whole canvas, only the current image i am about to draw. I have concluded that the glob...

Draw a semicircle / half circle in WPF / C#

Hello, I need to draw a semicircle / half circle in WPF. Any idea how to do that? Thanks for any hint! ...

php push 2d array into mysql

Hay All, I cant seem to get my head around this dispite the number to examples i read. Basically I have a 2d array and want to insert it into MySQL. The array contains a few strings. I cant get the following to work... $value = addslashes(serialize($temp3));//temp3 is my 2d array, do i need to use keys? (i am not at the moment) $query...

Creating a 2d matrix from an array (java)

I'm supposed to write a method that creates a 2d matrix from an array, for instance: ({1, 2, 3, 4}, 3) should return the matrix {{1, 2, 3}, {4}} public class Matrix { public static int[][]toM(int[] array, int a) { int[][]matrix = new int [(array.length + a- 1)/ a][a]; for (int i = 0; i < array.length; i++){ int value = a...

Java 2D graphics performance questions.

1) Is their any performance loss when making a new image with bitmask transparency, drawing just a few things on it then drawing it on top of another; versus drawing the same image in the same conditions, but with the background cleared to an opaque color ? 2) What is the importance of the performance loss when drawing multiple images v...

How to get path of stroke using opencv ?

I want to get path stroke from image using opencv. I know how to get contours but I need path of stroke (path that runs through the center of the stroke). Is it possible to get this in opencv ? ...

daynamic 2d array in c++ and memory leaks

Hi guys, i wrote this code, it runs ok, but when i check it under Valgrind it catches 2 problems, since i can not interpret valgrind's messages i will appreciate if anyone explain me more and tell me where is the problem!!! here is the code: #include <iostream> #define width 70000 #define height 10000 using namespace std; int main...

Accessing 2D array and passing string to label.text

Hi. I'm trying to create 2D array and initialize it with NSStrings. When I try to copy content of a cell from the array to a label.text, the application crashes. NSMutableArray *array = [NSMutableArray arrayWithCapacity:0]; [array addObject:[NSMutableArray arrayWithObjects: [NSArray arrayWithObjects: @"0-0", @"0-1",...

Python 2D list has weird behavor when trying to modify a single value...

Hi guys, So I am relatively new to Python and I am having trouble working with 2D Lists. Here's my code: data = [[None]*5]*5 data[0][0] = 'Cell A1' print data and here is the output (formatted for readability): [['Cell A1', None, None, None, None], ['Cell A1', None, None, None, None], ['Cell A1', None, None, None, None], ['Cell ...

Drawing an image in Java, slow as hell on a netbook.

In follow-up to my previous questions (especially this one : http://stackoverflow.com/questions/2684123/java-volatileimage-slower-than-bufferedimage), i have noticed that simply drawing an Image (it doesn't matter if it's buffered or volatile, since the computer has no accelerated memory*, and tests shows it's doesn't change anything), t...

optimize 2D array in C++

I'm dealing with a 2D array with the following characteristics: const int cols = 500; const int rows = 100; int arr[rows][cols]; I access array arr in the following manner to do some work: for(int k = 0; k < T; ++k) { // for each trainee myscore[k] = 0; for(int i = 0; i < cols; ++i) { // for each sample for(int j = 0; j <...

C++ 2d Array Class Function Call Help

I hope this question takes a simple fix, and I am just missing something very small. I am in my second semester of C++ in college, and we are just getting into OOP. This is my first OOP program, and it is causing me a little problem. Here are the errors I am getting: Member function must be called or its address taken in function displ...

Polygonal gradients with OpenGL

I'm wondering how I could create a gradient wuth multiple stops and a direction if I'm making polygons. Right now I'm creating gradients by changing the color of the verticies but this is limiting. Is there another way to do this? Thanks ...

Android: 2D. OpenGl or android.graphics?

I'm working with my friend on our first Android game. Basic idea is that every frame of the game the whole surface is redrawn (1 large bitmap) in 2 steps: Background with some static image (PNG) wipes out previous frame Then it is sprinkled all over with large number of particles which produces effect of soapy bubbles where there's a p...

C#: 2D sub-Tile Line intersection

Hi, I have some problems getting an algorithm for my game to work and hope someone here can help me. Google didn't seem to be a good help as most solutions just work for full tiles. In the game units can occupy different positions inside a tile, i.e. they can be in the upper left corner, center, bottom right, ... position of tile (2/3),...

XNA Track rotated pixel positions

Hi, Im making a game in xna where a tank has to move over a landscape. I need to be able find the bottom of the tank when it is rotated so I can make it move up and down as the player goes over the landscape. for example if i have a sprite at with its top left corner at 400,300 and i rotate it around its center by 45 degrees around its...

How to create a 2D map of room by a few images/movie frames ?

I'd like to create a simple 2D map of a room by getting pictures (ceiling) of all directions (360° - e.g. movie frames), recognize the walls by edge detection, delete other unwanted objects, concat the images at the right position (cf. walls, panorama) and finally create the approximate 2D map (looking on it from above). Getting the scal...