-
Notifications
You must be signed in to change notification settings - Fork 0
/
World.java
75 lines (52 loc) · 2.71 KB
/
World.java
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
package com.ks2002br.world;
import java.awt.image.BufferedImage;
import com.ks2002br.entities.Enemy;
import com.ks2002br.entities.Player;
import com.ks2002br.entities.itens.Ammo;
import com.ks2002br.entities.itens.Gun;
import com.ks2002br.entities.itens.Key;
import com.ks2002br.entities.itens.KeyCard;
import com.ks2002br.entities.itens.Medkit;
import com.ks2002br.entities.itens.Potion;
import com.ks2002br.frameworks.Bloco;
import com.ks2002br.frameworks.GameController;
import com.ks2002br.frameworks.ObjectId;
import com.ks2002br.game.Game;
public class World {
private BufferedImage level;
private GameController gc;
public static int w,h;
public World(BufferedImage level, GameController gc) {
this.level = level;
this.gc = gc;
w=level.getWidth();
h=level.getHeight();
System.out.println("[DEBUG WORLD] MAPA x,y = "+w*32+ " , "+h*32);
}
public void carregarLevel() {
for (int xx = 0; xx < h; xx++) {
for (int yy = 0; yy < w; yy++) {
int pixel = level.getRGB(xx, yy);
if(pixel == 0xFFFFFFFF) Game.gc.addObj(new Bloco(xx*32, yy*32, 0,ObjectId.BLOCO)); //GRAMA
else if(pixel == 0xFF7F3300) Game.gc.addObj(new Bloco(xx*32, yy*32, 1,ObjectId.BLOCO)); // TERRA ESQ
else if(pixel == 0xFFFFD800) Game.gc.addObj(new Bloco(xx*32, yy*32, 2,ObjectId.BLOCO)); //TERRA CENTRAL
else if(pixel == 0xFF7C3C11) Game.gc.addObj(new Bloco(xx*32, yy*32, 3,ObjectId.BLOCO)); //TERRA DIR
else if(pixel == 0xFFFF0000) Game.gc.addObj(new Player(xx*32,yy*32,3,ObjectId.PLAYER, gc));
else if(pixel == 0xFFFF6A00 )Game.gc.addObj(new Enemy(xx*32,yy*32,0,ObjectId.ENEMY)); //INIMIGO
else if(pixel == 0xFF0026FF)Game.gc.addObj(new Enemy(xx*32,yy*32,1,ObjectId.ENEMY));
//Criando os itens
else if(pixel == 0xFF0028FF)Game.gc.addObj(new Medkit(xx*32,yy*32,1,ObjectId.MEDKIT));
else if(pixel == 0xFF002CFF)Game.gc.addObj(new Medkit(xx*32,yy*32,2,ObjectId.MEDKIT));
else if(pixel == 0xFF0032FF)Game.gc.addObj(new Potion(xx*32,yy*32,1,ObjectId.POTION));
else if(pixel == 0xFF003AFF)Game.gc.addObj(new Potion(xx*32,yy*32,2,ObjectId.POTION));
else if(pixel == 0xFF0040FF)Game.gc.addObj(new Gun(xx*32,yy*32,1,ObjectId.GUN));
else if(pixel == 0xFF0046FF)Game.gc.addObj(new Ammo(xx*32,yy*32,2,ObjectId.BOX_AMMO));
else if(pixel == 0xFF0050FF)Game.gc.addObj(new Ammo(xx*32,yy*32,1,ObjectId.AMMO));
else if(pixel == 0xFF005AFF)Game.gc.addObj(new Key(xx*32,yy*32,ObjectId.KEY));
else if(pixel == 0xFF0062FF)Game.gc.addObj(new KeyCard(xx*32,yy*32,1,ObjectId.KEY_CARD));
else if(pixel == 0xFF006EFF)Game.gc.addObj(new KeyCard(xx*32,yy*32,2,ObjectId.KEY_CARD));
}
}
System.out.println("[DEBUG WORLD] MAPA CARREGADO OK!");
}
}