-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.java
More file actions
34 lines (31 loc) · 764 Bytes
/
Copy pathModel.java
File metadata and controls
34 lines (31 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Name: Jacob Smith
//Date: 9/11/20
//Descriptions: This is the class that has the math and tells program how
//to move the turtle throughout the screen
class Model
{
int turtle_x;
int turtle_y;
int dest_x;
int dest_y;
Model()
{
}
public void update()
{
// Move the turtle
if(this.turtle_x < this.dest_x)
this.turtle_x += Math.min(4, dest_x - turtle_x);
else if(this.turtle_x > this.dest_x)
this.turtle_x += Math.min(4, dest_x - turtle_x);
if(this.turtle_y < this.dest_y)
this.turtle_y += Math.min(4, dest_y - turtle_y);
else if(this.turtle_y > this.dest_y)
this.turtle_y += Math.min(4, dest_y - turtle_y);
}
public void setDestination(int x, int y)
{
this.dest_x = x;
this.dest_y = y;
}
}