2d

How can i convert x-y position to tile x-y for isometric tile?

夙愿已清 提交于 2019-11-30 16:21:23
I can draw my map according to the formula on Drawing Isometric game worlds . But how can i find the x-y of one tile according to it's position on map layer div? For being clear, my tile's left style is 1036px and top style is 865px. According to those css properties how can find the tile's x and y position according to map? Tile width is 200 and height is 100. Many Thanks. My javascript code is like that: this.drawTiles = function(min_x, max_x, min_y, max_y) { if (min_x < 0) min_x = 0; if (min_y < 0) min_y = 0; if (max_x < 0) max_x = thisObj.MAXSIZE; if (max_y < 0) max_y = thisObj.MAXSIZE; if

How can i convert x-y position to tile x-y for isometric tile?

守給你的承諾、 提交于 2019-11-30 16:11:42
问题 I can draw my map according to the formula on Drawing Isometric game worlds . But how can i find the x-y of one tile according to it's position on map layer div? For being clear, my tile's left style is 1036px and top style is 865px. According to those css properties how can find the tile's x and y position according to map? Tile width is 200 and height is 100. Many Thanks. My javascript code is like that: this.drawTiles = function(min_x, max_x, min_y, max_y) { if (min_x < 0) min_x = 0; if

Reflection? How do I do it?

老子叫甜甜 提交于 2019-11-30 15:51:37
问题 This is over my head, can someone explain it to me better? http://mathworld.wolfram.com/Reflection.html I'm making a 2d breakout fighting game, so I need the ball to be able to reflect when it hits a wall, paddle, or enemy (or a enemy hits it). all their formula's are like: x_1^'-x_0=v-2(v·n^^)n^^. And I can't fallow that. (What does ' mean or x_0? or ^^?) 回答1: The formula for reflection is easier to understand if you think to the geometric meaning of the operation of "dot product". The dot

Reflection? How do I do it?

女生的网名这么多〃 提交于 2019-11-30 15:41:20
This is over my head, can someone explain it to me better? http://mathworld.wolfram.com/Reflection.html I'm making a 2d breakout fighting game, so I need the ball to be able to reflect when it hits a wall, paddle, or enemy (or a enemy hits it). all their formula's are like: x_1^'-x_0=v-2(v·n^^)n^^. And I can't fallow that. (What does ' mean or x_0? or ^^?) The formula for reflection is easier to understand if you think to the geometric meaning of the operation of "dot product". The dot product between two 3d vectors is mathematically defined as <a, b> = ax*bx + ay*by + az*bz but it has a nice

Why does use of pens with dash patterns cause huge (!) performance degredation in WPF custom 2D drawing?

妖精的绣舞 提交于 2019-11-30 15:26:49
Hope anyone can shed light on this so I can use pens with dash patterns? I am writing a scrollable chart (a Panel inside ScrollViewer that implements IScrollInfo ) in WPF using DrawingVisual 's DataContext.Draw X . I have several thousand DrawingVisual s that get scrolled by using TranslateTransform on the Panel that hosts them. I implemented a grid by placing a Panel on top of it and drawing simple horizontal lines from one edge to the other using DataContext.DrawLine(pen, new Point(0, y), new Point(widthOfPanel, y)); //(note: these lines are always static, they never move). The scroll

How to make a wave warp effect in shader?

五迷三道 提交于 2019-11-30 15:13:43
问题 I want to make a wave warp effect like this: But I can only create the normal sine wave. Here is my fragment shader: precision mediump float; varying vec2 v_texCoord; uniform sampler2D s_baseMap; vec2 SineWave( vec2 p ){ float pi = 3.14159; float A = 0.15; float w = 10.0 * pi; float t = 30.0*pi/180.0; float y = sin( w*p.x + t) * A; return vec2(p.x, p.y+y);  } void main(){ vec2 p = v_texCoord; vec2 uv = SineWave( p ); vec4 tcolor = texture2D(s_baseMap, uv); gl_FragColor = tcolor; } and result

Drawing an iso line of a 2D implicit scalar field

假装没事ソ 提交于 2019-11-30 15:13:21
I have an implicit scalar field defined in 2D, for every point in 2D I can make it compute an exact scalar value but its a somewhat complex computation. I would like to draw an iso-line of that surface, say the line of the '0' value. The function itself is continuous but the '0' iso-line can have multiple continuous instances and it is not guaranteed that all of them are connected. Calculating the value for each pixel is not an option because that would take too much time - in the order of a few seconds and this needs to be as real time as possible. What I'm currently using is a recursive

Win32 clipboard and alpha channel images

删除回忆录丶 提交于 2019-11-30 15:03:19
问题 My application should be able to copy 32-bit images (RGB + alpha channel) to the clipboard and paste these images from the clipboard. For this I plan to use CF_DIBV5 because the BITMAPV5HEADER structure has a field bV5AlphaMask . The problem is that there doesn't seem to be a consensus as to how exactly the image data should be stored in the clipboard. While doing some tests I found out that there are several differences betweeen the applications making it next to impossible to come up with a

Creating an 2D array using pointer/malloc, and then print it out [closed]

主宰稳场 提交于 2019-11-30 14:13:49
I am trying to write 2 functions, one to read the matrix (2D array) and other one to print it out. So far I have: /* Read a matrix: allocate space, read elements, return pointer. The number of rows and columns are given by the two arguments. */ double **read_matrix(int rows, int cols){ double **mat = (double **) malloc(sizeof(double *)*rows); int i=0; for(i=0; i<rows; i++){ /* Allocate array, store pointer */ mat[i] = (double *) malloc(sizeof(double)*cols); //what to do after?? return mat; } then the print matrix function, not sure if it is correct void print_matrix(int rows, int cols, double

Flipping a 2D Sprite Animation in Unity 2D

跟風遠走 提交于 2019-11-30 13:59:48
问题 I've got a quick question regarding 2D Sprite animations that I haven't been able to find specifically answered anywhere: I have a sprite with walk animations to the right. However, I obviously want to flip the animation to the left when he walks left (2D side-scroller). I can easily flip the sprite itself, using transform.localscale.x , however, that only flips the sprite. Not the animation clip. (This no longer happens in Unity) So, while the sprite flips, the minute the animation clip