2d

Click detection in a 2D isometric grid?

不打扰是莪最后的温柔 提交于 2019-12-05 21:32:58
I've been doing web development for years now and I'm slowly getting myself involved with game development and for my current project I've got this isometric map, where I need to use an algorithm to detect which field is being clicked on. This is all in the browser with Javascript by the way. The map It looks like this and I've added some numbers to show you the structure of the fields (tiles) and their IDs. All the fields have a center point (array of x,y) which the four corners are based on when drawn. As you can see it's not a diamond shape, but a zig-zag map and there's no angle (top-down

Change size of Android custom SurfaceView

╄→尐↘猪︶ㄣ 提交于 2019-12-05 18:46:11
I'm trying to create a 2D game engine for an Android app. I've followed this tutorial , which works fine for creating a full screen display, but I don't want that. I want to make my view take the top 2/3 (or whatever) of the screen, and fill the bottom third with standard Android widgets (buttons, text entry, etc.). I cannot get this to work. The best I can get is a blank white screen. I've tried many permutations, including using an outer LinerLayout, then embedding the custom SurfaceView inside a nested RelativeLayout, and putting the Android widgets in a nested LinearLayout, and it doesn't

fftw c2c: missing symmetry in transformed real data

故事扮演 提交于 2019-12-05 18:26:05
recently I faced some problems concerning the use of fftw and it's c2c transformation (see: 3d c2c fft with fftw library ). As I located my problems in the use of the fftw lib I created a new Question in order to discus this situation in a more concrete way. Since I am doing a complex to complex transform with real data my transformed data in fourier space is supposed to be symmetric: F[n] = con(F[N-n]) Now I did some transformations with small blocks of test-data to check the transformed data for this symmetry. For 1D transform at every things worked as expected, but for higher dimensions I

2D vector modelling for game development

大城市里の小女人 提交于 2019-12-05 17:43:05
问题 Making my Asteroids clone (in C) I've rather fallen in love with vector-based entities, but I've simply coded them in as x,y-point arrays. That's been fine for something like Asteroids, but what should I do if I want to make more complex 2D models? I note that there is an awful lot of 3D modelling software out there, as well as ample tutorials and help on importing 3D models into one's C/C++ program for use with Open GL. However I'm rather more interested in creating 2D vector-based models

AngularJs ng-repeat 2D array in table, each subarray one column

北城余情 提交于 2019-12-05 15:30:36
I have an array and I need to put that array in table. $scope.testArr=[ {'first':[ { 'value':'1_1', 'rolle':'one1' }, { 'value':'2_1', 'rolle':'two1' }, { 'value':'3_1', 'rolle':'three1'} ] }, {'second': [ { 'value':'1_2', 'rolle':'one2' }, { 'value':'2_2', 'rolle':'two2' }, { 'value':'3_2', 'rolle':'three2' } ] } ]; Resulting table should have 4 columns, each subarray should be one(or two) column(s). Like this: one1 | 1_1 | one2 | 1-2 two1 | 2_1 | two2 | 2_2 three1|3_1 | three2|3_2 So far I got this. Its only the first subarray: <table> <tbody ng-repeat="test in testArr"> <tr ng-repeat="t1 in

Ray-Polygon Intersection Point on the surface of a sphere

拜拜、爱过 提交于 2019-12-05 12:41:15
I have a point (Lat/Lon) and a heading in degrees (true north) for which this point is traveling along. I have numerous stationary polygons (Points defined in Lat/Lon) which may or may not be convex. My question is, how do I calculate the closest intersection point, if any, with a polygon. I have seen several confusing posts about Ray Tracing but they seem to all relate to 3D when the Ray and Polygon are not on the same Plane and also the Polygons must be convex. sounds like you should be able to do a simple 2d line intersection... However I have worked with Lat/Long before and know that they

Collision detection in a 2D maze with thick walls

99封情书 提交于 2019-12-05 11:47:51
I have to make a game with Windows Forms for school. My game consists of a user having to get through a maze. I'm trying to prevent my user from going straight through the walls using collision detection, but am getting stuck because of the varying shape of the rectangles being used to represent walls. Here's an image of the game. This question may be similar to this one , however with my movement I believe that it is quite different, as I don't have a grid system or graphical map laid out. As you can see, the walls are fairly thick. Each wall is represented by a C# Rectangle, as is my Player

Normalized Device Coordinates

早过忘川 提交于 2019-12-05 11:06:14
I'm writing a library that deals with 2D graphical shapes. I'm just wondering why should my coordinate system range from [-1, 1] for both the x and y axis instead of [0, width] for x and [0, height] for y ? I went for the latter system because I felt it was straight forward to implement. From Jim Blinn's A Trip Down The Graphics Pipeline , p. 138. Let's start with what might at first seem the simplest transformation: normalized device coordinates to pixel space. The transform is s_x * X_NDC + d_x = X_pixel s_y * Y_NDC + d_y = Y_pixel A user/programmer does all screen design in NDC. There are

Bound CUDA texture reads zero

家住魔仙堡 提交于 2019-12-05 09:31:08
I try to read values from a texture and write them back to global memory. I am sure the writing part works, beause I can put constant values in the kernel and I can see them in the output: __global__ void bartureKernel( float* g_odata, int width, int height) { unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; if(x < width && y < height) { unsigned int idx = (y*width + x); g_odata[idx] = tex2D(texGrad, (float)x, (float)y).x; } } The texture I want to use is a 2D float texture with two channels, so I defined it as: texture<float2, 2,

Fast 2D illumination algorithm?

筅森魡賤 提交于 2019-12-05 09:22:49
We have a rectangular area with translucent walls and a few light sources.We are considering only the top view,so it is a 2D problem. We need to find the approximate lighting (signal strength)at each point of the area. We need to make the algorithm really fast. The brute force method was just too slow for our purposes. You can assume that all walls attenuate by same amount, even constant amount of attenuation is acceptable. The area would be at most 1000x1000, and there would not be more than 100 light sources. The light sources can have a range of approx. 50-100 units (they are not infinite).