Questions tagged [2d]

2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models.

Flat perspective, having no three-dimensional geometry. Including two-dimensional space and 2D geometric models, or two-dimensional images having only height, and width with no depth.

7489 questions
9
votes
2 answers

Swift 3 2d array of Int

It's actually a very simple question, but after an hour I can not solve my problem. I need to create a 2d array of Int. var arr = [[Int]]() or var arr : [[Int]] = [] tried to change value : arr[x][y] = 1 fatal error: Index out of range Should I…
Mikhail Sein
  • 329
  • 3
  • 4
  • 14
9
votes
3 answers

Simple registration algorithm for small sets of 2D points

I am trying to find a simple algorithm to find the correspondence between two sets of 2D points (registration). One set contains the template of an object I'd like to find and the second set mostly contains points that belong to the object of…
user5745159
9
votes
5 answers

Print 2-D Array in clockwise expanding spiral from center

I have an guaranteed to be a perfect square matrix. I want to start at the center of the matrix in this case it would be matrix[2][2], I know how to figure the center (int)(dimensions / 2). I need to output the contents of the array in this…
user3328187
  • 193
  • 2
  • 2
  • 6
9
votes
4 answers

Operation on 2d array columns

I'd like to know if it's possible to apply a function (or juste an operation, such as replacing values) to column in a python 2d array, without using for loops. I'm sorry if the question has already been asked, but I couldn't find anything specific…
Coulis
  • 196
  • 1
  • 13
9
votes
5 answers

2D game algorithm to calculate a bullet's needed speed to hit target?

I have a rather simple bird's-view 2D game where tower sprites defend against incoming moving sprites by shooting a bullet at them. My question: How do I calculate the needed bullet speed for the bullet to reach its moving target, provided that the…
Philipp Lenssen
  • 8,818
  • 13
  • 56
  • 77
9
votes
1 answer

Make two physics objects not collide but do detect collisions in Unity

I have a Unity project in which there is a 2D game world that consists of static colliders to make the geometry solid to the characters that inhabit it. The player is a dynamic collider (with a non-kinematic rigidbody). There's also an enemy…
Jela
  • 562
  • 1
  • 6
  • 20
9
votes
6 answers

Support multiple aspect ratio in Unity

I've been trying to create a Unity 2D game that supports each and every aspect ratios of devices for both android and tablets. Is there a way to do so that's been provided or recommended by Unity?
Balu
  • 1,069
  • 2
  • 10
  • 24
9
votes
10 answers

How to determine path from noisy X, Y data

I have an unsorted list of noisy X, Y points. They do, however, form a path through the world. I would like an algorithm to draw an approximation of this data using line segments. This is similar to how you would use a line -fitting algorithm to…
Frank Krueger
  • 69,552
  • 46
  • 163
  • 208
9
votes
2 answers

Cross product of 2 2D vectors

Can anyone provide an example of a function that returns the cross product of TWO 2d vectors? I am trying to implement this algorithm. C code would be great. Thanks. EDIT: found another way todo it that works for 2D and is dead easy. bool…
user181351
9
votes
3 answers

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

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…
jsimmons
  • 732
  • 1
  • 8
  • 18
9
votes
4 answers

Favorite image file format for 2d sprites

What is your favorite, lossless image format for games (namely 2d games)? And why? Some things to take into consideration are size on disk, overhead for converting to a usable format, and features of the format (ie alpha support). There is no best…
Spodi
  • 1,151
  • 1
  • 11
  • 19
9
votes
4 answers

How do I develop Java games for phones?

How do I begin developing J2ME games for mobile phones? Are any libraries available that can render pixel fonts for text? - for text games Are 2D graphic libraries available that can draw animated bitmaps? - for isometric and tiled games Any are 3D…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
9
votes
4 answers

2D geometry: how to check if a point is inside an angle

i have the following geometrical issue in 2D: i have a point from which i cast an infinite angle (2D-cone) which is given by a direction and an angle. (the point and the direction form a vector and to each side half of the angle forms the…
clamp
  • 33,000
  • 75
  • 203
  • 299
9
votes
3 answers

Java - Maximum sum in path through a 2D array

Basically I have a problem that goes something similar to this: There is a garden of strawberry plants represented by a 2D, square array. Each plant(each element) has a number of strawberries. You start at the top left corner of the array, and you…
user1547050
  • 337
  • 2
  • 7
  • 15
9
votes
4 answers

How to tell if a line intersects a polygon in C#?

I have a question very similar to this: How to know if a line intersects a plane in C#? I am searching for a method (in C#) that tells if a line is intersecting an arbitrary polygon. I think the algorithm by Chris Marasti-Georg was very helpful,…
svanerik
  • 113
  • 1
  • 2
  • 5