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
1 answer

How to Check for 2D Collision Without Checking Every Object

I'm being really ambitious and working on a 2D Shoot 'em Up game that will have, hopefully, hundreds of entities running around. What I'm having trouble wrapping my brain around, is how the bullet will detect when it makes a collision with an…
8
votes
3 answers

One dimensional edge detection

Instead of edge detection of a 2D image, I would like to detect edges on every single row (i.g. a line) of an image separately. That is detection of edges from an input 1D vector whose values are pixel intensities ranging from 0 to 255 ( image…
C graphics
  • 7,308
  • 19
  • 83
  • 134
8
votes
4 answers

The Math of a Jump in a 2D game

I'm working in J2ME, I have my gameloop doing the following: public void run() { Graphics g = this.getGraphics(); while (running) { long diff = System.currentTimeMillis() - lastLoop; lastLoop =…
fixmycode
  • 8,220
  • 2
  • 28
  • 43
8
votes
4 answers

Getting started with a Tile-based game in Qt using QGraphicsScene and QGraphicsView

I'm going to start programming a 2D tile-based game in Qt and read about the QGraphicsScene and QGraphicsView classes which are intended for displaying and handling lots of 2D objects. My question is that will it be feasible to create a world with…
Maush
  • 83
  • 1
  • 3
8
votes
4 answers

What happens when converting double (or floats) to ints?

I'm practicing some simple 2D game programming, and came up with a theory that during animation (the actual change in a image position is best calculated with floating point numbers). I have a feeling that if you move an image around with ints the…
mastrgamr
  • 631
  • 1
  • 11
  • 21
8
votes
4 answers

Android Speedometer (Needle Gauge)

Creating a simple app that calculates the speed your going and displays it in a speedometer graphic. I can do all the speed calculations, gps calculations etc.. but i am not too sure about the animation. Does anyone have any good tutorials or…
Mark Manickaraj
  • 1,661
  • 5
  • 28
  • 44
8
votes
3 answers

2D collision between a moving circle and a fixed line segment

In the context of a game program, I have a moving circle and a fixed line segment. The segment can have an arbitrary size and orientation. I know the radius of the circle: r I know the coordinates of the circle before the move: (xC1, yC1) I know…
Joel
  • 3,427
  • 5
  • 38
  • 60
8
votes
2 answers

fast 2dimensional histograming in matlab

I have written a 2D histogram algorithm for 2 matlab vectors. Unfortunately, I cannot figure out how to vectorize it, and it is about an order of magnitude too slow for my needs. Here is what I have: function [ result ] = Hist2D( vec0, vec1…
John
  • 5,735
  • 3
  • 46
  • 62
8
votes
4 answers

Can i move the origin when doing a rotation transform in Quartz 2D for the iPhone?

Sorry if this is obvious or covered elsewhere, but i've been googling all day and haven't found a solution that actually worked. My problem is as follows: I am currently drawing an image in a full screen UIView, for examples sake we'll say the image…
Skyler
  • 1,159
  • 2
  • 13
  • 22
8
votes
3 answers

Pacman maze in Java

So I'm building the pacman game in Java to teach myself game programming. I have the basic game window with the pacman sprite and the ghost sprites drawn, the pacman moves with the arrow keys, doesn't move beyond the walls of the window, etc. Now…
Ali
  • 261,656
  • 265
  • 575
  • 769
8
votes
2 answers

Algorithm for 2D nearest-neighbour queries with dynamic points

I am trying to find a fast algorithm for finding the (approximate, if need be) nearest neighbours of a given point in a two-dimensional space where points are frequently removed from the dataset and new points are added. (Relatedly, there are two…
Richard
  • 56,349
  • 34
  • 180
  • 251
8
votes
1 answer

Drawing aliased, pixel-perfect 1px splines (Catmull-Rom, specifically)

A brief background: I'm working on a web-based drawing application and need to draw 1px thick splines that pass through their control points. The issue I'm struggling with is that I need to draw each of the pixels between p1 and p2 as if I were…
Xenethyl
  • 3,179
  • 21
  • 31
8
votes
1 answer

Rotate rectangle around a point

How would I get 4 points rotated a certain degrees around a pointer to form a rectangle? I can rotate a point around a point, but I can't offset it to make a rectangle that isn't distorted.
Anonymous
  • 1,823
  • 7
  • 23
  • 29
8
votes
1 answer

2D Drawing for Jupyter?

I teach intro computer science classes, and I like to do so using 2D graphics. I've been using John Zelle's excellent graphics.py library, but I want to migrate to using Jupyter with my students so I need a new graphics solution. This needs to be…
David Rea
  • 246
  • 2
  • 12
8
votes
6 answers

2D array of lists in python

I am trying to create a 2d matrix so that each cell contains a list of strings. Matrix dimensions are known before the creation and I need to have access to any element from the beginning (not populating a matrix dynamically). I think some kind of…
Nik
  • 91
  • 1
  • 1
  • 2