View Single Post
  #8  
Old 03-05-2002, 12:03 AM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
Well I won't go on the assumption that you are not a l33t script0r, so instead I will tell you what I did, your math kind of needs to be strong to do this, and I wish I had a scanner so I could upload me notes, I'll try to overview.
If you think about it, on pong, you have 360 degrees, right? Well you can just cut it in half, to 180 degrees and two modes for x and y, so xmode = (0 || 1); ymode = (0 || 1); and each mode has 180 degrees. So like this, you can, using triginometry (sp?) figure out the direction of any object:
NPC Code:

xincrement = (cos(angle/57.3)*speed)-cos(angle/57.3);
yincrement = (sin(angle/57.3)*speed)-sin(angle/57.3);

Because remember circles are also 360 degrees...
where speed it the amount of space you want it to move each increment.


Than to move the actual object (assuming ox, oy is the object's x and y) you could simply do this:
NPC Code:

if (xmode == 0) ox+=abs(xincrement);
else ox-=abs(xincrement);
if (ymode == 0) oy+=abs(yincrement);
else oy-=abs(yincrement);



Than assuming that mx and my is the max x and y, and lx and ly is the least x and y, we can reverse the mode on hits.
NPC Code:

if (ox>=mx) this.xmode=0;
if (ox<=lx) this.xmode=1;
if (oy>=my) this.ymode=0;
if (oy<=ly) this.ymode=1;


Hope that helps.
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote