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

Username:   Password: 
 RegisterRegister   
 Navigation
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Prince Pwn




PostPosted: Mon Oct 09, 2006 12:53 pm   Post subject: Navigation

I'm working on a little program possibly that will let you navigate kinda like explorer.

code:

View.Set ("graphics:1000,300;offscreenonly")
var boxCol, boxRad, boxX, boxY, button, cnt, driveCol, fontcol, ground, growX, growY,
    inc, mouseX, mouseY, pass : int
var font : int := Font.New ("comic sans ms:15")
var stop : int := Font.New ("comic sans ms:50")
boxCol := brightred
cnt := 0
driveCol := red
ground := 10
growX := 0
inc := 35
boxRad := inc div 2
var existant : string := ""
var drive : array 1 .. 26 of char
var done : boolean := false
var keys : array char of boolean

for i : 'A' .. 'Z'
    %if Dir.Exists (i + ":/") then
    %put i
    cnt += 1
    drive (cnt) := i
    %end if
end for

var boxes : array 1 .. cnt of int

for i : 1 .. cnt
    boxes (i) := inc * i
end for

procedure Pause
    cls
    Input.Flush
    loop
        exit when hasch
        Font.Draw ("PAUSED", maxx div 2 - 100, maxy div 2, stop, Rand.Int (0, 255))
        Font.Draw ("(press any key to continue)", maxx div 2 - 95, maxy div 2 - 50, font, black)
        View.Update
    end loop
    done := false
end Pause

loop
    drawfillbox (0, 0, maxx, maxy, 11)
    Mouse.Where (mouseX, mouseY, button)
    Input.KeyDown (keys)
    drawfilloval (mouseX, mouseY, 10, 10, boxCol)
    drawfillbox (370, 110, 620, 290, white)
    drawbox (370, 110, 620, 290, black)
    Font.Draw ("Hello " + Sys.GetUserName, maxx div 2 - 95, maxy div 2, font, black)
    Font.Draw ("on " + Sys.GetComputerName, maxx div 2 - 110, maxy div 2 - 20, font, black)
    for i : 1 .. cnt
        growX += inc
        if Dir.Exists (drive (i) + ":/") then
            driveCol := Rand.Int (0, 255)
        else
            driveCol := brightred
        end if
        drawfillbox (growX - inc div 2, ground, inc + growX, ground + inc, driveCol)
        drawbox (growX - inc div 2, ground, inc + growX, ground + inc, black)
        Font.Draw (drive (i), growX - inc div 2 div 2, 20, font, white)
        if button = 1 and mouseX > boxes (i) - boxRad and mouseX < boxes (i) + boxRad and
                Dir.Exists (drive (i) + ":/") and mouseY > 10 and mouseY < 45
                then
            put drive (i)
            if Sys.Exec (drive (i) + ":/") then
            end if
            done := true
            exit
        elsif button = 0 and mouseX > boxes (i) - boxRad and mouseX < boxes (i) + boxRad
                and mouseY > 10 and mouseY < 45 then
            locate (4, 1)
            if Dir.Exists (drive (i) + ":/") then
                fontcol := 33
                existant := " exists!"
            else
                fontcol := brightred
                existant := " does not exist"
            end if
            Font.Draw (drive (i) + existant /*+ " (" + (intstr (File.DiskFree (drive (i))) + ") ")*/,
                maxx div 2 - 75, maxy div 2 + 35, font, fontcol)
        end if
    end for
    if done or keys (KEY_ESC) then
        Pause
    end if
    growX := 0
    locate (1, 1)
    Font.Draw (intstr (mouseX), maxx div 2 - 50, maxy - 30, font, black)
    Font.Draw (intstr (mouseY), maxx div 2 + 10, maxy - 30, font, black)
    % colour (black)
    % for i : 1 .. cnt
    %     put boxes (i), " " ..
    % end for
    locate (5, 55)
    Font.Draw ("DRIVES", maxx div 2 - 80, maxy - 75, font, black)
    for i : 1 .. cnt
        if Dir.Exists (drive (i) + ":/") then
            colour (33)
            Font.Draw (drive (i), maxx div 2 - 15 + i * 8, maxy - 75, font, 33)
        end if
    end for
    View.Update
    cls
    if button = 1 then
        boxCol := 55
    else
        boxCol := brightred
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
NikG




PostPosted: Mon Oct 09, 2006 10:23 pm   Post subject: (No subject)

Interesting but kinda annoying:
I don't know if anyone experiences this but the prog keeps pausing and my floppy drive makes a weird noise whenever it checks if there's a disk in it (which is every loop iteration).

Also, this is not really an explorer since all you're doing is opening an actual explorer window with the c drive.

Why not try creating an actual file directory? I believe it's possible to get the names of all the files in a folder (or am I just imagining that?) so all you have to do is have a flexible array to load the name of each one and draw an icon reprsenting each one in your program.

Good start. I hope you take it further.
Prince Pwn




PostPosted: Tue Oct 10, 2006 12:06 am   Post subject: (No subject)

Oh sorry I never really tested it on a computer with a floppy drive =). Yeah if I continue to work on it, I can make it into an explorer. Dir.Open, Dir.Current, and Dir.Get.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: