forked from ucsb-cs56-projects/cs56-games-country-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unfinished runner and jpanel code while trying to implement bullet. I…
…ssue ucsb-cs56-projects#50 is done
- Loading branch information
1 parent
d1273ea
commit c1be4f8
Showing
45 changed files
with
1,277 additions
and
853 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<project default ="compile"> | ||
|
||
<!-- build.xml for Country Runner, cs56, S13 | ||
name: Mathew Glodack, Christina Morris | ||
name: Sidney Rhoads, Tom Craig | ||
--> | ||
|
||
|
||
<property environment="env"/> <!-- load environment vars --> | ||
<property name="webRoot" value="${env.HOME}/public_html/cs56/13S/${env.USER}/country_runner" /> | ||
<property name="webBaseURL" value="http://www.cs.ucsb.edu/~${env.USER}/cs56" /> | ||
<property name="webBaseURL1" value="https://foo.cs.ucsb.edu/56mantis/view.php?id=805" /> | ||
|
||
<property name="course" value="cs56" /> | ||
<property name="quarter" value="13S" /> | ||
<property name="projectName" value="country_runner" /> | ||
<property name="projectPath" value="${course}/projects/games/${projectName}"/> | ||
<property name="javadocDest" value="${webRoot}/${projectName}/javadoc" /> | ||
<property name="javadocURL" value="${webBaseURL}/${projectName}/javadoc" /> | ||
<property name="mainClass" value="edu.ucsb.cs56.projects.games.country_runner/CountryRunnerGui" /> | ||
|
||
<path id="project.class.path"> | ||
<pathelement location="build"/> | ||
<pathelement location="lib/junit-4.8.2.jar"/> | ||
</path> | ||
|
||
<!-- target that compiles the src codes and make a build folder to store the class file --> | ||
<target name="compile" description="Compiles Country Runner"> | ||
<mkdir dir="build" /> | ||
<javac srcdir="src" destdir="build" debug="true" debuglevel="lines,source"> | ||
<classpath> | ||
<pathelement location="build" /> | ||
<pathelement location="lib/junit-4.8.2.jar" /> | ||
</classpath> | ||
</javac> | ||
</target> | ||
|
||
<!-- target that runs the program --> | ||
<target name="run" description="Runs Country Runner" depends="compile"> | ||
<java classname="${mainClass}" fork="true"> | ||
<classpath refid="project.class.path"/> | ||
</java> | ||
</target> | ||
|
||
<!-- target that deletes unnecessary files and directories --> | ||
<target name="clean" description="Deletes unnecessary files and dir" > | ||
<delete failonerror="false" verbose="true"> | ||
<fileset dir="build" includes="**/*.class"/> | ||
</delete> | ||
<delete dir="javadoc" quiet="true" /> | ||
</target> | ||
|
||
<!-- target that generates javadoc files --> | ||
<target name="javadoc" description="Generates JavaDoc files for Country Runner" depends="compile"> | ||
<delete dir="javadoc" quiet="true" /> | ||
<javadoc destdir="javadoc" author="true" version="true" use="true"> | ||
<fileset dir="src" includes="**/*.java" /> | ||
<classpath refid="project.class.path" /> | ||
</javadoc> | ||
<delete quiet="true" dir="${javadocDest}" /> | ||
<copy todir="${javadocDest}" > | ||
<fileset dir="javadoc"/> | ||
</copy> | ||
<!-- Note: this only does the chmod command on the javadoc | ||
subdirectory and its contents. You MIGHT have to MANUALLY do the | ||
chmod on the parent directories. However, you should only need to do | ||
that once. | ||
--> | ||
<chmod dir="${javadocDest}" perm="755" type="dir" includes="**" /> | ||
<chmod dir="${javadocDest}" perm="755" type="file" includes="**/*" /> | ||
<echo>Javadoc deployed to ${javadocURL}</echo> | ||
</target> | ||
|
||
<!-- target that create a jar file --> | ||
<target name="jar" description = "Creates a jar file" depends="compile"> | ||
<mkdir dir="dist" /> | ||
<copy todir="build/images"> | ||
<fileset dir="images"/> | ||
</copy> | ||
<jar destfile="dist/${course}_${quarter}_${projectName}.jar" | ||
basedir="build" > | ||
<manifest> | ||
<attribute name="Main-Class" value="${mainClass}" /> | ||
</manifest> | ||
</jar> | ||
</target> | ||
|
||
<!-- target that runs Junit Tests --> | ||
<target name="test" description="Run JUnit tests on Country Runner" depends="compile"> | ||
<junit haltonerror="no" haltonfailure="no"> | ||
<classpath refid="project.class.path" /> | ||
<batchtest fork="yes"> | ||
<fileset dir="src"> | ||
<include name="**/*Test.java"/> | ||
</fileset> | ||
</batchtest> | ||
<formatter type="plain" usefile="false"/> | ||
</junit> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file added
BIN
+1.11 KB
build/edu/ucsb/cs56/projects/games/country_runner/BackgroundMusic.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.36 KB
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerGui.class
Binary file not shown.
Binary file added
BIN
+946 Bytes
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerJPanel$1.class
Binary file not shown.
Binary file added
BIN
+7.05 KB
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerJPanel.class
Binary file not shown.
Binary file added
BIN
+891 Bytes
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerTitleScreen$1.class
Binary file not shown.
Binary file added
BIN
+1.11 KB
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerTitleScreen$2.class
Binary file not shown.
Binary file added
BIN
+1.13 KB
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerTitleScreen$3.class
Binary file not shown.
Binary file added
BIN
+1.12 KB
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerTitleScreen$4.class
Binary file not shown.
Binary file added
BIN
+1.08 KB
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerTitleScreen$5.class
Binary file not shown.
Binary file added
BIN
+1.14 KB
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerTitleScreen$6.class
Binary file not shown.
Binary file added
BIN
+3.49 KB
build/edu/ucsb/cs56/projects/games/country_runner/CountryRunnerTitleScreen.class
Binary file not shown.
Binary file added
BIN
+853 Bytes
build/edu/ucsb/cs56/projects/games/country_runner/GameOverJPanel$1.class
Binary file not shown.
Binary file added
BIN
+858 Bytes
build/edu/ucsb/cs56/projects/games/country_runner/GameOverJPanel$2.class
Binary file not shown.
Binary file added
BIN
+1.62 KB
build/edu/ucsb/cs56/projects/games/country_runner/GameOverJPanel$3.class
Binary file not shown.
Binary file added
BIN
+2.06 KB
build/edu/ucsb/cs56/projects/games/country_runner/GameOverJPanel.class
Binary file not shown.
Binary file added
BIN
+1.47 KB
build/edu/ucsb/cs56/projects/games/country_runner/GeneralPathWrapper.class
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 added
BIN
+833 Bytes
build/edu/ucsb/cs56/projects/games/country_runner/SpriteSequence.class
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion
1
src/edu/ucsb/cs56/projects/games/country_runner/.#CountryRunnerJPanel.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
src/edu/ucsb/cs56/projects/games/country_runner/Bullet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package edu.ucsb.cs56.projects.games.country_runner; | ||
import java.lang.Math; | ||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
import javax.imageio.ImageIO; | ||
import java.io.IOException; | ||
/**Draws the Bullet object on the screen | ||
* @author Christina Morris, Mathew Glodack | ||
* @author Sidney Rhoads, Tom Craig | ||
* @author William Huang, Ray Ouyang | ||
* @version cs56, F16, proj2 | ||
* | ||
*/ | ||
public class Bullet extends Sprite | ||
{ | ||
//initialXPosition goes into the super constructor | ||
private static double initialXPosition; | ||
private static int xPosition; | ||
private double t; | ||
//the speed of bullet | ||
private static final double speed = 15.0; | ||
//the amount of time that each bullet can be fired in milliseconds | ||
private static final int fireInterval = 1000; | ||
//holds the time of when a bullet was last fired | ||
private static int lastFire = 0; | ||
//Image of the bullet | ||
private BufferedImage image; | ||
|
||
|
||
/** Default Constructor makes a Bullet. | ||
* sets up the spriteSheet and fills the | ||
* sequences with images from it | ||
*/ | ||
public Bullet(Runner runner) | ||
{ | ||
//reference a runner so one can get the position from where the bullet is to be shot | ||
super(290,74, runner.returnXPosition(),runner.returnYPosition()); | ||
try { | ||
image = ImageIO.read(new File("redLaserRay.png")); | ||
} catch (IOException e) { | ||
} | ||
} | ||
/** public boolean canShoot() | ||
* determines if you can shoot based on | ||
* the last fire that was made and the fireInterval | ||
*/ | ||
public boolean canShoot(){ | ||
if((int)System.currentTimeMillis() - lastFire > fireInterval) | ||
return true; | ||
return false; | ||
} | ||
/** public BufferedImage returnImage() | ||
* returns the current image of the bullet | ||
*/ | ||
public BufferedImage returnImage() | ||
{ | ||
return image; | ||
} | ||
/** updateCurrentPosition | ||
* Moves the bullet to left until it is off screen. | ||
*/ | ||
public void updateCurrentPosition() | ||
{ | ||
if(!offTheScreen()) | ||
if(canShoot()) | ||
xPosition = (int)(speed * t); | ||
this.setX(xPosition); | ||
t++; | ||
} | ||
/** public boolean offTheScreen() | ||
* checks if the bullet is off the screen | ||
*/ | ||
public boolean offTheScreen() | ||
{ | ||
if(xPosition - 600 == 0) | ||
return true; | ||
return false; | ||
} | ||
} | ||
|
67 changes: 67 additions & 0 deletions
67
src/edu/ucsb/cs56/projects/games/country_runner/Bullet.java~
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package edu.ucsb.cs56.projects.games.country_runner; | ||
import java.lang.Math; | ||
|
||
/**Draws the Sheep object on the screen | ||
* @author Christina Morris, Mathew Glodack | ||
* @author Sidney Rhoads, Tom Craig | ||
* @author William Huang, Ray Ouyang | ||
* @version cs56, F16, proj2 | ||
* | ||
*/ | ||
public class Bullet extends Sprite | ||
{ | ||
//initialXPosition goes into the super constructor | ||
private static double initialXPosition; | ||
private static int xPosition; | ||
private double t; | ||
//the speed of bullet | ||
private static final double speed = 15.0; | ||
//the amount of time that each bullet can be fired in milliseconds | ||
private static final int fireInterval = 1000; | ||
//holds the time of when a bullet was last fired | ||
private static int lastFire = 0; | ||
//Image of the bullet | ||
private BufferedImage image; | ||
|
||
|
||
/** Default Constructor makes a Bullet. | ||
* sets up the spriteSheet and fills the | ||
* sequences with images from it | ||
*/ | ||
public Bullet(Runner runner) | ||
{ | ||
//reference a runner so one can get the position from where the bullet is to be shot | ||
super(290,74, runner.getXPosition(),runner.getYPosition); | ||
try { | ||
image = ImageIO.read(new File("redLaserRay.png")); | ||
} catch (IOException e) { | ||
} | ||
} | ||
public boolean canShoot(){ | ||
if(System.currentTimeMillis() - lastFire > fireInterval) | ||
return true; | ||
return false; | ||
} | ||
public boolean returnImage() | ||
{ | ||
return image; | ||
} | ||
/** updateCurrentPosition | ||
* Moves the bullet to left until it is off screen. | ||
*/ | ||
public void updateCurrentPosition() | ||
{ | ||
if(!offTheScreen()) | ||
if(canShoot()) | ||
xPosition = speed * t; | ||
this.setX(xPosition); | ||
t++; | ||
} | ||
public boolean offTheScreen() | ||
{ | ||
if(xPosition - 600 == 0) | ||
return true; | ||
return false; | ||
} | ||
} | ||
|
Oops, something went wrong.