
-----------------------------------
hq78
Fri Dec 24, 2004 12:48 am

How to draw a line controlled by user..
-----------------------------------
My Code for cursor controlling:


var x, y : int := 100
var col : int := 16
var switch := 0
var chars : array char of boolean

loop
    if switch = 0 then
        col := col + 1
    elsif switch = 1 then
        col := col - 1
    end if
    if col = 30 then
        switch := 1
    elsif col = 16 then
        switch := 0
    end if
    drawfilloval (x, y, 1, 1, col)
    delay (5)
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) and y < maxy then
        y := y + 1
    end if
    if chars (KEY_DOWN_ARROW) and y > 0 then
        y := y - 1
    end if
    if chars (KEY_LEFT_ARROW) and x > 0 then
        x := x - 1
    end if
    if chars (KEY_RIGHT_ARROW) and x < maxx then
        x := x + 1
    end if
end loop

I need to change the drawfilloval into drawline so the user can control a line instead of an oval but when i do it draws it horribly wrong. I want to make a snake game, and i need the tail of  the line to follow the user's cursor movements. Can someone tell me how to do it? or give me  hints to how to do it? Thanks in advanced

-----------------------------------
McKenzie
Wed Dec 29, 2004 9:31 am


-----------------------------------
Hey cool "etch-a-sketch",

The difference between a line and an oval is that you need two points with a line and only one with an oval. If you wanted to use a line you would need to keep track of the old x and y positions each time around the loop.

Unfortunately that won't get you any further ahead in making your snake game, just a different version of your "etch-a-sketch".  What you need to do is see your snake as a number of segments. You can draw the segments as ovals, boxes or bitmaps.... The important part is how you store the locations of all of the segments. You will need to use an array for that.

-----------------------------------
hq78
Sun Jan 02, 2005 4:20 pm


-----------------------------------
thanks for an idea!
