
-----------------------------------
computer_killer
Thu Dec 16, 2004 12:08 pm

i need help moving it
-----------------------------------
what is the code for moving an object? im doing frogger for a class project. :lol:  :oops:

-----------------------------------
Delos
Thu Dec 16, 2004 1:46 pm


-----------------------------------
None exists.

If you want to move an object/picture on the other hand, there are numerous ways of doing it, the most common being that one uses variable x-coord and y-coord values, and in some sort of loop systematically change them.

Post your code:
- we'll get a better idea of where you are
- you'll more precise help

-----------------------------------
Tony
Thu Dec 16, 2004 5:07 pm

Re: i need help moving it
-----------------------------------
what is the code for moving an object?

Object.move(newLocation)

now that's assuming that your object has a working move method. :wink:

-----------------------------------
Cervantes
Thu Dec 16, 2004 5:18 pm


-----------------------------------
Tony: And that the object moves in a one dimensional plane :wink:

You probably won't have an object, per se, as you're working in Turing.  You will probably have a bunch of variables that you clump together to store information about your "object".  
When you draw your object on the screen, you'll be using (most likely, as Delos pointed out) two variables, x and y.  That is, your Draw command will use these two variables.  Thus, changing these variables will change the location of the "object", making it "move".

If you want to be able to move the "object" in one line, you'll have to make a procedure (like what Tony was getting at):

procedure MoveObject (newX, newY : int)
  objectX := newX
  objectY := newY
end MoveObject

MoveObject (100, 148)


-----------------------------------
Tony
Thu Dec 16, 2004 5:29 pm


-----------------------------------
Tony: And that the object moves in a one dimensional plane :wink:
Not if newLocation is a datatype that includes more than one dimention :wink: Notice how I haven't specified that it's

3Dpoint newLocation = new 3Dpoint(x,y,z)

 :lol:

-----------------------------------
Cervantes
Thu Dec 16, 2004 5:47 pm


-----------------------------------
Somehow, when I posted that comment, I knew you were going to comeback with some computer kung-fu science and prove me wrong.
Bah!
I think we should be keeping things simpler than that, in this thread.

-----------------------------------
Tony
Thu Dec 16, 2004 6:05 pm


-----------------------------------
fair enough. And it's kung-foo :wink: 
so..

var x : int := 0
loop
    x += 5 %move 5 pixels to the right
    Draw.FillBox (x, 100, x + 5, 105, blue)
    delay (20)
    cls
    exit when x >= maxx %reached the end of the screen
end loop

