Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Analog Clock (https://forums.graalonline.com/forums/showthread.php?t=84616)

Tyhm 03-11-2009 12:32 PM

Analog Clock
 
1 Attachment(s)
PHP Code:

if (playerenters||timeout) {
  
showimg 0,insom_gui-watch.png,screenwidth-105,0;
  
changeimgvis 0,4;

  
temp.thp=(temp.thp-1)%1201;

  
setarray temp.points,8;

  
temp.cx=screenwidth-52;
  
temp.cy=52;
  
temp.h=30;
  
temp.radian=(pi*temp.thp/50);
  
temp.points[0]=temp.cx+(sin(temp.radian)*4);
  
temp.points[1]=temp.cy+(cos(temp.radian)*4);
  
temp.points[2]=temp.cx-(cos(temp.radian)*1);
  
temp.points[3]=temp.cy+(sin(temp.radian)*1);
  
temp.points[4]=temp.cx-(sin(temp.radian)*temp.h);
  
temp.points[5]=temp.cy-(cos(temp.radian)*temp.h);
  
temp.points[6]=temp.cx+(cos(temp.radian)*1);
  
temp.points[7]=temp.cy-(sin(temp.radian)*1);
  
showpoly 1,temp.points;
  
changeimgvis 1,6;
  
changeimgcolors 1,0.1,0.1,0.1,1;
  
temp.h+=4;
  
temp.points[0]=temp.cx+(sin(temp.radian)*5);
  
temp.points[1]=temp.cy+(cos(temp.radian)*5);
  
temp.points[2]=temp.cx-(cos(temp.radian)*2);
  
temp.points[3]=temp.cy+(sin(temp.radian)*2);
  
temp.points[4]=temp.cx-(sin(temp.radian)*temp.h);
  
temp.points[5]=temp.cy-(cos(temp.radian)*temp.h);
  
temp.points[6]=temp.cx+(cos(temp.radian)*2);
  
temp.points[7]=temp.cy-(sin(temp.radian)*2);
  
showpoly 2,temp.points;
  
changeimgvis 2,5;
  
changeimgcolors 2,0.5,0.5,0.5,0.25;

  
temp.h=20;
  
temp.radian=(pi*temp.thp/600);
  
temp.points[0]=temp.cx+(sin(temp.radian)*4);
  
temp.points[1]=temp.cy+(cos(temp.radian)*4);
  
temp.points[2]=temp.cx-(cos(temp.radian)*2);
  
temp.points[3]=temp.cy+(sin(temp.radian)*2);
  
temp.points[4]=temp.cx-(sin(temp.radian)*temp.h);
  
temp.points[5]=temp.cy-(cos(temp.radian)*temp.h);
  
temp.points[6]=temp.cx+(cos(temp.radian)*2);
  
temp.points[7]=temp.cy-(sin(temp.radian)*2);
  
showpoly 3,temp.points;
  
changeimgvis 3,6;
  
changeimgcolors 3,0.1,0.1,0.1,1;
  
temp.h+=4;
  
temp.points[0]=temp.cx+(sin(temp.radian)*5);
  
temp.points[1]=temp.cy+(cos(temp.radian)*5);
  
temp.points[2]=temp.cx-(cos(temp.radian)*3);
  
temp.points[3]=temp.cy+(sin(temp.radian)*3);
  
temp.points[4]=temp.cx-(sin(temp.radian)*temp.h);
  
temp.points[5]=temp.cy-(cos(temp.radian)*temp.h);
  
temp.points[6]=temp.cx+(cos(temp.radian)*3);
  
temp.points[7]=temp.cy-(sin(temp.radian)*3);
  
showpoly 4,temp.points;
  
changeimgvis 4,5;
  
changeimgcolors 4,0.5,0.5,0.5,0.25;
  
timeout=0.05;


I'm sure a clever coder could make a for loop for the points, but I like it my way. Replace temp.thp with the number of minutes you wish to reflect. Adding a second hand is left as an exercise for the reader. (Hint: You could probably just increment temp.thp by 1/60.)

Deas_Voice 03-12-2009 06:23 PM

is this a level npc?
because there would be no reason for posting this in gs1!
nice tho, but i really have to say that i hate your styling..
this.something=1; vs this.something = 1;
and for an example then u do the math,
temp.points[0]=temp.cx+(sin(temp.radian)*4);
just looks awful styling. use some spaces!

Chompy 03-12-2009 06:28 PM

Quote:

Originally Posted by Deas_Voice (Post 1473473)
is this a level npc?
because there would be no reason for posting this in gs1!
nice tho, but i really have to say that i hate your styling..
this.something=1; vs this.something = 1;
and for an example then u do the math,
temp.points[0]=temp.cx+(sin(temp.radian)*4);
just looks awful styling. use some spaces!

It's called personal preference, and every person/scripter is allowed to have their own way of styling.

Deas_Voice 03-12-2009 06:36 PM

Quote:

Originally Posted by Chompy (Post 1473474)
It's called personal preference, and every person/scripter is allowed to have their own way of styling.

yeah i know that ._.

Tyhm 03-12-2009 06:40 PM

Yeah, I did the whole damn thing in Offline Scripting. Feel free to convert to GS2 if you like, but I have bad luck trying to put GS2-converted script into ganis...

xXziroXx 03-13-2009 02:02 PM

1 Attachment(s)
Pretty inefficient and sore on the eyes. I use this on Maloria, perhaps any of it would make it possible for you to tweak yours?

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
setImg("mal_clock.gif");
  
drawUnderPlayer();
  
setTimer(.05);
}

function 
onTimeOut()
{
  
// Hour
  
with (findImg(200)) {
    
this.angle = -pi*(serverr.time.hour/6);
    
polygon = { 1.9.3*sin(this.angle), .9 .3*cos(this.angle) };
    
red .45green .2blue .1;
    
layer 2;
  }
  
  
// Minute
  
with (findImg(201)) {
    
this.angle = -pi*(serverr.time.minute/30);
    
polygon = { 1.9.5*sin(this.angle), .9 .5*cos(this.angle) };
    
red .3green .2blue .1;
    
layer 2;
  }
  
  
// Second
  
with (findImg(202)) {
    
this.angle = -pi*(serverr.time.second/30);
    
polygon = { 1.9.35*sin(this.angle), .9 .35*cos(this.angle) };
    
red .3green .2blue .1;
    
layer 2;
  }
  
setTimer(.05);
}

function 
onActionDoubleMouse()
{
  
client.messages.add("This is a clock");
  
client.messages.add("The current time is" SPC serverr.time.hour ":" serverr.time.minute);



ff7chocoboknight2 03-14-2009 04:29 AM

This is neat.


All times are GMT +2. The time now is 08:06 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.