Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Drawing a Periodic Table
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
midnite13




PostPosted: Wed May 17, 2006 8:36 am   Post subject: Drawing a Periodic Table

Hello all,

I was wondering if I could get some advice on drawing a periodic table. I WOULD import it from a jpeg file, except I have to incorporate mousewhere into my program. Is there an easy and efficient way to do this so that I don't have a gigantic if-structure?

Thanks
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Wed May 17, 2006 9:37 am   Post subject: (No subject)

Well, here's an example, assuming you know where to take it from here.
code:

setscreen ("graphics:340;380,nobuttonbar,offscreenonly")
colorback (black)
color (white)
var element : array 1 .. 9, 1 .. 18 of string %Put elements here
var mx, my, mz : int

proc refresh
    cls
    for i : 1 .. 9  % y-values
        for q : 1 .. 18 % x-values
            drawbox ((q - 1) * 20, (i - 1) * 40, (1) * 20, (i) * 40, white)
        end for
    end for
    put "Element # ", ceil (mx / 20), ",", ceil (my / 40) %rounding up
    % You can now do something like
    % if mz = 1 then
    %   selectedElement := element (ceil (mx / 20), ceil (my / 40))
    % end if
    View.Update
end refresh

loop
    mousewhere (mx, my, mz)
    refresh
    exit when hasch
end loop

Now there will still be some if statements needed (because not all spots are used for elements), but just assign somethign to that empty spot and in your if statement, just check if that spot if empty or not (or if it is of greater value than the array)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: