Computer Science Canada

Help with Character Graphics in Loops

Author:  nmr123321 [ Tue Dec 06, 2005 5:21 pm ]
Post subject:  Help with Character Graphics in Loops

If you run the program you'll see that the bus is moving left to right. I want to run the car right to left from row 10 but its not working. I tried putting both of these loops in a loop but its not working


code:

var row := 2
var column := 1

loop
    locate (row - 1, 1)
    put repeat ("=", 80)
    %___________________________________________
    locate (row, column)
    put "  ,-----.,-----.,---.\\\\       "
    locate (row + 1, column)
    put "  ||     ||     ||    \\\\      "
    locate (row + 2, column)
    put " |`-----'|-----||-----\\\\`----."
    locate (row + 3, column)
    put "  [       |    -||-   _|    (|  "
    locate (row + 4, column)
    put "  [  ,--. |_____||___/.--.   |  "
    locate (row + 5, column)
    put "  =-(( `))-----------(( `))-==  "
    %_________________________________________________
    locate (row + 6, 1)
    put repeat ("=", 80)
    delay (500)
    %______________________________________________
    locate (row, column)
    put "                                "
    locate (row + 1, column)
    put "                                "
    locate (row + 2, column)
    put "                                "
    locate (row + 3, column)
    put "                                "
    locate (row + 4, column)
    put "                                "
    locate (row + 5, column)
    put "                                "
    %___________________________________________
    if column = 50 then
        column := 1

    end if
    column := column + 1

    %_________________________________________________
end loop

loop
var row1 := 10
var column1 := 80

locate (row1, column1)
put "___//__][__\\\\___\\"
locate (row1 + 1, column1)
put "(o _ |  -|   _   o| "
locate (row1 + 2, column1)
put " `(_)-------(_)---' "


if column1 = 60 then
    column1 := 80
end if
column1 := column1 -1
end loop

Author:  Tony [ Tue Dec 06, 2005 5:39 pm ]
Post subject: 

well you are never exiting your first loop, so it will continue on forever.

Author:  GlobeTrotter [ Tue Dec 06, 2005 5:52 pm ]
Post subject: 

Try putting them in the same loop.

Author:  DIIST [ Tue Dec 06, 2005 7:19 pm ]
Post subject: 

Try A Counted LOOP! Like the bellow.
code:

var row := 2
for column:1..maxcol
    locate (row - 1, 1)
    put repeat ("=", 80)
    %___________________________________________
    locate (row, column)
    put "  ,-----.,-----.,---.\\\\       "
    locate (row + 1, column)
    put "  ||     ||     ||    \\\\      "
    locate (row + 2, column)
    put " |`-----'|-----||-----\\\\`----."
    locate (row + 3, column)
    put "  [       |    -||-   _|    (|  "
    locate (row + 4, column)
    put "  [  ,--. |_____||___/.--.   |  "
    locate (row + 5, column)
    put "  =-(( `))-----------(( `))-==  "
    %_________________________________________________
    locate (row + 6, 1)
    put repeat ("=", 80)
    delay (100)
    %______________________________________________
    locate (row, column)
    put "                                "
    locate (row + 1, column)
    put "                                "
    locate (row + 2, column)
    put "                                "
    locate (row + 3, column)
    put "                                "
    locate (row + 4, column)
    put "                                "
    locate (row + 5, column)
    put "                                "
     

    %_________________________________________________
end for
Thats pretty cool thought, that you doing animation with characters!


: