Clock Type Program
Author |
Message |
uberwalla
|
Posted: Wed Dec 20, 2006 10:22 pm Post subject: Clock Type Program |
|
|
Hey, im randomly trying to make a clock and i have it so it moves the arrow things, but i was wondering if theres a way so they stay the same size always (they tend to grow longer/shorter throughout).
this is what i got:
code: |
var x : int := maxx div 2
var y : int := maxy div 2
var x2 : int := maxx div 2
var y2 : int := maxy div 2 + 60
var mx2 : int := maxx div 2
var my2 : int := maxy div 2 + 60
var count : int := 0
var minute : int
loop
Draw.Line (x, y, x2, y2, 7)
Draw.ThickLine (x, y, mx2, my2, 2, 7)
if x2 >= maxx div 2 and x2 <= maxx div 2 + 60 and y2 <= maxy div 2 + 60 and y2 >= maxy div 2 then
x2 += 1
y2 -= 1
end if
if x2 <= maxx div 2 + 60 and x2 >= maxx div 2 and y2 <= maxy div 2 and y2 >= maxy div 2 - 60 then
x2 -= 1
y2 -= 1
end if
if x2 <= maxx div 2 and x2 >= maxx div 2 - 60 and y2 <= maxy div 2 and y2 >= maxy div 2 - 60 then
x2 -= 1
y2 += 1
end if
if x2 <= maxx div 2 and x2 >= maxx div 2 - 60 and y2 <= maxy div 2 + 60 and y2 >= maxy div 2 then
x2 += 1
y2 += 1
end if
delay (1000)
cls
count += 1
if count = 240 then
if mx2 >= maxx div 2 and mx2 <= maxx div 2 + 60 and my2 <= maxy div 2 + 60 and my2 >= maxy div 2 then
mx2 += 1
my2 -= 1
count := 0
end if
if mx2 <= maxx div 2 + 60 and mx2 >= maxx div 2 and my2 <= maxy div 2 and my2 >= maxy div 2 - 60 then
mx2 -= 1
my2 -= 1
count := 0
end if
if mx2 <= maxx div 2 and mx2 >= maxx div 2 - 60 and my2 <= maxy div 2 and my2 >= maxy div 2 - 60 then
mx2 -= 1
my2 += 1
count := 0
end if
if mx2 <= maxx div 2 and mx2 >= maxx div 2 - 60 and my2 <= maxy div 2 + 60 and my2 >= maxy div 2 then
mx2 += 1
my2 += 1
count := 0
end if
end if
end loop
|
thx in advance. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Hackmaster
|
Posted: Wed Dec 20, 2006 10:27 pm Post subject: (No subject) |
|
|
Well... it seems pretty easy.
all you do is make it MORE graphical. have so that you make a circle around it, and maybe some numbers would be nice. when you are done that, it's easy.
code: |
lineLength := radius_of_circle
|
however you want to display that is fine, but, fairly easy I would think...?
hope that helped! |
|
|
|
|
|
uberwalla
|
Posted: Wed Dec 20, 2006 10:31 pm Post subject: (No subject) |
|
|
heh that'll probably work well lol thx a bunch
lets just see how well i do with this |
|
|
|
|
|
Hackmaster
|
Posted: Wed Dec 20, 2006 10:34 pm Post subject: (No subject) |
|
|
no probelm... I'll be on for a bit... work it, then post it again!! |
|
|
|
|
|
uberwalla
|
Posted: Wed Dec 20, 2006 11:34 pm Post subject: (No subject) |
|
|
ok i know you probably dont wanna do it all for me or w.e, i understand but i need some guidance. i litterally have no idea how to implement it.
this is new code with a circle
code: |
setscreen ("nooffscreenonly")
var x : int := maxx div 2
var y : int := maxy div 2
var x2 : int := maxx div 2
var y2 : int := maxy div 2 + 60
var mx2 : int := maxx div 2
var my2 : int := maxy div 2 + 60
var radius_of_circle : int := 60
var count : int := 0
loop
drawoval (x, y, radius_of_circle, radius_of_circle, 1)
Draw.Line (x, y, x2, y2, red)
Draw.ThickLine (x, y, mx2, my2, 2, 7)
if x2 >= maxx div 2 and x2 <= maxx div 2 + 60 and y2 <= maxy div 2 + 60 and y2 >= maxy div 2 then
x2 += 1
y2 -= 1
elsif x2 <= maxx div 2 + 60 and x2 >= maxx div 2 and y2 <= maxy div 2 and y2 >= maxy div 2 - 60 then
x2 -= 1
y2 -= 1
elsif x2 <= maxx div 2 and x2 >= maxx div 2 - 60 and y2 <= maxy div 2 and y2 >= maxy div 2 - 60 then
x2 -= 1
y2 += 1
elsif x2 <= maxx div 2 and x2 >= maxx div 2 - 60 and y2 <= maxy div 2 + 60 and y2 >= maxy div 2 then
x2 += 1
y2 += 1
end if
delay (1000)
cls
count += 1
if count = 240 then
if mx2 >= maxx div 2 and mx2 <= maxx div 2 + 60 and my2 <= maxy div 2 + 60 and my2 >= maxy div 2 then
mx2 += 1
my2 -= 1
count := 0
elsif mx2 <= maxx div 2 + 60 and mx2 >= maxx div 2 and my2 <= maxy div 2 and my2 >= maxy div 2 - 60 then
mx2 -= 1
my2 -= 1
count := 0
elsif mx2 <= maxx div 2 and mx2 >= maxx div 2 - 60 and my2 <= maxy div 2 and my2 >= maxy div 2 - 60 then
mx2 -= 1
my2 += 1
count := 0
elsif mx2 <= maxx div 2 and mx2 >= maxx div 2 - 60 and my2 <= maxy div 2 + 60 and my2 >= maxy div 2 then
mx2 += 1
my2 += 1
count := 0
end if
end if
end loop
|
please help i got no idea how to make them same length as radius.
like i mean i know it has something to do with math like...
if x2 - x not= -60 then
something
end if
something like that?
im really lost. |
|
|
|
|
|
richcash
|
Posted: Thu Dec 21, 2006 12:05 am Post subject: (No subject) |
|
|
Why don't you use sine and cosine for something like this?
code: | var r := 25
View.Set ("offscreenonly")
for i : 1 .. 360
cls
Draw.Line (100, 100, 100 + round (sind (i) * r), 100 + round (cosd (i) * r), 7)
Draw.Oval (100, 100, r, r, 7)
View.Update
end for |
It would be quite troublesome trying to do this without trigonometry. |
|
|
|
|
|
uberwalla
|
Posted: Thu Dec 21, 2006 12:11 am Post subject: (No subject) |
|
|
wow i have never seen those code words in my life lol (well turing)
that shortened my code by 10000x thx a bunch learned a bunch. now ima go add minutes and hours |
|
|
|
|
|
ericfourfour
|
Posted: Thu Dec 21, 2006 12:16 am Post subject: (No subject) |
|
|
uberwalla, I take it you haven't reached grade 10 math yet. I was in the same dilemma when I started programming. Trigonometry is not hard to understand. It just takes a while to learn because of the math behind it (speaking from personal experience).
Examine richcash's code. It should do the trick. Try to figure out how it works. I'm sure, if you are unable to figure it out, you could find some tutorials on the internet. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
ericfourfour
|
Posted: Thu Dec 21, 2006 12:18 am Post subject: (No subject) |
|
|
Err... Woops. Didn't realize you posted after richcash. |
|
|
|
|
|
uberwalla
|
Posted: Thu Dec 21, 2006 12:21 am Post subject: (No subject) |
|
|
i do know some trig but i just didnt think of using it for the clock and you're right though i havent done gr 10 math yet, its nexy semester |
|
|
|
|
|
Hackmaster
|
Posted: Thu Dec 21, 2006 4:56 pm Post subject: (No subject) |
|
|
I don't know what it is... latley there have been a bunch of graphical clocks going around... You should check some of the other posts in the area. it must be finals time... |
|
|
|
|
|
uberwalla
|
Posted: Thu Dec 21, 2006 5:04 pm Post subject: (No subject) |
|
|
actually i just randomly wanted to make one when i saw the other guy trying to make one. mines not for class at all |
|
|
|
|
|
Hackmaster
|
Posted: Thu Dec 21, 2006 5:29 pm Post subject: (No subject) |
|
|
oh.. well there you go! whatever...
good luck anyhow! or just wait till next semester for trig. or go to this wonderus place... it's called "The internet". it is used to gather datums of all kinds... and you can learn it yourself.... |
|
|
|
|
|
|
|