Added Some Documentation...
This commit is contained in:
parent
f3c3997fe3
commit
b2777bbf68
20 changed files with 688 additions and 551 deletions
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -6,7 +6,17 @@
|
|||
</artifacts-to-build>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="aa440324-95db-4232-b779-41095ebcca0f" name="Default" comment="" />
|
||||
<list default="true" id="aa440324-95db-4232-b779-41095ebcca0f" name="Default" comment="">
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/artifacts/Astroids2D_jar/Astroids2D.jar" afterPath="$PROJECT_DIR$/out/artifacts/Astroids2D_jar/Astroids2D.jar" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Engine/GameEngine.java" afterPath="$PROJECT_DIR$/src/Engine/GameEngine.java" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/GamePanels/GamePanel.java" afterPath="$PROJECT_DIR$/src/GamePanels/GamePanel.java" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Sprites/Astroid.java" afterPath="$PROJECT_DIR$/src/Sprites/Astroid.java" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Sprites/Fog.java" afterPath="$PROJECT_DIR$/src/Sprites/Fog.java" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Sprites/LaserBlast.java" afterPath="$PROJECT_DIR$/src/Sprites/LaserBlast.java" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Sprites/Ship.java" afterPath="$PROJECT_DIR$/src/Sprites/Ship.java" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Sprites/Sprite.java" afterPath="$PROJECT_DIR$/src/Sprites/Sprite.java" />
|
||||
</list>
|
||||
<ignored path="Astroids2D.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
|
@ -27,21 +37,15 @@
|
|||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file leaf-file-name="GameEngine.java" pinned="false" current-in-tab="true">
|
||||
<file leaf-file-name="GameEngine.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/Engine/GameEngine.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="2.1241474">
|
||||
<caret line="276" column="12" selection-start-line="276" selection-start-column="12" selection-end-line="278" selection-end-column="13" />
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="130" column="29" selection-start-line="130" selection-start-column="29" selection-end-line="130" selection-end-column="29" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="method#initFogs#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#startNewGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#initGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#setupLives#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#update#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#collisionHandler#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="e#9718#9719#0" expanded="true" />
|
||||
<element signature="e#9756#9757#0" expanded="true" />
|
||||
<element signature="e#3584#3585#0" expanded="true" />
|
||||
<element signature="e#3611#3612#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -61,7 +65,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/Astroid.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="14" column="54" selection-start-line="14" selection-start-column="51" selection-end-line="14" selection-end-column="54" />
|
||||
<caret line="21" column="7" selection-start-line="14" selection-start-column="51" selection-end-line="14" selection-end-column="54" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -73,7 +77,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/Fog.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="13" column="31" selection-start-line="13" selection-start-column="31" selection-end-line="13" selection-end-column="31" />
|
||||
<caret line="20" column="26" selection-start-line="20" selection-start-column="26" selection-end-line="20" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -85,7 +89,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/Sprite.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="91" column="17" selection-start-line="91" selection-start-column="17" selection-end-line="91" selection-end-column="17" />
|
||||
<caret line="146" column="7" selection-start-line="146" selection-start-column="7" selection-end-line="146" selection-end-column="7" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -97,12 +101,8 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/Ship.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="61" column="0" selection-start-line="61" selection-start-column="0" selection-end-line="61" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#2181#2182#0" expanded="true" />
|
||||
<element signature="e#2220#2221#0" expanded="true" />
|
||||
</folding>
|
||||
<caret line="51" column="0" selection-start-line="51" selection-start-column="0" selection-end-line="51" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -119,14 +119,12 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="GamePanel.java" pinned="false" current-in-tab="false">
|
||||
<file leaf-file-name="GamePanel.java" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/GamePanels/GamePanel.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="74" column="43" selection-start-line="74" selection-start-column="43" selection-end-line="74" selection-end-column="43" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
<state vertical-scroll-proportion="1.7435198">
|
||||
<caret line="76" column="43" selection-start-line="76" selection-start-column="43" selection-end-line="76" selection-end-column="43" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -135,7 +133,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/LaserBlast.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="12" column="50" selection-start-line="12" selection-start-column="50" selection-end-line="12" selection-end-column="50" />
|
||||
<caret line="19" column="13" selection-start-line="19" selection-start-column="13" selection-end-line="19" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -152,6 +150,9 @@
|
|||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="GradleLocalSettings">
|
||||
<option name="externalProjectsViewState">
|
||||
<projects_view />
|
||||
|
@ -173,9 +174,9 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="51" />
|
||||
<option name="x" value="67" />
|
||||
<option name="y" value="27" />
|
||||
<option name="width" value="1869" />
|
||||
<option name="width" value="1853" />
|
||||
<option name="height" value="1053" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
|
@ -203,7 +204,7 @@
|
|||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
|
@ -310,8 +311,8 @@
|
|||
</PATH>
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scratches" />
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
|
@ -604,7 +605,7 @@
|
|||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="51" y="27" width="1869" height="1053" extended-state="6" />
|
||||
<frame x="67" y="27" width="1853" height="1053" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Palette	" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
|
@ -621,14 +622,14 @@
|
|||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.12904997" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.12853186" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.13754228" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32890365" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="combo" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="Vcs.Log.UiProperties">
|
||||
|
@ -647,7 +648,7 @@
|
|||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/src/Engine/GameEngine.java</url>
|
||||
<line>270</line>
|
||||
<line>371</line>
|
||||
<properties />
|
||||
<option name="timeStamp" value="2" />
|
||||
</line-breakpoint>
|
||||
|
@ -661,20 +662,42 @@
|
|||
<option name="FILTER_TARGETS" value="false" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/src/Engine/CollisionUtil.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="47" column="5" selection-start-line="47" selection-start-column="5" selection-end-line="48" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/GamePanels/GamePanel.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="74" column="43" selection-start-line="74" selection-start-column="43" selection-end-line="74" selection-end-column="43" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/Sprites/LaserBlast.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="12" column="50" selection-start-line="12" selection-start-column="50" selection-end-line="12" selection-end-column="50" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/Engine/GameEngine.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="method#initFogs#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#startNewGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#initGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#setupLives#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#update#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#collisionHandler#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="e#9718#9719#0" expanded="true" />
|
||||
<element signature="e#9756#9757#0" expanded="true" />
|
||||
<element signature="e#3584#3585#0" expanded="true" />
|
||||
<element signature="e#3611#3612#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -721,11 +744,7 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="61" column="0" selection-start-line="61" selection-start-column="0" selection-end-line="61" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#2181#2182#0" expanded="true" />
|
||||
<element signature="e#2220#2221#0" expanded="true" />
|
||||
</folding>
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -743,9 +762,7 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="79" column="0" selection-start-line="79" selection-start-column="0" selection-end-line="79" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -765,14 +782,8 @@
|
|||
<caret line="135" column="49" selection-start-line="135" selection-start-column="49" selection-end-line="135" selection-end-column="49" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="method#initFogs#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#startNewGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#initGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#setupLives#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#update#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#collisionHandler#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="e#9718#9719#0" expanded="true" />
|
||||
<element signature="e#9756#9757#0" expanded="true" />
|
||||
<element signature="e#3584#3585#0" expanded="true" />
|
||||
<element signature="e#3611#3612#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -819,11 +830,7 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="61" column="0" selection-start-line="61" selection-start-column="0" selection-end-line="61" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#2181#2182#0" expanded="true" />
|
||||
<element signature="e#2220#2221#0" expanded="true" />
|
||||
</folding>
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -841,9 +848,7 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="79" column="0" selection-start-line="79" selection-start-column="0" selection-end-line="79" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -863,14 +868,8 @@
|
|||
<caret line="135" column="49" selection-start-line="135" selection-start-column="49" selection-end-line="135" selection-end-column="49" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="method#initFogs#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#startNewGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#initGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#setupLives#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#update#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#collisionHandler#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="e#9718#9719#0" expanded="true" />
|
||||
<element signature="e#9756#9757#0" expanded="true" />
|
||||
<element signature="e#3584#3585#0" expanded="true" />
|
||||
<element signature="e#3611#3612#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -917,11 +916,7 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="61" column="0" selection-start-line="61" selection-start-column="0" selection-end-line="61" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#2181#2182#0" expanded="true" />
|
||||
<element signature="e#2220#2221#0" expanded="true" />
|
||||
</folding>
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -939,9 +934,7 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="79" column="0" selection-start-line="79" selection-start-column="0" selection-end-line="79" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -961,14 +954,8 @@
|
|||
<caret line="40" column="51" selection-start-line="40" selection-start-column="51" selection-end-line="40" selection-end-column="51" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="method#initFogs#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#startNewGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#initGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#setupLives#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#update#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#collisionHandler#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="e#9718#9719#0" expanded="true" />
|
||||
<element signature="e#9756#9757#0" expanded="true" />
|
||||
<element signature="e#3584#3585#0" expanded="true" />
|
||||
<element signature="e#3611#3612#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -1015,11 +1002,7 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="28" column="13" selection-start-line="28" selection-start-column="13" selection-end-line="28" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#2181#2182#0" expanded="true" />
|
||||
<element signature="e#2220#2221#0" expanded="true" />
|
||||
</folding>
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -1027,9 +1010,7 @@
|
|||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -1060,7 +1041,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/Fog.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="13" column="31" selection-start-line="13" selection-start-column="31" selection-end-line="13" selection-end-column="31" />
|
||||
<caret line="20" column="26" selection-start-line="20" selection-start-column="26" selection-end-line="20" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -1075,7 +1056,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/Sprite.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="91" column="17" selection-start-line="91" selection-start-column="17" selection-end-line="91" selection-end-column="17" />
|
||||
<caret line="146" column="7" selection-start-line="146" selection-start-column="7" selection-end-line="146" selection-end-column="7" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -1085,12 +1066,8 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/Ship.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="61" column="0" selection-start-line="61" selection-start-column="0" selection-end-line="61" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#2181#2182#0" expanded="true" />
|
||||
<element signature="e#2220#2221#0" expanded="true" />
|
||||
</folding>
|
||||
<caret line="51" column="0" selection-start-line="51" selection-start-column="0" selection-end-line="51" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -1114,7 +1091,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/LaserBlast.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="12" column="50" selection-start-line="12" selection-start-column="50" selection-end-line="12" selection-end-column="50" />
|
||||
<caret line="19" column="13" selection-start-line="19" selection-start-column="13" selection-end-line="19" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -1124,7 +1101,7 @@
|
|||
<entry file="file://$PROJECT_DIR$/src/Sprites/Astroid.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="14" column="54" selection-start-line="14" selection-start-column="51" selection-end-line="14" selection-end-column="54" />
|
||||
<caret line="21" column="7" selection-start-line="14" selection-start-column="51" selection-end-line="14" selection-end-column="54" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -1139,31 +1116,23 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/GamePanels/GamePanel.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/Engine/GameEngine.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0">
|
||||
<caret line="74" column="43" selection-start-line="74" selection-start-column="43" selection-end-line="74" selection-end-column="43" />
|
||||
<caret line="130" column="29" selection-start-line="130" selection-start-column="29" selection-end-line="130" selection-end-column="29" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3584#3585#0" expanded="true" />
|
||||
<element signature="e#3611#3612#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/Engine/GameEngine.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/GamePanels/GamePanel.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="2.1241474">
|
||||
<caret line="276" column="12" selection-start-line="276" selection-start-column="12" selection-end-line="278" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="method#initFogs#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#startNewGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#initGame#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#setupLives#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#update#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="method#collisionHandler#0;class#GameEngine#0" expanded="false" />
|
||||
<element signature="e#9718#9719#0" expanded="true" />
|
||||
<element signature="e#9756#9757#0" expanded="true" />
|
||||
</folding>
|
||||
<state vertical-scroll-proportion="1.7435198">
|
||||
<caret line="76" column="43" selection-start-line="76" selection-start-column="43" selection-end-line="76" selection-end-column="43" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -22,12 +22,12 @@ import java.util.Vector;
|
|||
|
||||
|
||||
public class GameEngine implements KeyListener {
|
||||
private final int LARGE=100, MEDIUM=50, SMALL=25, NUM_OF_LIVES = 3, LASER_SPEED = 10, ASTROID_SPEED = 3;
|
||||
private final int STOP=0, UP=1, DOWN=-1;
|
||||
private final int LARGE=100, MEDIUM=50, SMALL=25, NUM_OF_LIVES = 3, LASER_SPEED = 10, ASTROID_SPEED = 3, FOG_COUNT = 4, MINI_SHIP_SIZE = 30;
|
||||
private final int STOP=0, UP=1, DOWN=-1; //Movement directions
|
||||
public boolean gameOn,fireLock, gameOver, isFirstGame;
|
||||
private Ship player;
|
||||
private Vector<Sprite> astroidsSprites,laserSprites;
|
||||
private int pWidth, pHeight;
|
||||
private Vector<Sprite> astroidsSprites,laserSprites; //will save all laser shots and asteroids which are currently on the screen.
|
||||
private int pWidth, pHeight; //panel dimensions
|
||||
private Timer astroidTimer, fireTimer, startTime;
|
||||
private Random r;
|
||||
private int score, countDown;
|
||||
|
@ -40,6 +40,8 @@ public class GameEngine implements KeyListener {
|
|||
private final URL themeURL= getClass().getResource("/Sounds/theme.wav");
|
||||
|
||||
public GameEngine(int width, int height){
|
||||
|
||||
//initialize variables and load audio\image files.
|
||||
this.isFirstGame = true;
|
||||
this.gameOver = true;
|
||||
this.pWidth = width;
|
||||
|
@ -56,16 +58,23 @@ public class GameEngine implements KeyListener {
|
|||
fogs = new Vector<>();
|
||||
r = new Random();
|
||||
sceneImage = new BufferedImage(width, height, Image.SCALE_SMOOTH);
|
||||
initFogs();
|
||||
|
||||
initFogs(); //create fog sprites moving on screen.
|
||||
startNewGame();
|
||||
}
|
||||
|
||||
/**
|
||||
* creates FOG_COUNT amount of fog sprites to roam the screen. (currently set to 4)
|
||||
*/
|
||||
private void initFogs(){
|
||||
for(int i = 0 ; i < 4 ; i++){
|
||||
for(int i = 0 ; i < FOG_COUNT ; i++){
|
||||
fogs.add(new Fog((-1)*r.nextInt(),(-1)*r.nextInt(),pWidth,pHeight,1,"Fog.png",r.nextInt(360),pWidth));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize and reset vars and timers to "new game" configuration.
|
||||
*/
|
||||
private void startNewGame(){
|
||||
score = 0;
|
||||
lives = new Vector<>();
|
||||
|
@ -77,6 +86,9 @@ public class GameEngine implements KeyListener {
|
|||
initGame();
|
||||
}
|
||||
|
||||
/**
|
||||
* clears asteroid and laser arrays, creates new asteroids, starts timers and repositions ship in center of screen.
|
||||
*/
|
||||
private void initGame(){
|
||||
this.countDown = 3;
|
||||
astroidsSprites = new Vector<>();
|
||||
|
@ -90,32 +102,53 @@ public class GameEngine implements KeyListener {
|
|||
createAstroid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates requested amount of ships to "Lives" array (Mini ships to be presented at corner of the screen).
|
||||
* @param num
|
||||
* number of wanted "Lives".
|
||||
*/
|
||||
private void setupLives(int num){
|
||||
int size = 30;
|
||||
for(int i = 0 ; i < num ; i++){
|
||||
lives.add(new Ship(pWidth - ((i+1)*size), 15, pWidth, pHeight, size));
|
||||
lives.add(new Ship(pWidth - ((i+1)*MINI_SHIP_SIZE), 15, pWidth, pHeight, MINI_SHIP_SIZE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns score
|
||||
* @return
|
||||
* int
|
||||
*/
|
||||
public int getScore(){
|
||||
return score;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns gameOver flag
|
||||
* @return
|
||||
* boolean
|
||||
*/
|
||||
public boolean isGameOver(){
|
||||
return this.gameOver;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns countDown
|
||||
* @return
|
||||
* int
|
||||
*/
|
||||
public int getCountDown(){
|
||||
return countDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new asteroid on a random position.
|
||||
*/
|
||||
private void createAstroid(){
|
||||
astroidsSprites.add(new Astroid((-1)*r.nextInt(),(-1)*r.nextInt(),pWidth,pHeight,ASTROID_SPEED,"astroid.png",r.nextInt(360),LARGE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent keyEvent) {
|
||||
}
|
||||
public void keyTyped(KeyEvent keyEvent) {}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent keyEvent) {
|
||||
|
@ -128,15 +161,16 @@ public class GameEngine implements KeyListener {
|
|||
player.setDirection(DOWN);
|
||||
break;
|
||||
case KeyEvent.VK_LEFT:
|
||||
player.turnShip(DOWN);
|
||||
player.turnShip(DOWN); //Left
|
||||
break;
|
||||
case KeyEvent.VK_RIGHT:
|
||||
player.turnShip(UP);
|
||||
player.turnShip(UP); //Right
|
||||
break;
|
||||
case KeyEvent.VK_SPACE:
|
||||
case KeyEvent.VK_SPACE: //Fire
|
||||
if (!fireLock && countDown <= 0) {
|
||||
if(laserAudioClip != null)
|
||||
laserAudioClip.loop();
|
||||
laserAudioClip.play(); //Play audio file
|
||||
//create a new laser from ship towards ship direction.
|
||||
laserSprites.add(new LaserBlast((int) player.getLocX() + (player.getImageWidth() / 2),
|
||||
(int) player.getLocY() + (player.getImageHeight() / 2),
|
||||
pWidth,
|
||||
|
@ -145,11 +179,11 @@ public class GameEngine implements KeyListener {
|
|||
"laser2.gif",
|
||||
player.getAngle(),
|
||||
SMALL));
|
||||
fireLock = true;
|
||||
fireLock = true; //lock for delay in fire speed
|
||||
}
|
||||
|
||||
break;
|
||||
case KeyEvent.VK_F2:
|
||||
case KeyEvent.VK_F2: //new game
|
||||
this.isFirstGame = false;
|
||||
gameOver = false;
|
||||
startNewGame();
|
||||
|
@ -165,6 +199,7 @@ public class GameEngine implements KeyListener {
|
|||
@Override
|
||||
public void keyReleased(KeyEvent keyEvent) {
|
||||
if(gameOn){
|
||||
//stop all movement activity
|
||||
switch (keyEvent.getKeyCode()){
|
||||
case KeyEvent.VK_UP:
|
||||
case KeyEvent.VK_DOWN:
|
||||
|
@ -174,9 +209,9 @@ public class GameEngine implements KeyListener {
|
|||
case KeyEvent.VK_LEFT:
|
||||
player.turnShip(STOP);
|
||||
break;
|
||||
case KeyEvent.VK_SPACE:
|
||||
laserAudioClip.stop();
|
||||
break;
|
||||
// case KeyEvent.VK_SPACE:
|
||||
// laserAudioClip.stop();
|
||||
// break;
|
||||
default:
|
||||
break;
|
||||
|
||||
|
@ -185,7 +220,9 @@ public class GameEngine implements KeyListener {
|
|||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all sprites, including collision handling.
|
||||
*/
|
||||
public void update(){
|
||||
for (Sprite sprite : fogs) {
|
||||
sprite.update();
|
||||
|
@ -205,18 +242,29 @@ public class GameEngine implements KeyListener {
|
|||
sprite.update();
|
||||
}
|
||||
|
||||
|
||||
// check for collisions
|
||||
collisionHandler();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a collision has occurred.
|
||||
* in case of missile hitting an asteroid - they are both removed.
|
||||
* in case of asteroid hitting the ship - round over.
|
||||
*/
|
||||
private void collisionHandler(){
|
||||
|
||||
Vector<Sprite> newAstroids = new Vector<>();
|
||||
Vector<Sprite> removeLasers = new Vector<>();
|
||||
Vector<Sprite> removeAstroids = new Vector<>();
|
||||
|
||||
|
||||
/*
|
||||
* check for "Laser vs Asteroid" collisions
|
||||
* in case of collision both missile and asteroid are removed,
|
||||
* and 2 smaller asteroids are created (if needed).
|
||||
*/
|
||||
for (int i = 0; i<laserSprites.size(); i++){
|
||||
for (int j = 0; j<astroidsSprites.size(); j++){
|
||||
|
||||
|
@ -240,6 +288,11 @@ public class GameEngine implements KeyListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* check for "Asteroid vs Ship" collisions.
|
||||
* if last live - game over
|
||||
* else - 1 less life and reset vars for next round
|
||||
*/
|
||||
|
||||
for(int i = 0 ; i < astroidsSprites.size() ; i++){
|
||||
if(CollisionUtil.collidesWith(astroidsSprites.get(i), player)){
|
||||
|
@ -250,23 +303,33 @@ public class GameEngine implements KeyListener {
|
|||
if(lives.size() > 0)
|
||||
lives.remove(lives.size()-1);
|
||||
initGame();
|
||||
System.out.println("==============GAME OVER==============");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//add new asteroids and remove collisions.
|
||||
astroidsSprites.addAll(newAstroids);
|
||||
|
||||
laserSprites.removeAll(removeLasers);
|
||||
astroidsSprites.removeAll(removeAstroids);
|
||||
}
|
||||
|
||||
/**
|
||||
* render buffered image.
|
||||
* @param panel
|
||||
* JPanel
|
||||
*/
|
||||
public void render(JPanel panel){
|
||||
sceneImage = new BufferedImage(this.pWidth, this.pHeight, Image.SCALE_FAST);
|
||||
renderScene(sceneImage.getGraphics(), panel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws all sprites
|
||||
* @param g
|
||||
* Graphics
|
||||
* @param panel
|
||||
* Jpanel
|
||||
*/
|
||||
public void renderScene(Graphics g, JPanel panel){
|
||||
if(!gameOver)
|
||||
player.drawSprite(g, panel);
|
||||
|
@ -289,13 +352,20 @@ public class GameEngine implements KeyListener {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* creates an new asteroid each 5 seconds *
|
||||
*/
|
||||
private class astroidTimerListener implements ActionListener{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
createAstroid();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Limits fire speed to 1 second.
|
||||
*
|
||||
*/
|
||||
private class fireTimerListener implements ActionListener{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
|
@ -303,6 +373,10 @@ private class fireTimerListener implements ActionListener{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre game countdown.
|
||||
*
|
||||
*/
|
||||
private class countDownListener implements ActionListener{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
|
@ -311,6 +385,11 @@ private class fireTimerListener implements ActionListener{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns sceneImage
|
||||
* @return
|
||||
* BufferedImage
|
||||
*/
|
||||
public BufferedImage getScene(){
|
||||
return this.sceneImage;
|
||||
}
|
||||
|
|
|
@ -3,25 +3,20 @@ import Engine.*;
|
|||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
//import java.awt.image.BufferedImage;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Created by sagi on 12/18/15.
|
||||
*/
|
||||
public class GamePanel extends JPanel implements Runnable{
|
||||
// private final String BASE_PATH = System.getProperty("user.dir") + File.separator +"src"+ File.separator;
|
||||
|
||||
// private final String bgPath = BASE_PATH + "Images" + File.separator + "bg.gif";
|
||||
// private final String gameOverPath = BASE_PATH + "Images" + File.separator + "gameOver.png";
|
||||
// private final String startPath = BASE_PATH + "Images" + File.separator + "start.png";
|
||||
|
||||
private final URL bgURL= getClass().getResource("/Images/bg2.gif");
|
||||
private final URL gameOverURL= getClass().getResource("/Images/gameOver.png");
|
||||
private final URL startURL= getClass().getResource("/Images/start.png");
|
||||
|
||||
|
||||
private int width, height;
|
||||
// private int width, height;
|
||||
private GameEngine engine;
|
||||
private JLabel lbl_score, lbl_countDown, lbl_gameOver, lbl_bg, lbl_start;
|
||||
|
||||
|
@ -30,23 +25,30 @@ public class GamePanel extends JPanel implements Runnable{
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Constructor.
|
||||
* initializes all objects on panel and creates gameEngine
|
||||
*/
|
||||
public GamePanel(int width, int height){
|
||||
this.setLayout(null);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
// this.width = width;
|
||||
// this.height = height;
|
||||
this.engine = new GameEngine(width, height);
|
||||
this.addKeyListener(engine);
|
||||
this.setFocusable(true);
|
||||
this.requestFocus();
|
||||
|
||||
//set score label at top left corner
|
||||
this.lbl_score = new JLabel("");
|
||||
lbl_score.setBounds(15,15,width,30);
|
||||
|
||||
//set countDown label at center
|
||||
this.lbl_countDown = new JLabel("");
|
||||
lbl_countDown.setBounds(width/2,0,width,height);
|
||||
System.out.println("URL = " +bgURL);
|
||||
|
||||
//set background
|
||||
img_bg = new ImageIcon(bgURL);
|
||||
Image tmp_BG = img_bg.getImage();
|
||||
bg_image = tmp_BG.getScaledInstance(width, height, java.awt.Image.SCALE_SMOOTH);
|
||||
|
@ -83,6 +85,7 @@ public class GamePanel extends JPanel implements Runnable{
|
|||
while(engine.gameOn){
|
||||
engine.update();
|
||||
|
||||
//check if game is over and draw labels accordingly
|
||||
if(engine.isGameOver()){
|
||||
this.lbl_countDown.setVisible(false);
|
||||
if(!engine.isFirstGame)
|
||||
|
@ -95,16 +98,20 @@ public class GamePanel extends JPanel implements Runnable{
|
|||
|
||||
}
|
||||
|
||||
//render graphics
|
||||
engine.render(this);
|
||||
repaint();
|
||||
|
||||
//sleep to slow down game
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
Thread.sleep(5);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
repaint();
|
||||
|
||||
//sleep for other processes to take control
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
Thread.sleep(20);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -124,6 +131,7 @@ public class GamePanel extends JPanel implements Runnable{
|
|||
|
||||
g.drawImage(bg_image, 0, 0, this); //draw the background
|
||||
g2d.drawImage(engine.getScene(),0,0,this); //Draw the scene
|
||||
|
||||
//Some labels - Score & countDown
|
||||
lbl_score.setText("SCORE : " + engine.getScore());
|
||||
if(engine.getCountDown() > 0){
|
||||
|
|
|
@ -19,6 +19,9 @@ public class Astroid extends Sprite {
|
|||
rotationSpeed = ((r.nextDouble()*10) % 3) + 0.01;
|
||||
}
|
||||
|
||||
/**
|
||||
* updates sprite location according to movement speed and angle.
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
locX += acceleration * Math.cos(Math.toRadians(angle));
|
||||
|
@ -27,6 +30,9 @@ public class Astroid extends Sprite {
|
|||
selfAngle+=rotationSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* draw sprite with rotation according to sprite angle
|
||||
*/
|
||||
@Override
|
||||
public void drawSprite(Graphics g, JPanel p) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
|
|
|
@ -22,6 +22,9 @@ public class Fog extends Sprite {
|
|||
alphaChannel = r.nextFloat()-0.04f;
|
||||
}
|
||||
|
||||
/**
|
||||
* updates sprite location according to movement speed and angle.
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
locX += acceleration * Math.cos(Math.toRadians(angle));
|
||||
|
@ -30,6 +33,9 @@ public class Fog extends Sprite {
|
|||
selfAngle+=rotationSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* draw sprite with rotation according to sprite angle
|
||||
*/
|
||||
@Override
|
||||
public void drawSprite(Graphics g, JPanel p) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
|
|
|
@ -14,6 +14,9 @@ public class LaserBlast extends Sprite {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* updates sprite location according to movement speed and angle.
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
locX += acceleration * Math.cos(Math.toRadians(angle));
|
||||
|
@ -21,6 +24,9 @@ public class LaserBlast extends Sprite {
|
|||
outOfScreeFix();
|
||||
}
|
||||
|
||||
/**
|
||||
* draw sprite with rotation according to sprite angle
|
||||
*/
|
||||
@Override
|
||||
public void drawSprite(Graphics g, JPanel p) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package Sprites;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
//import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.AffineTransformOp;
|
||||
//import java.awt.geom.AffineTransform;
|
||||
//import java.awt.image.AffineTransformOp;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
//import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by sagi on 12/18/15.
|
||||
|
@ -28,6 +28,9 @@ public class Ship extends Sprite {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* updates sprite location according to movement speed and angle.
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
setSpeed();
|
||||
|
@ -35,9 +38,23 @@ public class Ship extends Sprite {
|
|||
locX += selfAccel * Math.cos(Math.toRadians(angle));
|
||||
locY -= selfAccel * (-1 * Math.sin(Math.toRadians(angle)));
|
||||
outOfScreeFix();
|
||||
}
|
||||
|
||||
/**
|
||||
* draw sprite with rotation according to sprite angle
|
||||
*/
|
||||
public void drawSprite(Graphics g, JPanel panel) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
g2d.rotate(Math.toRadians(angle), locX + (bImage.getWidth()/2), locY + (bImage.getHeight()/2));
|
||||
g2d.drawImage(bImage, (int)locX, (int)locY, panel);
|
||||
g2d.rotate(-1*Math.toRadians(angle), locX + (bImage.getWidth()/2), locY + (bImage.getHeight()/2));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* sets movement speed according to movement direction.
|
||||
* if ship is not "moved" - it will slow down by slowing factor.
|
||||
*/
|
||||
private void setSpeed(){
|
||||
if (direction == UP && !(selfAccel > MAX_SPEED)){
|
||||
selfAccel+=SLOWING_FACTOR*2;
|
||||
|
@ -61,18 +78,21 @@ public class Ship extends Sprite {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set movement direction
|
||||
* @param direction
|
||||
* int
|
||||
*/
|
||||
public void setDirection(int direction){
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
|
||||
public void drawSprite(Graphics g, JPanel panel) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
g2d.rotate(Math.toRadians(angle), locX + (bImage.getWidth()/2), locY + (bImage.getHeight()/2));
|
||||
g2d.drawImage(bImage, (int)locX, (int)locY, panel);
|
||||
g2d.rotate(-1*Math.toRadians(angle), locX + (bImage.getWidth()/2), locY + (bImage.getHeight()/2));
|
||||
|
||||
}
|
||||
/**
|
||||
* set turning direction
|
||||
* @param direction
|
||||
* int
|
||||
*/
|
||||
public void turnShip(int direction){
|
||||
turnDirection=direction;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import javax.imageio.ImageIO;
|
|||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
//import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
//import java.net.URL;
|
||||
|
||||
|
||||
public abstract class Sprite {
|
||||
|
@ -18,7 +18,7 @@ public abstract class Sprite {
|
|||
protected int pWidth, pHeight, size; // panel's dimensions
|
||||
|
||||
protected double angle;
|
||||
private final String BASE_PATH = System.getProperty("user.dir") + File.separator +"src"+ File.separator;
|
||||
// private final String BASE_PATH = System.getProperty("user.dir") + File.separator +"src"+ File.separator;
|
||||
|
||||
|
||||
public Sprite(int x, int y, int w, int h, int acc, String imgName, double angle, int size)
|
||||
|
@ -29,19 +29,24 @@ public abstract class Sprite {
|
|||
acceleration = acc;
|
||||
pWidth = w;
|
||||
pHeight = h;
|
||||
try {///home/sagi/Development/JCE/Astroids2D/src/Images/ship.gif
|
||||
this.angle = angle;
|
||||
|
||||
//load image from source files
|
||||
try {
|
||||
bImage = ImageIO.read(getClass().getResource("/Images/"+imgName));
|
||||
}catch (IOException pin){
|
||||
pin.printStackTrace();
|
||||
bImage = null;
|
||||
}
|
||||
this.angle = angle;
|
||||
|
||||
setImageDimensions();
|
||||
}
|
||||
|
||||
|
||||
public void setImageDimensions()
|
||||
/*
|
||||
* resizes image to a set size
|
||||
*/
|
||||
private void setImageDimensions()
|
||||
{
|
||||
Image tmp = bImage.getScaledInstance(size,size, Image.SCALE_SMOOTH);
|
||||
BufferedImage bi = new BufferedImage(size,size, BufferedImage.TYPE_INT_ARGB);
|
||||
|
@ -52,44 +57,82 @@ public abstract class Sprite {
|
|||
bImage = bi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract method to update sprite.
|
||||
*/
|
||||
public abstract void update();
|
||||
|
||||
// public Rectangle getBoundingBox()
|
||||
// {
|
||||
// return new Rectangle(getLocX(), getLocY(), imageWidth, imageHeight);
|
||||
// }
|
||||
/**
|
||||
* returns sprite x position
|
||||
* @return
|
||||
* double
|
||||
*/
|
||||
public double getLocX() {return locX;}
|
||||
|
||||
public double getLocX() {
|
||||
return locX;
|
||||
/**
|
||||
* returns sprite y position
|
||||
* @return
|
||||
* double
|
||||
*/
|
||||
public double getLocY() {return locY;}
|
||||
|
||||
/**
|
||||
* returns sprite acceleration
|
||||
* @return
|
||||
* int
|
||||
*/
|
||||
public int getAcceleration() {return acceleration;}
|
||||
|
||||
/**
|
||||
* returns sprite size
|
||||
* @return
|
||||
* int
|
||||
*/
|
||||
public BufferedImage getbImage() {return bImage;}
|
||||
|
||||
/**
|
||||
* returns image width
|
||||
* @return
|
||||
* int
|
||||
*/
|
||||
public int getImageWidth() {return imageWidth;}
|
||||
|
||||
/**
|
||||
* returns image height
|
||||
* @return
|
||||
* int
|
||||
*/
|
||||
public int getImageHeight() {return imageHeight;}
|
||||
|
||||
/**
|
||||
* returns sprite angle
|
||||
* @return
|
||||
* double
|
||||
*/
|
||||
public double getAngle() {return angle;}
|
||||
|
||||
/**
|
||||
* returns sprite size
|
||||
* @return
|
||||
* int
|
||||
*/
|
||||
public int getSize() {return size;}
|
||||
|
||||
|
||||
/**
|
||||
* returns shape location and dimensions as a Rectangle.
|
||||
* @return
|
||||
* Rectangle
|
||||
*/
|
||||
public Rectangle getBounds() {
|
||||
return new Rectangle((int)locX, (int)locY, size, size);
|
||||
}
|
||||
|
||||
public double getLocY() {
|
||||
return locY;
|
||||
}
|
||||
|
||||
public int getAcceleration(){
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
public BufferedImage getbImage()
|
||||
{
|
||||
return bImage;
|
||||
}
|
||||
|
||||
public int getImageWidth() {
|
||||
return imageWidth;
|
||||
}
|
||||
|
||||
public int getImageHeight()
|
||||
{
|
||||
return imageHeight;
|
||||
}
|
||||
|
||||
public double getAngle(){
|
||||
return angle;
|
||||
}
|
||||
|
||||
protected void outOfScreeFix(){ //its not a bug it's a feature
|
||||
/**
|
||||
* its not a bug it's a feature. actually it just moves a shape that goes beyond the screen to the other side.
|
||||
*/
|
||||
protected void outOfScreeFix(){
|
||||
if(locX < 0 - size)
|
||||
locX = pWidth;
|
||||
else if (locX > pWidth+size)
|
||||
|
@ -101,17 +144,11 @@ public abstract class Sprite {
|
|||
locY = 0-size ;
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
Rectangle r = new Rectangle((int)locX, (int)locY, size, size);
|
||||
return r;
|
||||
}
|
||||
|
||||
public int getSize(){
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* abstract method for drawing sprite.
|
||||
* @param g
|
||||
* @param p
|
||||
*/
|
||||
public abstract void drawSprite(Graphics g, JPanel p);
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue