TGC Codebase Backup



scientific graphical calculator by Anonymous Coder

11th Aug 2004 18:13
Summary

scientific graphical calculator not really working, but it runs .exe file available



Description

Dear friendzone,
i was unable to affix graphical functions, but mostly the axes are there so as 4 layers of different distination axes, the four ages of the screen, the centre,and a zoom of the centre axes



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    global pushed_this$
`global txt$


global maxx,maxy,halfx,halfy,layer1_x,layer2_x,layer1_y,layer2_y
global centre1_x,centre1_y,zoom1_x,zoom1_y,linex1,line1y,linex2,line2y
global add1_x,add1_y
maxx=screen width()
maxy=screen height()
halfx=maxx/2
halfy=maxy/2
add1_x=1
add1_y=1

x=maxx
y=0

do
cls
make_button(halfx*(0.15625*11),halfy*(0.1*15),200.0,0.0,0.0,"zoom in")
make_button(halfx*(0.15625*11),halfy*(0.1*16),200.0,0.0,0.0,"zoom out")
axes()
print_layer1_xy_2int(10,10,mousex(),mousey())
print_layer2_xy_2int(10,70,mousex(),mousey())
print_layer3_xy_2int(10,130,mousex(),mousey())
print_layer4_xy_2int(10,190,mousex(),mousey())
print_centre_xy_2int(halfx*1.8,halfy*1/24,mousex(),mousey())
print_zoom_xy_2int(halfx*1.8,halfy*(0.2916667),mousex(),mousey())

loop
wait key
end




function axes()
line 0,halfy,maxx,halfy
line halfx,0,halfx,maxy
endfunction

function print_layer1_xy_2int(x,y,integer1,integer2)
set cursor x,y
print "Layer 1"
set cursor x,y+15
layer1_x=integer1
print layer1_x
set cursor x,y+30
layer1_y=integer2
print layer1_y
endfunction

function print_layer2_xy_2int(x,y,integer1,integer2)
set cursor x,y
print "Layer 2"
set cursor x,y+15
layer2_x=maxx-integer1
print layer2_x
set cursor x,y+30
layer2_y=maxy-integer2
print layer2_y
endfunction

function print_layer3_xy_2int(x,y,integer1,integer2)
set cursor x,y
print "Layer 3"
set cursor x,y+15
layer2_x=integer1
print layer2_x
set cursor x,y+30
layer2_y=maxy-integer2
print layer2_y
endfunction

function print_layer4_xy_2int(x,y,integer1,integer2)
set cursor x,y
print "Layer 4"
set cursor x,y+15
layer2_x=maxx-integer1
print layer2_x
set cursor x,y+30
layer2_y=integer2
print layer2_y
endfunction

function print_centre_xy_2int(x,y,integer1,integer2)
set cursor x,y
print "Centre"
set cursor x,y+15
if (integer1>halfx) then:centre1_x=integer1-halfx
if (integer1<halfx) then:centre1_x=integer1-halfx
print centre1_x
set cursor x,y+30
if (integer2>halfy)then:centre1_y=-(integer2-halfy)
if (integer2<halfy)then:centre1_y=-(integer2-halfy)
print centre1_y
endfunction


function print_zoom_xy_2int(x,y,integer1,integer2)
set cursor x,y
print "Zoom"
set cursor x,y+15
if (integer1>halfx) then:zoom1_x=integer1-halfx:zoom1_x=((zoom1_x*add1_x)/50)
if (integer1<halfx) then:zoom1_x=integer1-halfx:zoom1_x=((zoom1_x*add1_x)/50)
print zoom1_x
set cursor x,y+30
if (integer2>halfy)then:zoom1_y=-(integer2-halfy):zoom1_y=((zoom1_y*add1_y)/50)
if (integer2<halfy)then:zoom1_y=-(integer2-halfy):zoom1_y=((zoom1_y*add1_y)/50)
print zoom1_y
endfunction

`function draw_function(integer1,integer2)
`spotx=(integer1)/zoom1_x
`spoty=(integer2)/zoom1_y
`dot spotx,spoty
`endfunction

function make_button(x,y,r#,g#,b#,txt$)
button(x,y,txt$,r#,g#,b#)
endfunction


function button(x,y,txt$,r#,g#,b#)
   ` code made by Atreides (I don't mind if you don't add me to your credits ^^)
   ` X ans Y are the center of the button
   ` txt is the text of the button
   ` r, g and b is the color of the button
   mob as boolean
   if mousex()>x-text width(txt$)/2-6 and mousex()<x+text width(txt$)/2+6
      if mousey()>y-text height(txt$)/2-2 and mousey()<y+text height(txt$)/2+2
         if mouseclick()=1 then :mob=1:pushed_this$=txt$:cls 0:switch_states()
      endif
   endif
   if mob=0
      ink rgb(r#*0.7,g#*0.7,b#*0.7),0
      box x-text width(txt$)/2-6,y-text height(txt$)/2-2,x+text width(txt$)/2+6,y+text height(txt$)/2+4
      ink rgb(r#,g#,b#),0
      box x-text width(txt$)/2-3,y-text height(txt$)/2,x+text width(txt$)/2+3,y+text height(txt$)/2+2
      if (r#+g#+b#)/3>=128
         ink rgb(0,0,0),0
      else
         ink rgb(255,255,255),0
      endif
      text x-text width(txt$)/2,y-text height(txt$)/2,txt$
   else
      repeat
         ink rgb(r#,g#,b#),0
         box x-text width(txt$)/2-6,y-text height(txt$)/2-2,x+text width(txt$)/2+6,y+text height(txt$)/2+4
         ink rgb(r#*0.7,g#*0.7,b#*0.7),0
         box x-text width(txt$)/2-3,y-text height(txt$)/2,x+text width(txt$)/2+3,y+text height(txt$)/2+2
         if (r#*0.7+g#*0.7+b#*0.7)/3>=128
            ink rgb(0,0,0),0
         else
            ink rgb(255,255,255),0
         endif
         text x-text width(txt$)/2,y-text height(txt$)/2,txt$
         sync
      until mouseclick()=0
      if mousex()>x-text width(txt$)/2-6 and mousex()<x+text width(txt$)/2+6 and mousey()>y-text height(txt$)/2-2 and mousey()<y+text height(txt$)/2+2
         if mouseclick()=1 then mob=1
      else
         mob = 0
      endif
   endif
   ink rgb(255,255,255),0
endfunction mob


function switch_states()
if (pushed_this$="zoom in")then:add1_x=add1_x+1:add1_y=add1_y+1
if (pushed_this$="zoom out")then:add1_x=add1_x-1:add1_y=add1_y-1
if (add1_x<0)then:add1_x=0
if (add1_y<0)then:add1_y=0
endfunction


function print_xy_message(x,y,message$)
set cursor x,y
print message$
endfunction