Files
2025-06-07 01:59:34 -04:00

422 lines
16 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_03) on Fri Apr 23 12:22:23 EDT 2004 -->
<TITLE>
PhysicsEngine
</TITLE>
<META NAME="keywords" CONTENT="edu.gatech.cs2335.lemmings.physics.PhysicsEngine class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="PhysicsEngine";
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV CLASS&nbsp;
&nbsp;<A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsObject.html" title="class in edu.gatech.cs2335.lemmings.physics"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="PhysicsEngine.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
edu.gatech.cs2335.lemmings.physics</FONT>
<BR>
Class PhysicsEngine</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../../resources/inherit.gif" ALT="extended by"><B>edu.gatech.cs2335.lemmings.physics.PhysicsEngine</B>
</PRE>
<HR>
<DL>
<DT>public class <B>PhysicsEngine</B><DT>extends java.lang.Object</DL>
<P>
The Physics Engine.
This takes care of calculating movement due to gravity or velocity
in addition to taking care of World Collision Detection.
Revision History:
v1.7 (2004-04-13) - Added code for climbers, gliders, and floaters
v1.6a (2004-04-13) - VLAD: I updated the ray-tracing code for
the J direction, so that when the lemming or whatever
hits the ground, the first component is not -1, but
rather just the negative of the real value. The real
value cannot be negative, so that's fine. That fixes
the bug, where the lemming dies but doesn't really
reach ground visually.
v1.5a(2004-04-12) - Negative Gravity now works
v1.5 (2004-04-12) - Rewrote most of Physics Engine, PMD should shut
the hell up now. Added Particle calculations, fixed
rayTracing when falling up, calculations now work for
crazy Gravity settings up to around 11, above that and
strange things happen. Velocities will work at any
value, so long as gravity is not too wild a number.
Currently, a negative gravity causes problems.
v1.1 (2004-04-01) - Updated stuff so the lemmings' animation is
handled correctly upon reversing direction.
<P>
<P>
<DL>
<DT><B>Version:</B></DT>
<DD>1.7</DD>
<DT><B>Author:</B></DT>
<DD><A HREF="mailto:gtg184g@mail.gatech.edu">Jose Caban</A></DD>
</DL>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html#PhysicsEngine()">PhysicsEngine</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html#calculateNextPoint(java.util.List)">calculateNextPoint</A></B>(java.util.List&nbsp;poList)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Iterate through the list of Physics Objects and calculate their next
Positions</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html#calculateNextPoint(edu.gatech.cs2335.lemmings.physics.PhysicsObject)">calculateNextPoint</A></B>(<A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsObject.html" title="class in edu.gatech.cs2335.lemmings.physics">PhysicsObject</A>&nbsp;po)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Calculates the next point for the Physics Object</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.awt.image.BufferedImage</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html#getCurrentMap()">getCurrentMap</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get CurrentMap</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html" title="class in edu.gatech.cs2335.lemmings.physics">PhysicsEngine</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html#getInstance()">getInstance</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Method getInstance</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.awt.image.BufferedImage</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html#getUnbreakableMap()">getUnbreakableMap</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Method getUnbreakableMap</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html#setCurrentMap(java.awt.image.BufferedImage)">setCurrentMap</A></B>(java.awt.image.BufferedImage&nbsp;aMap)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the current gameplay level</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html#setUnbreakableMap(java.awt.image.BufferedImage)">setUnbreakableMap</A></B>(java.awt.image.BufferedImage&nbsp;unbreakableMap)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Method setUnbreakableMap</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.Object</B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ FIELD DETAIL =========== -->
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="PhysicsEngine()"><!-- --></A><H3>
PhysicsEngine</H3>
<PRE>
public <B>PhysicsEngine</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="getInstance()"><!-- --></A><H3>
getInstance</H3>
<PRE>
public static <A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsEngine.html" title="class in edu.gatech.cs2335.lemmings.physics">PhysicsEngine</A> <B>getInstance</B>()</PRE>
<DL>
<DD>Method getInstance
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the Physics Engine instance</DL>
</DD>
</DL>
<HR>
<A NAME="getCurrentMap()"><!-- --></A><H3>
getCurrentMap</H3>
<PRE>
public java.awt.image.BufferedImage <B>getCurrentMap</B>()</PRE>
<DL>
<DD>get CurrentMap
<P>
<DD><DL>
<DT><B>Returns:</B><DD>BufferedImage , currentMap</DL>
</DD>
</DL>
<HR>
<A NAME="getUnbreakableMap()"><!-- --></A><H3>
getUnbreakableMap</H3>
<PRE>
public static java.awt.image.BufferedImage <B>getUnbreakableMap</B>()</PRE>
<DL>
<DD>Method getUnbreakableMap
<P>
<DD><DL>
<DT><B>Returns:</B><DD>BufferedImage , unbreakable image</DL>
</DD>
</DL>
<HR>
<A NAME="setCurrentMap(java.awt.image.BufferedImage)"><!-- --></A><H3>
setCurrentMap</H3>
<PRE>
public void <B>setCurrentMap</B>(java.awt.image.BufferedImage&nbsp;aMap)</PRE>
<DL>
<DD>Set the current gameplay level
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>aMap</CODE> - the new game level</DL>
</DD>
</DL>
<HR>
<A NAME="setUnbreakableMap(java.awt.image.BufferedImage)"><!-- --></A><H3>
setUnbreakableMap</H3>
<PRE>
public static void <B>setUnbreakableMap</B>(java.awt.image.BufferedImage&nbsp;unbreakableMap)</PRE>
<DL>
<DD>Method setUnbreakableMap
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>unbreakableMap</CODE> - unbreakable image.</DL>
</DD>
</DL>
<HR>
<A NAME="calculateNextPoint(edu.gatech.cs2335.lemmings.physics.PhysicsObject)"><!-- --></A><H3>
calculateNextPoint</H3>
<PRE>
public void <B>calculateNextPoint</B>(<A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsObject.html" title="class in edu.gatech.cs2335.lemmings.physics">PhysicsObject</A>&nbsp;po)</PRE>
<DL>
<DD>Calculates the next point for the Physics Object
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>po</CODE> - the Physics object to calculate the next point for</DL>
</DD>
</DL>
<HR>
<A NAME="calculateNextPoint(java.util.List)"><!-- --></A><H3>
calculateNextPoint</H3>
<PRE>
public void <B>calculateNextPoint</B>(java.util.List&nbsp;poList)</PRE>
<DL>
<DD>Iterate through the list of Physics Objects and calculate their next
Positions
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>poList</CODE> - the list of Physics objects to iterate through</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV CLASS&nbsp;
&nbsp;<A HREF="../../../../../edu/gatech/cs2335/lemmings/physics/PhysicsObject.html" title="class in edu.gatech.cs2335.lemmings.physics"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="PhysicsEngine.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>