   easy way to simulate perspective?
  Hi there,I am trying to make simple 2D game with ilusion of depth. I would like to draw long corridor or hallway moving away from camera. Camera is always facing same direction, it's vector is parallel with walls and floor. ------------------------------    |    | C ------>    |    |    |------------------------------(C is camera, arrow show direction camera is looking. camera is slowly moving in opposite direction)I want to do all this without using any 3d api, just few images, scaling and moving.My first idea was to create 4 trapezoids (one for each side) to simulate perspective so i don't have to skew rectangles and just move them towards center of the screen and scale them down accordingly. I want to tile them to create whole wall. I am fighting with this whole day and I just can't get it right. I have z position for each part of wall that I am incrementing each tick but I can't figure out how can I calculate position on screen and scale from depth. Is there some easy way or am I doing this all wrong?   
  One method could be based on the old tunnel demo effect, especially in regard to the calculation of depth as a texture index.Here's a snippet of sample code for Ken Silverman's Evaldraw:(x,y,t,&r,&g,&b)if (abs(x) > abs(y)) {   u = 1/(x*x);   v = y/x;} else {   u = 1/(y*y);   v = x/y;}w=0; h=0; getpicsiz(w,h);pic(u*w+t*10,v*h,r,g,b);The result looks like this.The implementation is not especially efficient (you only need to calculate u once for each row for the ceiling and floor and once for each column for the walls) but may help illustrate a possible technique!   ;  thanks for reply, but if I understand it correctly it show hot to calculate color from x,y coordinate on the screen. I need something different, I need to calculate position on screen from x,y,z position in world. I thought that it will be something simple because camera is in center of the world looking in direction of z axis, but I still can't get it right.I found flash game with similar effect, maybe you will understand better what I want to achievehttp://en.playplayplay.info/play.17.html   ;  Ah, perspective projection can be implemented as  x2D = (x3D / z3D) + (screen.width / 2) and y2D = (y3D / z3D) + (screen.width / 2) — the further away something is, the larger z is and so the closer it appears to the vanishing point in the middle of the screen.You do need to make sure z is larger than 0 (at zero it would be scratching your eyeballs and below zero it would be behind your eyes).   