/* attempt to deal with prototype, bootstrap, jquery conflicts */ /* for dropdown menus */

Jump to content

Image of the Day

Today's #ScreenshotSaturday features Face Your Fears from Turtle Roc ... #virtualrealityshop #mobilevr #vrshop https://t.co/3qhSNAVNOZ
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

Get coordinates for a rectangles edges

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 P0jahn   Members   

307
Like
0Likes
Like

Posted 09 January 2013 - 10:43 AM

I need to implement a laser unit to my game that fire a rotating(360 degree) laser. The laser target coordinate is where I am getting stuck at. Every frame, it need to update its target coordinates so the laser is spinning. So if I have a rectangle that is 800x600, first I get coordinate 1:0, then 2:0, and later 800:0, then 800:1, 800:2, later 800:600, then 799:600. I hope that was clear. I thought it was an easy task, I opened eclipse but got stuck pretty fast smile.png Searched on google but could not find anything.



#2 Ravnock   Members   

307
Like
0Likes
Like

Posted 09 January 2013 - 11:09 AM

I need to implement a laser unit to my game that fire a rotating(360 degree) laser. The laser target coordinate is where I am getting stuck at. Every frame, it need to update its target coordinates so the laser is spinning. So if I have a rectangle that is 800x600, first I get coordinate 1:0, then 2:0, and later 800:0, then 800:1, 800:2, later 800:600, then 799:600. I hope that was clear. I thought it was an easy task, I opened eclipse but got stuck pretty fast smile.png Searched on google but could not find anything.

The laser has to follow a path of targets, I would create a class "Follower" with a container with points to follow and a class CircuitFollower that updates the current point until the end and begins again, initialized with  this three points: (0,0) (800,0) (800,600)

 

The class perform an Action every frame and updates the current point every frame (usually to the next).

 

So if you have a class Enemy you should implement this class.

 

Class Follower

{

 Queue pointsToFollow;

 Action();

 Update();

}

 

Class CircuitFollower

{

  ...

}

 

 

Maybe it's too generic for you, I don't know... but it's useful for more stuff

 


#3 P0jahn   Members   

307
Like
0Likes
Like

Posted 09 January 2013 - 12:56 PM

Actually, that is a fantastic idea and is well compatible with my game. Thanks!



#4 Kwizatz   Members   

1367
Like
1Likes
Like

Posted 09 January 2013 - 04:51 PM

You may want to consider using polar coordinates or just store the angle of the ray to calculate the line.

If you just sweep the screen borders, the animation will seem to slow down and speed up because of the difference in ratio between width and height.



#5 Ravnock   Members   

307
Like
0Likes
Like

Posted 11 January 2013 - 05:34 AM

Actually, that is a fantastic idea and is well compatible with my game. Thanks!

You are welcome, it's nice to be useful!






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.