Skip to content

Commit

Permalink
Initial codebase commit
Browse files Browse the repository at this point in the history
Stuff from 2013, fixed up so that you *should* be able to build it out of the box.
  • Loading branch information
trigger-segfault committed May 19, 2019
1 parent 575e778 commit fc94579
Show file tree
Hide file tree
Showing 459 changed files with 14,528 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Custom
out/
profiles/
unused/

# Package Files #
*.jar
*.war
Expand All @@ -21,3 +26,59 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
#*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
6 changes: 6 additions & 0 deletions MetroidMapGuardian/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="out"/>
</classpath>
47 changes: 47 additions & 0 deletions MetroidMapGuardian/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MetroidMapGuardian</name>
<comment>A map viewer and powerup collector for the Metroid Prime Trilogy.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/builder.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1558289867571</id>
<name></name>
<type>10</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-bin</arguments>
</matcher>
</filter>
<filter>
<id>1558289867580</id>
<name></name>
<type>10</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-profiles</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
19 changes: 19 additions & 0 deletions MetroidMapGuardian/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project MetroidMapGuardian">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required -->
<!--define folder properties-->
<property name="dir.buildfile" value="."/>
<property name="dir.workspace" value="${dir.buildfile}/.."/>
<property name="dir.jarfile" value="${dir.buildfile}/bin"/>
<target name="create_run_jar">
<jar destfile="${dir.jarfile}/MetroidMapGuardian.jar" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="main.Main"/>
<attribute name="Class-Path" value="."/>
<attribute name="SplashScreen-Image" value="resources/images/splash.png"/>
</manifest>
<fileset dir="${dir.buildfile}/out"/>
</jar>
</target>
</project>
12 changes: 12 additions & 0 deletions MetroidMapGuardian/builder.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="MetroidMapGuardian"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/MetroidMapGuardian/build.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
208 changes: 208 additions & 0 deletions MetroidMapGuardian/src/entity/Entity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
package entity;

import java.awt.Graphics2D;

import nbt.NBTTagCompound;

import room.Room;
import game.GameInstance;
import game.Trilogy;
import geometry.Rectangle;
import geometry.Vector;

/**
* A base class for all objects that are contained in, and interact with the map.
*
* @author Robert Jordan
*
* @see
* {@linkplain Map},
* {@linkplain GameInstance}
*/
public abstract class Entity {

// =================== Private Members ====================

/**
* The last known direction of the entity. This is used when
* the entities velocity is 0.
*/
private double lastDirection;

// ==================== Public Members ====================

/** The game this entity is linked to. */
public GameInstance instance;
public Trilogy trilogy;
/** The room that contains this entity. */
public Room room;
/**
* A string that represents a way to access the entity without receiving
* information about it in advance.
*/
public String id;
/**
* The draw depth of the entity, entities with higher depths will draw
* before entities with lower depths.
*/
public int depth;
/** The position on the map of the entity. */
public Vector position;
/** The speed of the entity in units per update. */
public Vector velocity;

public Rectangle bounds;
/** True if the entity has been destroyed. */
public boolean destroyed;

// ===================== Constructors =====================

/**
* The default constructor, constructs an entity at (0, 0).
*
* @return Returns the default entity.
*/
protected Entity() {
this.instance = null;
this.trilogy = null;
this.room = null;

this.id = "";
this.depth = 0;

this.position = new Vector();
this.velocity = new Vector();
this.lastDirection = 0.0;

}
/**
* Constructs an entity with the specified details.
*
* @param id - The key identifier of the entity.
* @param depth - The depth of the entity.
* @param position - The position of the entity.
* @param velocity - The velocity of the entity.
* @return Returns an entity with the specified details.
*/
protected Entity(String id, int depth, Vector position, Vector velocity) {
this.instance = null;
this.trilogy = null;
this.room = null;

this.id = id;
this.depth = depth;

this.position = new Vector(position);
this.velocity = new Vector(velocity);
this.lastDirection = 0.0;

}
/**
* Constructs the entity from an NBT compound of values. This is mainly used
* To load entire maps from file in NBT format.
*
* @param nbt - The compound containing the tags related to the entity.
* @return Returns the entity constructed from tag data.
*
* @see
* {@linkplain NBTElement},
* {@linkplain NBTTagCompound}
*/
protected Entity(NBTTagCompound nbt) {
instance = null;
trilogy = null;
room = null;

id = nbt.getString("id", "");
depth = nbt.getInteger("depth");

if (nbt.hasKey("speed") || nbt.hasKey("direction"))
velocity = new Vector(nbt.getDouble("speed"), nbt.getDouble("direction"), true);
else
velocity = new Vector(nbt.getDouble("hspeed"), nbt.getDouble("vspeed"));
position = new Vector(nbt.getDouble("x"), nbt.getDouble("y"));
lastDirection = nbt.getDouble("direction");

}
/**
* Initializes the entity by setting the game instance it is linked to.
*
* @param room - The room that contains the entity.
* @param instance - The game instance that contains the room.
*/
public void initialize(Room room, GameInstance instance, Trilogy trilogy) {
this.room = room;
this.trilogy = trilogy;
this.instance = instance;
}

// ===================== NBT File IO ======================

/**
* Saves tag information about the entity to the NBT compound.
*
* @param nbt - The NBT compound to save tag information to.
*
* @see
* {@linkplain NBTTagCompound}
*/
public void saveEntity(NBTTagCompound nbt) {
nbt.setString( "id", id);
nbt.setInteger( "depth", depth);
nbt.setDouble( "x", position.x);
nbt.setDouble( "y", position.y);
nbt.setDouble( "hspeed", velocity.x);
nbt.setDouble( "vspeed", velocity.y);
nbt.setDouble( "lastDirection", lastDirection);
}
/**
* Saves the entity to an NBT compound tag.
*
* @return Returns the NBT compound containing the values on the entity.
*
* @see
* {@linkplain NBTTagCompound}
*/
public abstract NBTTagCompound saveEntity();
/**
* Creates an entity based on the information given from an NBT compound. The
* entity must first be defined in EntityLoader in order to be loaded from a
* map file.
*
* @param nbt - The NBT compound containing tag information on the entity.
* @return Returns an entity constructed from the specified tag information.
*
* @see
* {@linkplain NBTTagCompound},
* {@linkplain EntityLoader}
*/
public abstract Entity loadEntity(NBTTagCompound nbt);

// ======================== Updating ========================

/**
* Called every step for the entity to perform actions and update.
*/
public void update() {

// Update position
position.add(velocity);

}
/**
* Called every step for the entity to draw to the screen.
*
* @param g - The graphics object to draw to.
*/
public void draw(Graphics2D g) {

}
/**
* Destroys the entity and marks it for removal.
*/
public void destroy() {
destroyed = true;
}

}

Loading

0 comments on commit fc94579

Please sign in to comment.