-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTutorial
106 lines (89 loc) · 2.84 KB
/
Tutorial
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package wave;
import org.lwjgl.input.Mouse;
import java.awt.Font;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
import grid.Waypoint;
import java.util.*;
import playerObjects.*;
public class Tutorial1 {
static int i = 0;
static float x = 0;
static float y = 0;
public static ArrayList<Enemy> tutorial(int milli) throws FileNotFoundException, IOException
{
//Does this need to be made a method instead that ccalls milli as a parameter in order to move every second?
//getpath uses grid locations, not pixel locations
//Does Vector2f use grid locations or pixel locations?
Vector2f startingLoc = new Vector2f(40, 40);
//Vector2f endingLoc = new Vector2f(8, 8);
// ArrayList<Waypoint> locs = new ArrayList<Waypoint>();
int tot = 0;
tot += milli;
Texture Elfy = TextureLoader.getTexture("jpg", new FileInputStream(new File("./res/Blue1.jpg")));
Vector2f size = new Vector2f(1, 1);
Icon img = new Icon(new Image(Elfy), size);
Vector2f loc = startingLoc;
Vector2f vel = new Vector2f(0, 0);
Enemy e = new HouseElf(loc, vel, size, img);
while(tot > 1)
{ tot = 0;
if((i %= 2) == 0)
{
y += 1;
}
else
{
x += 1;
}
}
i++;
e.setLoc(new Vector2f((e.getLoc().x + x*5), e.getLoc().y+y*5));
if((e.getLoc().x <= 290) || (e.getLoc().y <= 290))
{
e.render();
}
ArrayList<Enemy> es = new ArrayList<Enemy>();
return es;
//Doesn't work because Waypoint is non-functional
/*
Waypoint way = gr.getPath(startingLoc, endingLoc);
//Stores all the waypoints in the path in an arraylist
while(way.hasParent())
{
Waypoint parent = way.getParent();
locs.add(parent);
way = parent;
}
int count = 0;
int length = locs.size();
Vector2f wayloc = locs.get(i).getLoc();
//Do I replace gr.getGrid().length with gr.getGrid().width for y...?
loc = new Vector2f((loc.x + wayloc.x * gr.getSize().x/gr.getGrid().length),(loc.y + wayloc.y * gr.getSize().y/gr.getGrid().length));
*/
// loc = loc.scale(milli/1000);
//Moves enemy to the closest waypoint
//Apparently I don't need this?
/*
for(int i = length; i = 0; i--)
{
Enemy e = new HouseElf(loc, vel, size, img);
Vector2f wayloc = locs.get(i).getLoc();
loc = e.getDirection(loc, wayloc);
e.render();
}
*/
}
}