2d

Having the Background or Camera “Scroll” based on charcter position

妖精的绣舞 提交于 2019-11-30 00:04:23
问题 I'm working on an RPG game that has a Top-Down view. I want to load a picture into the background which is what the character is walking on, but so far I haven't figured out how to correctly have the background redraw so that it's "scrolling". Most of the examples I find are auto scrolling. I want the camera to remained centered at the character until you the background image reaches its boundaries, then the character will move without the image re-drawing in another position. 回答1: Your

Foreach and 2D Array in PHP

痴心易碎 提交于 2019-11-29 23:47:06
问题 $mainMenu['Home'][1] = '/mult/index.php'; $mainMenu['Map'][1] = '/mult/kar.php'; $mainMenu['MapA'][2] = '/mult/kara.php'; $mainMenu['MapB'][2] = '/mult/karb.php'; $mainMenu['Contact'][1] = '/mult/sni.php'; $mainMenu['Bla'][1] = '/mult/vid.php'; This is a menu, 1 indicates the main part, 2 indicates the sub-menu. Like: Home Map -MapA -MapB Contat Bla I know how to use foreach but as far as I see it is used in 1 dimensional arrays. What I have to do in the example above? 回答1: You would need to

Locating Bounding 2D Entities

狂风中的少年 提交于 2019-11-29 22:02:47
问题 Given a point and a set of arbitrary 2D entities (circles, polygons, lines, polylines, arcs, etc.), does anyone know of existing strategies to: Determine if the point is enclosed (bounded) by any combination of entities? I know that it is easy enough to do an 'inside' test on the closed shapes, but this won't always give me what I want - particularly with nested or intersecting shapes. Find the smallest (closest?) set of lines / entities that form a closed polygon around my point? (think of a

Most performant way to graph thousands of data points with WPF?

妖精的绣舞 提交于 2019-11-29 20:12:06
I have written a chart that displays financial data. Performance was good while I was drawing less than 10.000 points displayed as a connected line using PathGeometry together with PathFigure and LineSegment s. But now I need to display up to 100.000 points at the same time (without scrolling) and it's already very slow with 50.000 points. I was thinking of StreamGeometry , but I am not sure since it's basically the same as a PathGeometry stroring the information as byte stream. Does any one have an idea to make this much more performant or maybe someone has even done something similar already

2D Engines for Javascript [closed]

匆匆过客 提交于 2019-11-29 19:58:31
I'm attempting to build a tile-based game in javascript, using HTML5 canvas. There are -many- engines to choose from, such as; JawsJS GameJS Cocos2D MelonJS CraftyJS ImpactJS (commercial) ... and the list goes on and on. However, there does not seem to be one de facto standard among all these different implementations. Essentially I am looking for the 'jQuery' of javascript game engines. One that is backed by a (larger) community, has excellent documentation and is actively maintained. Most of these just seem like one-man projects to me. To phrase this into a real question; what is the de

Generate 2D cross-section polygon from 3D mesh

那年仲夏 提交于 2019-11-29 18:08:43
问题 I'm writing a game which uses 3D models to draw a scene (top-down orthographic projection), but a 2D physics engine to calculate response to collisions, etc. I have a few 3D assets for which I'd like to be able to automatically generate a hitbox by 'slicing' the 3D mesh with the X-Y plane and creating a polygon from the resultant edges. Google is failing me on this one (and not much helpful material on SO either). Suggestions? The meshes I'm dealing with will be simplified versions of the

Three.js - 2D object in 3D space (by Vertices)

一世执手 提交于 2019-11-29 18:08:20
I have a problem: I have an array of 3D Points. How to draw 2D, flat object given by Vertices in 3D Space? I want to draw line from Points[0] to Points[1], from Points[1] to Points[2] etc… Now I have a following solution: var geometry = new THREE.BufferGeometry(); var vertices = faceToTriangles( VerticesArray ); // my function var uvs = new Float32Array([ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0 ]); geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); geometry.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) ); var material = new THREE

Matplotlib Save imshow array

大城市里の小女人 提交于 2019-11-29 17:59:26
I was wondering if it were at all possible to save the array of an imshow function? What do I mean by this? Well, I have a 2d array with unique values. I would like to see that represented in colour, so I naturally would use the imshow function. I understand that the imshow function applies a colormap to my array and then displays that. I would like to be able to get the array that matplotlib uses to show my original 2d array in colour. Can this be done? You can actually just get the color maping with out imshow data_ = (data - np.min(data))/ (np.max(data) - np.min(data)) my_cmap = matplotlib

get width and height of JPanel outside of the class

一笑奈何 提交于 2019-11-29 17:42:43
So I created a simple simple simulation where squares are spawned randomly with random vectors and bounce of the edges of the window. I wanted it to take into account the window being resized. So that if I change the dimensions of the window from 600x600 to 1200x600 the squares will bounce of the new border rather than 600x600. I tried doing getWidth() getHeight() but it would return 0. So I put it in the pain() (since it gets called on window resize) method and saved the return values as local variables. But I cannot call getjpWidth() from the Rect class. So basically what I need is to get

Mouse hover canvas/shape

荒凉一梦 提交于 2019-11-29 17:35:30
I have this code on in Jquery. I would like to change the opacity percentage of the individual shapes on mouseover. I normaly don't have this kind of problems, but I don't know a lot about canvas... Any help/advice would be appreciate! Thanks in advance! var canvas = document.getElementById('canvas'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.canvas.addEventListener('mousemove', function(event){ var mouseX = event.clientX; var mouseY = event.clientY; var status = document.getElementById('status'); status.innerHTML = mouseX + " | " + mouseY; }); ctx.beginPath(); ctx.moveTo