2d

How to calculate SCREEN to WORLD position in 2D game

隐身守侯 提交于 2019-12-12 10:53:27
问题 I have this class, I use it for drawing sprites in my 2D game: using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Audio; namespace Namespace { /// <summary> /// Found this brilliant code at. /// http://adambruenderman.wordpress.com/2011/04/05/create-a-2d-camera-in-xna-gs-4-0/ /// </summary> public class CCamera2d { private const float zoomUpperLimit = 1.3f; private const float zoomLowerLimit = .85f; private float _zoom; private Matrix

Matplotlib 2d Plot on Faces of 3d Plot

夙愿已清 提交于 2019-12-12 10:25:36
问题 I am producing plots of a spacecraft's trajectory at a specific point in its orbit. I have a piece of code which produces a 3d line plot in 3dMatplotlib (a part of mycode and figure is shown here (I have drastically reduced the number of points within X,Y,Z to ~20 per array to make it easier to simply copy and paste as the principle is the same): # import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.axes3d import Axes3D from numpy import * XdS=[14.54156005, 14.53922242, 14.53688586, 14

fftw c2c: missing symmetry in transformed real data

烈酒焚心 提交于 2019-12-12 09:48:21
问题 recently I faced some problems concerning the use of fftw and it's c2c transformation (see: 3d c2c fft with fftw library). As I located my problems in the use of the fftw lib I created a new Question in order to discus this situation in a more concrete way. Since I am doing a complex to complex transform with real data my transformed data in fourier space is supposed to be symmetric: F[n] = con(F[N-n]) Now I did some transformations with small blocks of test-data to check the transformed data

Unity3d Is there something like Mesh Collider for 2D objects?

£可爱£侵袭症+ 提交于 2019-12-12 09:15:02
问题 Im making simple 2D game, I designed the "way" the player going through in the game. If the player touches the wall the game is over, so I must detect collisions. At first I created the walls from sprites, but then I realized there is no 2D collider that suit himself to the shape of the sprit(it was to difficult to create the collider manually from a lot of smaller polygon and circle colliders), so I made all the walls that builds the "way" 3D objects(.dae files with z=0.001), and added them

2D array Null Pointer Exception error

穿精又带淫゛_ 提交于 2019-12-12 09:01:38
问题 public class DoubleMatrix { private double[][] doubMatrix; public DoubleMatrix(int row, int col) { if(row > 0 && col > 0) { makeDoubMatrix(row,col); } else { row = 1; col = 1; } } public DoubleMatrix(double[][] tempArray) { if(tempArray != null) { for(int i = 0; i < tempArray.length-1;i++) { if(tempArray[i].length == tempArray[i+1].length) { tempArray = doubMatrix; } } } else { makeDoubMatrix(1,1); } } public int getDim1() { return doubMatrix.length; } public int getDim2() { return doubMatrix

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

拜拜、爱过 提交于 2019-12-12 07:57:10
问题 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 lots of tiles using QGraphicsScene? Can I add the whole world at once tile-by-tile or should I try to implement something to restrict the area a bit? I've read that QGraphicsScene can handle "thousands of items" but a 2D tile map can easily get

Find equidistant points on ellipse or Beizier curves

怎甘沉沦 提交于 2019-12-12 07:01:48
问题 Currently I writing JavaScript code that will place objects on screen accross the ellipse. I trying to find algorithm that will solve one of this problems, ellipse will be perfect, but if it is too expensive Beizier curve will be ok too. I'm sorry, but unforunately my math doesn't let me to use answers that I found (https://mathoverflow.net/questions/28070/finding-n-points-that-are-equidistant-around-the-circumference-of-an-ellipse , Equidistant points across Bezier curves ), so I need help

2D array manipulation using a pointer in C

 ̄綄美尐妖づ 提交于 2019-12-12 06:38:54
问题 Let us say I have a function which manipulates a 2D array which receives a pointer to the 2D array from the main function as its parameter. Now, I want to modify(assume add 10 to each element) each element of the 2D array. I am interested in knowing about traversing through the 2D array with a single pointer given to me and return the pointer of the newly modified array. Rough Structure Assume pointer a contains the initial address of the 2D array. int add_10(int *a) { int i, j, b[M][N] = {0}

2D shape in C++ by using the OpenGl library

孤人 提交于 2019-12-12 05:26:19
问题 I am trying to draw a shape in C++ by using the OpenGl library I've written the following code , but all what I achieved is the following shape ): but do I need to use glRotatef to get this shape :? and how can I use it ? this is my code :) #include <Windows.h> #include <GL\glew.h> #include <GL\freeglut.h> #include <iostream> #include <math.h> using namespace std; float angle, radius, xx1, yy1; int main(int argc, char** argv) { void Transform(void); void circle(void); void shape(void); void

Rendering Opaque and Transparent 2D sprites using z-index sorting

☆樱花仙子☆ 提交于 2019-12-12 04:47:48
问题 As part of my 2D game engine, I would like to be able set the order (from back to front) in which my sprites are rendered on screen by manipulating their z-index . This z-index sprite property is a floating point value which can range between the far and near planes of my orthographic projection (in the range of (-1.0, 1.0] ). Currently, in order to minimize unnecessary texture switching, I store my sprites in an un-ordered dictionary, where the keys are textures and the values are the