TGC Codebase Backup



Extremely useful mouse code detector, with image positioning! (saves all info to text file!) by Aralox

13th Jul 2007 8:27
Summary

A very very useful program which can load and position (in realtime) images onto the screen, and stores click coordinates into a text file. very easy to use, and very flexible. Us



Description

A very very useful program which can load and position (in realtime) images onto the screen, and stores click coordinates into a text file. very easy to use, and very flexible.
Use this for finding the coordinates of buttons, or where to place a picture onto the screen, or where to draw an object, ect. just load images onto the screen, and get clicking!
please credit if used!
www.freewebs.com/aralox

sorry if i seem a little too enthusiastic but this program took me hours to make, it was unbelievably buggy!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `mouse position detecter & storer
`this code is useful when you need coordinates for buttons, pic positions, ect
`please drop me a note at my website if you found this helpful!
`credit if used!
`by aralox
`www.freewebs.com/aralox


file = 0
li = 0
nv = 0
dim name$(32)
dim imagepos(9,2)
dim imagesu$(9)

start:
cls
print "welcome to the mouse position detecter & storer"
print "how many storage variables? (type in 909 to end)"
input sv
if sv = 909 then end

undim storagevx(sv)
undim storagevy(sv)

print "do you want to load an image? (y) you can have up to nine"
input iml$
if iml$ = "y" then gosub loadimage

dim storagevx(sv)
dim storagevy(sv)
num = 0
mousedown = 0
file = file + 1
imagestatus = 0
nv = nv + 1
currentimage = 1

do
   cls
   mx = mousex()
   my = mousey()
   print "mouse x = "+str$(mx)+" , mouse y = "+str$(my)+" "+str$(num)+" out of "+str$(sv)+" numbers stored. press upkey to finish"

   if num<sv then print "position x "+str$(storagevx(num))+" and position y "+str$(storagevy(num))+" has been stored"
   if num=sv then print "storage variables exausted. press the upkey to save"

   if inkey$() = "1" then currentimage = 1
   if inkey$() = "2" then currentimage = 2
   if inkey$() = "3" then currentimage = 3
   if inkey$() = "4" then currentimage = 4
   if inkey$() = "5" then currentimage = 5
   if inkey$() = "6" then currentimage = 6
   if inkey$() = "7" then currentimage = 7
   if inkey$() = "8" then currentimage = 8
   if inkey$() = "9" then currentimage = 9

   if currentimage = 0 then currentimage = 1

   text 0, 440, "Image "+str$(currentimage)+" is currently selected."
   text 0, 460, " press 1-9 to select and move around an image with the right mouse button."

   if mouseclick() = 1
      if mousedown = 0
         mousedown = 1
         if num<sv
            num = num+1 : storagevx(num) = mx : storagevy(num)= my
         endif
      endif
   endif

   for refreshimage = 1 to 9
      if image exist(refreshimage)
         paste image refreshimage, imagepos(refreshimage,1), imagepos(refreshimage,2)
      endif
   next refreshimage

   if mouseclick() = 2
      if image exist(currentimage)
         imagepos(currentimage,1) = mx
         imagepos(currentimage,2) = my
         paste image currentimage, imagepos(currentimage,1),imagepos(currentimage,2)
      endif
   endif

   if mouseclick() <> 1 then mousedown = 0
   if upkey() = 1 then goto save
loop


loadimage:
cls
if li = 9 then return
li = li + 1
print "these are the contents of the directory you are in"
print "please type in the image you want to use (with the extension)"
print " type in 'none' if you dont want to load anything"
print " "
dir
input image$
if image$ = "none" then return
imagesu$(li) = image$
load image image$, li
paste image li , 100 , 300
print "That was image "+str$(li)+". remember that. load another? (y)"
input anotherimage$
if anotherimage$ = "y" then goto loadimage
return


save:
cls
if nv < 32
   print "Storage file name? (using the same name will overwrite the file)"
   print "if you dont want to save a file then press 'n'"
   input tempname$
   if tempname$ = "n" then end
   name$(nv) = tempname$

   if file exist(tempname$+".txt") = 1 then delete file tempname$+".txt"

   open to write file, tempname$+".txt"

   for i = 1 to sv
     write string file,"x:"+str$(storagevx(i))+"     y: "+str$(storagevy(i))
   next i
   write string file,"thank you for using aralox's mouse detector!"
   write string file,"www.freewebs.com/aralox"

   print "again? (y)"
   input again$
   if again$ = "y" then goto start
else
   print "sorry file limit reached (32). press any key to quit. (run this program again to save another 32 files!)"
   goto finish
endif

finish:
cls
print " "
print "your file(s) have be stored in the directory this program is located in"
print "                              -files-"
for f = 1 to sv
   print "                              "+name$(f)
next f
print " "
print "                           -images used-"
for imagesused = 1 to li
   print "                           "+imagesu$(imagesused)
next imagesused
print " "
print "thank you for using aralox's mouse detector!"
print "www.freewebs.com/aralox"
print "press any key to end"

wait key
end