Cyber Syndicate
<center><p style='font-size:120%;'><strong>Welcome to Cyber Syndicate!<strong></p>

You are visiting as a guest; please <strong>register</strong> or <strong>log in</strong>.

Being logged in provides many benefits, including access to the useful <strong>Methods forum</strong>, posting permissions, and voting permissions.

<strong>Enjoy.</strong></center>
Cyber Syndicate
<center><p style='font-size:120%;'><strong>Welcome to Cyber Syndicate!<strong></p>

You are visiting as a guest; please <strong>register</strong> or <strong>log in</strong>.

Being logged in provides many benefits, including access to the useful <strong>Methods forum</strong>, posting permissions, and voting permissions.

<strong>Enjoy.</strong></center>
Cyber Syndicate
Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
HomeLatest imagesRegisterLog in

 

 Rotating Mouse

Go down 
5 posters
AuthorMessage
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Rotating Mouse Empty
PostSubject: Rotating Mouse   Rotating Mouse Icon_minitimeWed Mar 09, 2011 10:09 pm

This method can be used to make a rotating mouse for your script.

Imports:
Code:
import com.rsbuddy.script.methods.Mouse;
import java.awt.*;

As a method:
Code:
private double getRot(int ticks){
    return (System.currentTimeMillis() % (360 * ticks)) / ticks;
}

In your onRepaint()
Code:
         Graphics2D g = (Graphics2D) g1;
         g.drawString("Nonrotating", 0, 0);
         Graphics2D m = (Graphics2D) g1;
         m.rotate(Math.toRadians(getRot(5)), Mouse.getLocation().x, Mouse.getLocation().y);
         // Mouse graphics here

Enjoy.


Last edited by b0xb0x on Sun Mar 13, 2011 12:05 pm; edited 3 times in total
Back to top Go down
https://cybersyndicate.forumotion.com
TaffTech
Administrator
Administrator



Posts : 72
Join date : 2011-02-27

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeWed Mar 09, 2011 10:50 pm

That's pretty awesome Very Happy
Would you by any chance know how to make a trailing mouse? Because I'd love one of those for my scripts xD
In the meanwhile, I'll be trying to make on of my own Very Happy
Back to top Go down
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeWed Mar 09, 2011 10:58 pm

TaffTech wrote:
That's pretty awesome Very Happy
Would you by any chance know how to make a trailing mouse? Because I'd love one of those for my scripts xD
In the meanwhile, I'll be trying to make on of my own Very Happy

I haven't ever made one, but I just looked through the docs and got a few ideas...
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics2D.html#getStroke%28%29
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Stroke.html#createStrokedShape%28java.awt.Shape%29
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics2D.html#draw%28java.awt.Shape%29
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics2D.html#fill%28java.awt.Shape%29
Very Happy I'm going to make one as well.
Back to top Go down
https://cybersyndicate.forumotion.com
TaffTech
Administrator
Administrator



Posts : 72
Join date : 2011-02-27

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeWed Mar 09, 2011 11:02 pm

b0xb0x wrote:
TaffTech wrote:
That's pretty awesome Very Happy
Would you by any chance know how to make a trailing mouse? Because I'd love one of those for my scripts xD
In the meanwhile, I'll be trying to make on of my own Very Happy

I haven't ever made one, but I just looked through the docs and got a few ideas...
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics2D.html#getStroke%28%29
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Stroke.html#createStrokedShape%28java.awt.Shape%29
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics2D.html#draw%28java.awt.Shape%29
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics2D.html#fill%28java.awt.Shape%29
Very Happy I'm going to make one as well.

Awesome Very Happy
Back to top Go down
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeWed Mar 09, 2011 11:05 pm

TaffTech wrote:
Awesome Very Happy

Never mind those links, none really help haha :P
Back to top Go down
https://cybersyndicate.forumotion.com
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeWed Mar 09, 2011 11:12 pm

I'll let you do it haha it's a pain since you have to create x timers running at x different equal times that save the mouse points in an array and then in your Graphics2D, make a for statement that draws the mouse based off of the array of points looping rather than just one point.
Back to top Go down
https://cybersyndicate.forumotion.com
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeWed Mar 09, 2011 11:37 pm

Back to top Go down
https://cybersyndicate.forumotion.com
TaffTech
Administrator
Administrator



Posts : 72
Join date : 2011-02-27

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeWed Mar 09, 2011 11:38 pm

b0xb0x wrote:
I'll let you do it haha it's a pain since you have to create x timers running at x different equal times that save the mouse points in an array and then in your Graphics2D, make a for statement that draws the mouse based off of the array of points looping rather than just one point.

My idea was somewhat simpler... xD
Have an arraylist of saved points then.
Draw a line from the mouse position to the last point,
Draw lines from and to each point in the arraylist,
Update the points Very Happy
Back to top Go down
Ramus
VIP
VIP



Posts : 41
Join date : 2011-02-27
Age : 28
Location : Wales

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeSun Mar 13, 2011 12:22 am

It works, but it's a bit laggy when I try to rotate a rectangle :S Any ideas?
Back to top Go down
Remo
Member
Member



Posts : 41
Join date : 2011-03-10

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeSun Mar 13, 2011 6:26 am

Mouse can not be resolved =[ What is the import I need?
Back to top Go down
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeSun Mar 13, 2011 8:51 am

Remo wrote:
Mouse can not be resolved =[ What is the import I need?

com.rsbuddy.script.methods.Mouse Smile
Back to top Go down
https://cybersyndicate.forumotion.com
Remo
Member
Member



Posts : 41
Join date : 2011-03-10

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeSun Mar 13, 2011 10:03 am

b0xb0x wrote:
Remo wrote:
Mouse can not be resolved =[ What is the import I need?

com.rsbuddy.script.methods.Mouse Smile

That's what can't be resolved.
Back to top Go down
Salvation
VIP
VIP



Posts : 15
Join date : 2011-02-28

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeSun Apr 03, 2011 9:55 am

Code:
   @Override
   public void onRepaint(Graphics graphics) {
      Point location = Mouse.getLocation();
      
      Graphics2D m = (Graphics2D) graphics;
      m.setRenderingHints(antialiasing);
      m.rotate(Math.toRadians(getRot(5)), location.x, location.y);
      m.drawImage(mousepointer, location.x, location.y, null);
      
      Graphics2D g = (Graphics2D) graphics;
      g.setRenderingHints(antialiasing);
      g.setColor(Color.BLACK);
      g.drawLine(location.x, 0, location.x, (int)Game.getCanvasSize().getHeight());
      g.drawLine(0, location.y,(int)Game.getCanvasSize().getWidth(), location.y);
      g.drawImage(mousepointer, location.x, location.y, null);
   }
no shittin me, the entire thing is turning >.<
Back to top Go down
Salvation
VIP
VIP



Posts : 15
Join date : 2011-02-28

Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitimeSun Apr 03, 2011 10:12 am

fixed, will post later
Code:
      double rotation = Math.toRadians(System.currentTimeMillis() % (360));
      g.rotate(rotation, location.x, location.y);
      g.drawImage(mousepointer, location.x, location.y, null);
      g.rotate(-rotation, location.x, location.y);
Back to top Go down
Sponsored content





Rotating Mouse Empty
PostSubject: Re: Rotating Mouse   Rotating Mouse Icon_minitime

Back to top Go down
 
Rotating Mouse
Back to top 
Page 1 of 1
 Similar topics
-
» Mouse Trail

Permissions in this forum:You cannot reply to topics in this forum
Cyber Syndicate :: Development :: Methods-
Jump to: