Computer Science Canada

Good ol' Etch-a-Sketch

Author:  Fashoomp [ Tue May 22, 2007 9:19 pm ]
Post subject:  Good ol' Etch-a-Sketch

It started off as just teaching myself arrow key movement on a box. I elaborated on that, and the etch a sketch took off from there. Arrow keys to move, space bar to clear, enter to change colour, mouse click, to start drawing from a new location (where you clicked) "D" to make pensize bigger, "A" to make it smaller. One flaw i cant seem to fix, is when you mouseclick somewhere else, it changes the pen size back to default. Can anyone fix this?
code:

View.Set ("offscreenonly")
var counter : int := 0
var x1 : int := 0
var x2 : int := 2
var y1 : int := 0
var y2 : int := 2
var colours : array 1 .. 7 of int := init (7, 12, 10, 13, 14, 9, 3)
var c_c : int := 1
var chars : array char of boolean

loop

    % put "(", x1 + 50, ")" ..
    % put "," ..
    % put "(", y1 + 50, ")" ..
    colour (counter)
    delay (25)

    drawfillbox (x1, y1, x2, y2, colours (c_c))
    Input.KeyDown (chars)
    if chars (chr (97)) then
        y1 := y1 - 1
        x1 += 1
    end if
    if chars (chr (115)) then
        y1 := y1 + 1
        x1 -= 1
    end if
    View.Update
    %200 up
    %208 down
    %205 right
    %203 left
    if chars (chr (10)) then
        c_c := c_c + 1
    end if
    if c_c = 7 then
        c_c := 1
    end if
    if chars (chr (32)) then
        cls
    end if
    if chars (chr (205)) then %right
        x1 := x1 + 2
        x2 := x2 + 2
    else
    end if
    var x, y, button : int

    mousewhere (x, y, button)
   
    if button = 1 then
        x1 := x
        y1 := y
        x2 := x + 2
        y2 := y + 2
    end if






    if chars (chr (203)) then                     %left
        x1 := x1 - 2
        x2 := x2 - 2
    else
    end if

    if chars (chr (208)) then                         %up
        y1 := y1 - 2
        y2 := y2 - 2
    else
    end if

    if chars (chr (200)) then                             %down
        y1 := y1 + 2
        y2 := y2 + 2
    else








    end if
    if x1 <= 0 or x2 <= 0 then
        x1 := maxx
        x2 := x1 - 2
    elsif y2 <= 0 or y1 <= 0 then
        y2 := maxy
        y1 := y2 - 2
    elsif y2 >= maxy - 1 or y1 >= maxy - 1 then
        y2 := 0
        y1 := y2 + 2
    elsif x1 >= maxx - 1 or x2 >= maxx - 1 then
        x1 := 0
        x2 := x1 + 2
    end if
    %if y1 >
end loop

Author:  ashiphire [ Wed May 23, 2007 7:13 am ]
Post subject:  RE:Good ol\' Etch-a-Sketch

nice

you should make it so can change the colour during the program is ruinning

Author:  lilmizeminem [ Wed May 23, 2007 10:41 am ]
Post subject:  RE:Good ol\' Etch-a-Sketch

yeah differant colours would be cool, bright ones lol

Author:  Fashoomp [ Wed May 23, 2007 10:50 am ]
Post subject:  Re: Good ol' Etch-a-Sketch

what are you talking about...you can change colours while the program is runnning...just press enter

Author:  lilmizeminem [ Wed May 23, 2007 10:54 am ]
Post subject:  RE:Good ol\' Etch-a-Sketch

ohh, i didnt notice that you should say that in the beginning or something.

Author:  ashiphire [ Wed May 23, 2007 10:58 am ]
Post subject:  RE:Good ol\' Etch-a-Sketch

yea you should have an instruction menu to explain how to completely use your program

Author:  Fashoomp [ Wed May 23, 2007 11:22 am ]
Post subject:  Re: Good ol' Etch-a-Sketch

Heres the new code with instructions
code:

put "Welcome to the etch-a-sketch"
put " "
put "Some commands you can use are:"
put "A and S keys to increase/decrease pen size"
put "Enter to change colours (does not work on slower comps)"
put "Space bar to 'shake' the etch a sketch"
put "Mouseclick to draw from a different location, fixing the age old problem"
put "of the etch a sketch (leaving a line across as you tried a smiley face"
put "Lastly, you can go through the edge of the screen and appear on the other side"
put " "
put "Any key to continue"
var ch:string (1)
getch (ch)
View.Set ("offscreenonly")
var counter : int := 0
var x1 : int := 0
var x2 : int := 2
var y1 : int := 0
var y2 : int := 2
var colours : array 1 .. 7 of int := init (7, 12, 10, 13, 14, 9, 3)
var c_c : int := 1
var chars : array char of boolean
cls
loop
    colour (counter)
    delay (25)

    drawfillbox (x1, y1, x2, y2, colours (c_c))
    Input.KeyDown (chars)
    if chars (chr (97)) then
        y1 := y1 - 1
        x1 += 1
    end if
    if chars (chr (115)) then
        y1 := y1 + 1
        x1 -= 1
    end if
    View.Update
    %200 up
    %208 down
    %205 right
    %203 left
    if chars (chr (10)) then
        c_c := c_c + 1
    end if
    if c_c = 7 then
        c_c := 1
    end if
    if chars (chr (32)) then
        cls
    end if
    if chars (chr (205)) then %right
        x1 := x1 + 2
        x2 := x2 + 2
    else
    end if
    var x, y, button : int

    mousewhere (x, y, button)
   
    if button = 1 then
        x1 := x
        y1 := y
        x2 := x + 2
        y2 := y + 2
    end if






    if chars (chr (203)) then                     %left
        x1 := x1 - 2
        x2 := x2 - 2
    else
    end if

    if chars (chr (208)) then                         %up
        y1 := y1 - 2
        y2 := y2 - 2
    else
    end if

    if chars (chr (200)) then                             %down
        y1 := y1 + 2
        y2 := y2 + 2
    else








    end if
    if x1 <= 0 or x2 <= 0 then
        x1 := maxx
        x2 := x1 - 2
    elsif y2 <= 0 or y1 <= 0 then
        y2 := maxy
        y1 := y2 - 2
    elsif y2 >= maxy - 1 or y1 >= maxy - 1 then
        y2 := 0
        y1 := y2 + 2
    elsif x1 >= maxx - 1 or x2 >= maxx - 1 then
        x1 := 0
        x2 := x1 + 2
    end if
end loop

Author:  Tallguy [ Thu May 24, 2007 11:47 am ]
Post subject:  Re: Good ol' Etch-a-Sketch

IOt's a pretty cool program, i like how when it goes off screen it goes back at the opposite pole... try to make it to change colors every time you go a diffenert direction....that would be sweet Wink

Author:  tenniscrazy [ Thu May 24, 2007 4:14 pm ]
Post subject:  RE:Good ol\' Etch-a-Sketch

pretty cool...but when i made the thing relly big it messed up so that it was like a line or something, not a square..then it started switching so a made it bigger then a made it smaller again.


: