Function to create evenly spaced tickmarks for tachometer or speedometer display. Function uses sprites positioned on screen, and after you run the code, just do a print screen and paste it into your favorite art program.
Can control the total rotation of the tickmarks, the start location of the tickmarks, and the number of major ticks, up to 16.(counting zero).
I needed to do this because I want to make my own textures for the 3D speedometers/tachometers.
REM Project: tickmarks
REM Created: 8/16/2009 3:09:15 PM
REM
REM ***** Main Source File *****
REM created by Visigoth
REM free to use, credit please!
autocam off
sync on
sync rate 0
set display mode desktop width(),desktop height(),32
ox = screen width() / 2
oy = screen height() / 2
//first param is how many rpms, in 1's
//second param is total rotation of gauge, up to 360
//third param is the starting offset, 90 is straight down, winds clockwise
tach_dial(ox,oy,15,270,180)
do
sync
loop
function tach_dial(ox,oy,rpm,rotation#,offset#)
load image "bar1.png",1
load image "bar2.png",2
load image "bar3.png",3
load image "numbers.png",4
//tens loop
ang# = offset#
stepVal# = rotation# / rpm
ten_step = rpm + 1
for i = 1 to ten_step
x1 = ox + ((oy - 64) * cos(ang#))
y1 = oy + ((oy - 64) * sin(ang#))
sprite i,x1,y1,1
offset sprite i,2,2
rotate sprite i,ang#
inc ang#,stepVal#
next i
//fives loop
ang# = offset# + ((rotation# / rpm)/2)
stepVal# = rotation# / rpm
five_step = (rpm * 2) + 1
for i = ten_step + 1 to five_step
x1 = ox + ((oy - 52) * cos(ang#))
y1 = oy + ((oy - 52) * sin(ang#))
sprite i,x1,y1,2
offset sprite i,2,2
rotate sprite i,ang#
inc ang#,stepVal#
next i
//ones loop
ang# = offset#
stepVal# = (rotation# /(rpm * 10))
one_step = (five_step + 1) + (rpm * 10)
for i = five_step + 1 to one_step
x1 = ox + ((oy - 44) * cos(ang#))
y1 = oy + ((oy - 44) * sin(ang#))
sprite i,x1,y1,3
offset sprite i,1,1
rotate sprite i,ang#
inc ang#,stepVal#
next i
//numbers
ang# = offset#
ang_inc# = rotation# / rpm
for i = one_step + 1 to (one_step + 1) + rpm
x1 = ox + ((oy - 100) * cos(ang#))
y1 = oy + ((oy - 100) * sin(ang#))
sprite i,x1,y1,4
offset sprite i,32,32
size sprite i,64,64
inc ang#,ang_inc#
next i
u0# = 0.0
u1# = 0.0625
s_num = (rpm * 12) + 3
for i = 1 to rpm + 1
set sprite texture coord s_num,0,u0#,0.0
set sprite texture coord s_num,1,u1#,0.0
set sprite texture coord s_num,2,u0#,1.0
set sprite texture coord s_num,3,u1#,1.0
inc s_num,1
inc u0#,.0625
inc u1#,.0625
next i
endfunction
requires media in the attachment