Archived

This topic is now archived and is closed to further replies.

jimywang

help needed on data structure of DOOM style FPS

Recommended Posts

i am doing a DOOM style FPS game at the moment.the data structure i am using to represent the wall looks like this: typedef struct WALL_TYP { float x1; float y1; float x2; float y2; float m; float b; }WALL, *WALL_PTR; where x1,y1,x2,y2 is for the positions of the start and end points of the wall.m is for the slope of the wall and b is for the the line equation y = mx + b. then i have an array of WALL to contain all of walls in the map which looks like this: const WALL map [] = { (0,200,200,200,0,200) }; however,when i tried to render this wall on screen with raycast algorithm,all the value in the array appears all wrong.i mean,the wall actually rendered is (200,0,0,0,0,0) instead (0,200,200,200,0,200).no matter how i change the value in the array,it always renders (200,0,0,0,0,0) for me.Can someone tell me what it is going on here plz?Thx.

Share this post


Link to post
Share on other sites
my basic idea is with all these value in WALL,i can get a line equation for the wall that is rendering.also i have the line equation for the current ray i am casting.then the algorithm will calculate the intersection between the lines and distance between the intersection and current player position.

Share this post


Link to post
Share on other sites