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

Username:   Password: 
 RegisterRegister   
 Adding borders to turingoutput screens.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
toolazy12




PostPosted: Wed Jun 01, 2011 1:41 pm   Post subject: Adding borders to turingoutput screens.

What is it you are trying to achieve?
I need to add a border to a turing program screen. Theres a rectangle, and you can move it with arrow keys. however, its possible to move the square out of theoutput screen. I have no idea how to set up the borders

Describe what you have tried to solve this problem
I've tried to put up an if structure but it hasn't been any helps..


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I'm really sorry its so long, I dont know how to attach a code..

Turing:


<%declaration section
var startpointx, startpointy : int := 0
var endpointx, endpointy : int := 50
var key : string (1)

%set screen mode and size
setscreen ("graphics:400;400")
setscreen ("noecho")
setscreen ("nocursor")
setscreen ("offscreenonly")

procedure display
    drawfillbox (startpointx, startpointy, endpointx, endpointy, white)
    drawfillbox (startpointx + 1, startpointy + 1, endpointx - 1, endpointy - 1, blue)
    getch (key)
    if key = chr (200) then
        startpointy := startpointy + 1
        endpointy := endpointy + 1
    elsif key = chr (208) then
        startpointy := startpointy - 1
        endpointy := endpointy - 1
    elsif key = chr (205) then
        startpointx := startpointx + 1
        endpointx := endpointx + 1
    else
        if key = chr (203) then
            startpointx := startpointx - 1
            endpointx := endpointx - 1
        else
            if (startpointx = 0 or startpointx = 350) and (startpointy = 0 or startpointy = 350) and (endpointx = 399 or endpointy = 0) and (endpointy = 399 or endpointy = 0) then
                startpointx := startpointx-1
                startpointy := startpointy-1
                endpointy := endpointy-1
                endpointx := endpointx-1
            end if
        end if
    end if
    View.Update
end display
%main program
loop
    display
    exit when key = chr (27)
end loop
>



Please specify what version of Turing you are using
The most recent..
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Wed Jun 01, 2011 4:13 pm   Post subject: Re: Adding borders to turingoutput screens.

Turing:

if x >= maxx then
     x = maxx
elsif x <= 0 then
     x = 0
end if
if y >= maxy then
     y = maxy
elsif y <= 0 then
     y = 0
end if

You could do something like that.
goroyoshi




PostPosted: Wed Jun 01, 2011 5:56 pm   Post subject: RE:Adding borders to turingoutput screens.

actually, there is a different way to do it in less lines, and its the proper way to do it, im in their class
Turing:

if key = chr (200) and endpointY < maxy then
    %insert movement here
end if

just do that with all 4 movements
toolazy12




PostPosted: Wed Jun 01, 2011 6:12 pm   Post subject: RE:Adding borders to turingoutput screens.

in my class?
and thanks a lot
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  [ 4 Posts ]
Jump to:   


Style:  
Search: