2d

Best way to detect collision between sprites?

断了今生、忘了曾经 提交于 2019-11-29 05:12:16
Whats the best way to detect collisions in a 2d game sprites? I am currently working in allegro and G++ There are a plethora of ways to detect collision detection. The methods you use will be slightly altered if depending on if your using a 2d or 3d environment. Also remember when instituting a collision detection system, to take into account any physics you may want to implement in the game (needed for most descent 3d games) in order to enhance the reality of it. The short version is to use bounding boxes. Or in other words, make each entity in the world a box, then check if each of the

Finding closest non-black pixel in an image fast

笑着哭i 提交于 2019-11-29 04:29:37
I have a 2D image randomly and sparsely scattered with pixels. given a point on the image, I need to find the distance to the closest pixel that is not in the background color (black). What is the fastest way to do this? The only method I could come up with is building a kd-tree for the pixels. but I would really want to avoid such expensive preprocessing. also, it seems that a kd-tree gives me more than I need. I only need the distance to something and I don't care about what this something is. As Pyro says, search the perimeter of a square that you keep moving out one pixel at a time from

Java 2D Game engine for tile-based Game

南笙酒味 提交于 2019-11-29 03:51:15
Can anyone recommend a good Java game engine for developing simple tile-based games? I'm looking for an engine that will allow me to build maps using something like Tiled www.mapeditor.org Slick is exactly what I'm looking for, slick.cokeandcode.com but I can't get it working on Vista-64. The best I can manage is:Can't load IA 32-bit .dll on a AMD 64-bit platform (and this after downloading the latest LWJGL version). Can anyone suggest something similar that will run on 64-bit vista? I'd recommend purchasing the book "Developing Games in Java" by David Brackeen, it includes a tile-based game

How do I use OpenGL 3.x VBOs to render a dynamic world?

两盒软妹~` 提交于 2019-11-29 03:07:45
问题 Although there seem to be very few up to date references for OpenGL 3.x itself, the actual low level manipulation of OpenGL is relatively straight forward. However I am having serious trouble trying to even conceptualise how one would manipulate VBOs in order to render a dynamic world. Obviously the immediate mode ways of old are non applicable, but from there where do I go? Do I write some kind of scene structure and then convert that to a set of vertices and stream that to the VBO, how

How can I find the minimal circle include some given points?

时光毁灭记忆、已成空白 提交于 2019-11-29 03:07:15
问题 I have given some points (2D-coordinates) and want to find the smallest circle, that includes all of this points. The algorithm doesn't have to be very efficient (while it would be nice naturally). 回答1: This is the so-called Smallest Enclosing Balls problem (in your case, Smallest Enclosing Circle ), a.k.a. Miniball . There are several algorithms and implementations out there for this problem – all of the following are linear-time solutions (i.e., given n balls, they run in O(n) if you

LibGDX - Application crashes when call TiledMapRenderer.render()

给你一囗甜甜゛ 提交于 2019-11-29 02:27:38
@Override public void render(float delta) { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update(); sprite.setProjectionMatrix(camera.combined); mLevel.getTiledMapRenderer().getProjectionMatrix().set(camera.combined); Vector3 tmp = new Vector3(); tmp.set(0, 0, 0); camera.unproject(tmp); mLevel.getTiledMapRenderer().render(tmp.x, tmp.y, camera.viewportWidth, camera.viewportHeight); sprite.begin(); ... sprite.end(); } Here is what I get when launching the desktop version : Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: Number of remaining buffer elements is 0,

Source code for Javascript tree that features in “Inventing on Principle” video

有些话、适合烂在心里 提交于 2019-11-29 01:37:16
问题 I was quite inspired by Bret Victor's Inventing on Principle video (http://vimeo.com/36579366). Also, I was very fascinated by that tree drawn using Javascript. I have not done much of graphics programming. All my career I have been a middle-tier and database developer. But looking at that programmatically draw tree, I am motivated to learn. I have started learning Javascript. I know I will eventually (in a few weeks or months, depending on how much time I get) be able to write such program

Bezier clipping

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 01:32:42
I'm trying to find/make an algorithm to compute the intersection (a new filled object) of two arbitrary filled 2D objects. The objects are defined using either lines or cubic beziers and may have holes or self-intersect. I'm aware of several existing algorithms doing the same with polygons, listed here . However, I'd like to support beziers without subdividing them into polygons, and the output should have roughly the same control points as the input in areas where there are no intersections. This is for an interactive program to do some CSG but the clipping doesn't need to be real-time. I've

Wrapping long text on an Android Canvas

喜你入骨 提交于 2019-11-29 01:21:46
I have a custom control that is doing a lot of 2D drawing straight to the canvas . Some of this drawing is text, so I am using the Canvas.drawText() method. I want to draw the text within some bounds - a top-left, certain maximum width, and a maximum number of lines. After drawing the text, I want to know how many lines it took. Is there a built-in function to draw text within bounds doing the splitting sensibly? If not, is there a standard recipe for doing so? Roman Nurik You can use the android.text.StaticLayout class for this; simply create a StaticLayout for the desired text, alignment,

Why do 2D transformations need 3x3 matrices?

怎甘沉沦 提交于 2019-11-29 00:57:13
问题 I want to do some 2D drawing and thus want to implement some matrix transformations. With my light mathematics background I am trying to understand how to do so in C# (any other oop language would do it obviously). All I read is explaining that we need to work with 3x3 matrices to be able to cope with the translations. Because you cannot make translation with multiplications. But this is with multiplications of the matrices that we create our transformations. So we work with something like: {