Skip to content

Commit

Permalink
colisao com water funcionando
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgueiros committed Sep 28, 2020
1 parent 7d5f6a9 commit 1d10e12
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/main/java/com/lucasgueiros/ludovicus/maps/InvisibleCell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.lucasgueiros.ludovicus.maps;

import com.lucasgueiros.ludovicus.generics.Drawable;
import com.lucasgueiros.ludovicus.generics.Pair;
import java.awt.Graphics2D;

public class InvisibleCell extends Drawable {
public void draw(Graphics2D g, Pair relativeTo) {
}

public void update() {

}

public InvisibleCell (Pair position){
super(position,new Pair(25,25));
}
}
13 changes: 11 additions & 2 deletions src/main/java/com/lucasgueiros/ludovicus/maps/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.lucasgueiros.ludovicus.maps.elements.Tree;
import com.lucasgueiros.ludovicus.generics.Pair;
import com.lucasgueiros.ludovicus.maps.elements.FixedElement;
import com.lucasgueiros.ludovicus.generics.Drawable;

public class Map {

Expand All @@ -36,7 +37,7 @@ public class Map {

private Pair inicZero;

private List<FixedElement> objects = new ArrayList<>();
private List<Drawable> objects = new ArrayList<>();

public Map(String fileUrl) {
try {
Expand All @@ -57,6 +58,7 @@ public Map(String fileUrl) {

Element ground = (Element) doc.getElementsByTagName("ground").item(0);
NodeList lines = ground.getElementsByTagName("line");
int cellx = 0, celly = 0;
for(int i = 0 ; i < x; i++) {
String string = lines.item(i).getTextContent();
for(int j = 0; j <y; j++) {
Expand All @@ -72,7 +74,14 @@ public Map(String fileUrl) {
default:
map[i][j] = Cell.GRASS;
}

if(!map[i][j].isPodePassar()) {
objects.add(new InvisibleCell(new Pair(cellx,celly)));
}
cellx += 25;
}
celly += 25;
cellx = 0;
}

Element objectList = (Element) doc.getElementsByTagName("objects").item(0);
Expand Down Expand Up @@ -112,7 +121,7 @@ public void draw(Graphics2D g2d, Pair relativeTo){

}

public List<FixedElement> getObjects() {
public List<Drawable> getObjects() {
return objects;
}

Expand Down

0 comments on commit 1d10e12

Please sign in to comment.