Skip to content
This repository has been archived by the owner on May 20, 2019. It is now read-only.

Commit

Permalink
Implement inter-map motion.
Browse files Browse the repository at this point in the history
Works like a charm, exactly how `sdd.org` says it should.
  • Loading branch information
vermiculus committed Nov 23, 2013
1 parent 8aff5ae commit 6ea3baa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Expand Up @@ -77,7 +77,7 @@ public BSInterface(BSSession session) {
}

private void LoadActiveRegions() {
final int VOFFSET = -50;
final int VOFFSET = 0;//-50;


Rectangle r_menu_button = vFlipRectangle(menubutton.getBoundingRectangle());
Expand Down Expand Up @@ -484,9 +484,9 @@ public void dispose() {
}
m.map.dispose();
}
cambatch.dispose();
controls.dispose();
assets.dispose();
//cambatch.dispose();
//controls.dispose();
//assets.dispose();
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/butterseal/src/edu/smcm/gamedev/butterseal/BSMap.java
Expand Up @@ -71,6 +71,15 @@ BSTile getPlayer(String key) {
}
return ret;
}

public static BSMap getByKey(String key) {
for (BSMap m : BSMap.values()) {
if (m.key.equals(key)) {
return m;
}
}
return null;
}
}

// Local Variables:
Expand Down
14 changes: 14 additions & 0 deletions src/butterseal/src/edu/smcm/gamedev/butterseal/BSPlayer.java
Expand Up @@ -58,6 +58,7 @@ public void setAnimations() {
static AssetManager assets;
public static OrthographicCamera camera;
BSAnimation walkUp, walkDown, walkRight, walkLeft, idle;
BSMap nextmap = null;
Sprite currentFrame;
/**
* The pixels yet to move
Expand Down Expand Up @@ -97,6 +98,12 @@ public void draw() {
// update moving state based on whether we have more to move
changeSprite(state.isMoving ? state.facing : null);
this.state.isMoving = displacement.x != 0 || displacement.y != 0;
if(!this.state.isMoving && this.nextmap != null) {
String oldkey = this.state.currentMap.key;
this.state.currentMap = this.nextmap;
this.nextmap = null;
this.place(oldkey);
}

this.currentFrame.draw(batch);

Expand Down Expand Up @@ -143,6 +150,13 @@ public void move(BSDirection direction) {
return;
}
this.state.isMoving = true;

// check to see if we need to move maps
HashMap<String,String> props = this.getFacingTile().getProperties(this.state.currentMap).get("player");
if (props.containsKey("player")) {
this.nextmap = BSMap.getByKey(props.get("player"));
}

if(direction != state.facing) {
if(BSSession.DEBUG) {
System.out.println("Moving " + direction);
Expand Down

0 comments on commit 6ea3baa

Please sign in to comment.