Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / new screen wrapping style need help

Author
Message
qwerty michael 007
12
Years of Service
User Offline
Joined: 21st Feb 2010
Location:
Posted: 25th Feb 2010 04:04
hello i solved my previous screen wrapping program in an easy way by saying that if the ship went off the screen at x=0 and y=150 then the ship x would equal x max (which is 480) so in that sense the ship would jump to that position at the default vector but what i want to do is since i am using vector based turning i want to take the angle of the turn and return the ship at the same vector which would make the turning and loop functions much clearer. the image attached will show you what i mean the red inking is the current loop function that i have and the green arrows are the loop function that i plan to write. thanks to anybody that can help me.

Attachments

Login to view attachments
LBFN
15
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 1st Mar 2010 04:49
It will be hard to provide any assistance to you unless we can see your code. Can you post it in a code snippet?

qwerty michael 007
12
Years of Service
User Offline
Joined: 21st Feb 2010
Location:
Posted: 1st Mar 2010 23:50
[float Line(float X)
{

return tan(angle)*(X - Ship.x) + Ship.y;

}

if (pos[1] < 0)
{

// Slope from angle

// If Angle = PI / 2 or 3*PI / 2, S = 0

float S = tanf(fAngle);
float X = (640 + S*pos[0] - pos[1]) / S;
float Y = S(X-pos[0]) + pos[1];

pos[0] = X;
pos[1] = Y;

}

else if (pos[1] > 640)

{
float S = tanf(fAngle);
float X = (S*pos[0] - pos[1]) / S;
float Y = S(X-pos[0]) + pos[1];

pos[0] = X;
pos[1] = Y;
]

sorry if it wasn't clear

Login to post a reply

Server time is: 2023-01-29 05:30:33
Your offset time is: 2023-01-29 05:30:33