Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alan23273850 committed Feb 21, 2018
0 parents commit 66257ee
Show file tree
Hide file tree
Showing 1,070 changed files with 2,741 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="lib/core.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Eclipse-Built Folders
/bin/

# Makefile-Built Files
/out/
/*.jar

# Database for Jar Files Run in the Root Directory
/stat/
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Final_Project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Program, flags, etc.
JAC = javac
JAR = jar
OBJ = ./*
STATOBJ = stat/*.class
TARGET = game rank survey
OUTDIR = out

all: clean precompile $(TARGET)

clean:
-rm -r out stat *.jar

precompile:
mkdir $(OUTDIR); cp -r src/res $(OUTDIR); $(JAC) -cp lib/* src/*/*.java -encoding Big5 -d $(OUTDIR)

game: precompile
cd $(OUTDIR); $(JAR) xf ../lib/core.jar; $(JAR) cfe ../Game.jar main.MainApp $(OBJ)

rank: precompile
cd $(OUTDIR); $(JAR) cfe ../Rank.jar stat.Rank $(STATOBJ) res/rank/

survey: precompile
cd $(OUTDIR); $(JAR) cfe ../Survey.jar stat.Survey $(STATOBJ)
Binary file added lib/core.jar
Binary file not shown.
63 changes: 63 additions & 0 deletions src/ani/GameOverAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package ani;

import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
* Reference: http://openhome.cc/Gossip/ComputerGraphics/SkeletonOfAnimation.htm
*/

@SuppressWarnings("serial")
public class GameOverAnimation extends JPanel implements Runnable {
private Thread thread;
private JLabel jLabel;
private int picId = 0;

public void start () {
try
{
this.setVisible(true);
this.setLayout(new FlowLayout());
this.setBounds(new Rectangle(0,0,1000,800));
ImageIcon icon = new ImageIcon( ImageIO.read( getClass().getResourceAsStream("/res/gameOverAni/2.gif") ) );
jLabel = new JLabel(icon);
jLabel.setSize(1000, 800);
this.setLayout(null);
this.add(jLabel);

thread = new Thread(this);
thread.start();
}
catch (Exception e) {}
}

public void run() {
try
{
// 動畫迴圈
while (true) {
if (picId<935)
picId++;
else
break;
// 動畫的狀態改變、緩衝區繪圖
ImageIcon icon = new ImageIcon(ImageIO.read(getClass().getResourceAsStream("/res/gameOverAni/" + (picId+1) + ".gif")));
if (jLabel!=null)
jLabel.setIcon(icon);
this.repaint(); // 重繪畫面
} // while結束
}
catch (Exception e) {}
} // run()結束

// 改寫update(),避免畫面不連續
@Override
public void update (Graphics g) {
super.paint(g); // 繪圖動作
}
}
38 changes: 38 additions & 0 deletions src/ani/GameWinAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package ani;

import main.Help;
import processing.core.PApplet;
import processing.core.PImage;

@SuppressWarnings("serial")
public class GameWinAnimation extends PApplet {
private PImage [] jump = new PImage[2];
private PImage moneyMountain = new PImage();
private PImage reptile = new PImage();
private PImage winTitle = new PImage();
private int counter = 0;

public void setup(){
setSize(1000,700);
setLocation(0,0);
moneyMountain = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/gameWinAni/moneyMountain.png"));
reptile = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/gameWinAni/deathreptile.png"));
winTitle = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/gameWinAni/youwin.png"));
jump[0]= Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/gameWinAni/Sara_jump1.png"));
jump[1] = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/gameWinAni/Sara_jump2.png"));
}

public void draw(){
image(moneyMountain,0,0);
if ( 20<=counter%40 )
image(jump[1], 500, 385);
else
image(jump[0], 500, 425);
counter++;
image(reptile,25,580);
image(reptile,74,600);
image(reptile,124,610);
image(reptile,189,620);
image(winTitle,200,0);
}
}
79 changes: 79 additions & 0 deletions src/ani/PassAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package ani;

import main.Game;
import main.Help;
import processing.core.PApplet;
import processing.core.PImage;

@SuppressWarnings("serial")
public class PassAnimation extends PApplet {
private int prizeGet;
private int a=0;
private boolean check = false;
private boolean chooseGift = false;
private PImage backGround = new PImage();
private PImage [] prize = new PImage[2];
private PImage [][] datatest = new PImage[Game.MAX_LEVEL][2];
private PImage clickMe = new PImage();
private PImage beforeStage = new PImage();

public PassAnimation(int stage){
initDataTest();
prize[0]=datatest[stage-2][0];
prize[1]=datatest[stage-2][1];
prizeGet = -1;
}

public void setup(){
setSize(1000,700);
backGround = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/passAni/passBackground.png"));
clickMe = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/passAni/clickMe.png"));
beforeStage = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/passAni/passStoryGround.png"));
}

public void draw(){
if(chooseGift==false){
image(backGround,0,0);
image(prize[0],150,225);
image(prize[1],550,225);
image(clickMe,200,550);
image(clickMe,585,550);
}
else{
stroke(256,256,256);
background(256,256,256);
image(beforeStage,0,50);
if(a%20<=19&&a%20>=10)
rect(780,300,200,100);
a++;
}
}

public void mouseClicked () {
if (chooseGift==false && mouseX<=420 && mouseX>=200 && mouseY<=600 && mouseY>=550) {
chooseGift = true;
prizeGet = 0;
}
else if (chooseGift == false && mouseX<=850 && mouseX>=630 && mouseY<=600 && mouseY>=550) {
chooseGift = true;
prizeGet = 1;
}
else {}
if (chooseGift && mouseX<=980 && mouseX>=780 && mouseY<=400 && mouseY>=300)
check=true;
}

public boolean hasFinished () {
return check;
}

public void initDataTest () {
for (int i=0; i<Game.MAX_LEVEL; i++)
for (int j=0; j<2; j++)
datatest[i][j]=Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/passAni/datatest" + (i+1) + "_" + (j+1) + ".png"));
}

public int getPrizeGet () {
return prizeGet;
}
}
89 changes: 89 additions & 0 deletions src/ani/StartAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package ani;

import java.awt.Rectangle;
import processing.core.PApplet;
import processing.core.PImage;
import ch.Player;
import main.Help;

@SuppressWarnings("serial")
public class StartAnimation extends PApplet {
private Player player;
private boolean animationGo = false;
private boolean animationOver = false;
private Rectangle bound;
private int a=0, b=0;
private PImage forestimg = new PImage();
private PImage startnoimg = new PImage();
private PImage startimg = new PImage();
private PImage title = new PImage();
private PImage backStory = new PImage();
private PImage mouse[] = new PImage[2];
private boolean dataIsStored = false;
private boolean story = false;

public StartAnimation(Rectangle bounds){
bound = bounds;
}

public void setup(){
player=new Player(this,290,340);
forestimg = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/startAni/forest.jpg"));
startnoimg = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/startAni/graystart.png"));
title=Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/startAni/title.png"));
startimg=Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/startAni/start.png"));
backStory=Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/startAni/storyGround.png"));
mouse[0]=Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/startAni/mouse.png"));
mouse[1]=Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/startAni/white.png"));
size(bound.width,bound.height);
setLocation(0,0);
background(255);
frameRate(20);
}

public void draw(){
if(story==false){
image(forestimg,0,0);
if(dataIsStored)
image(startimg,200,450);
else
image(startnoimg,200,450);
image(title,180,30);
this.revalidate();
this.repaint();
if(animationGo==true){
player.display();
fill(0,0,0);
rect(305,400,400,50);
fill(0XFF,0XDC,35);
rect(305,400,10*a,50);
player.setMovement(3);
player.move();
player.move();
if(a==40)
story=true;
a++;
}
}
else{
image(backStory,0,0);
image(mouse[(b%20<10)?1:0],850,400);
b++;
}
}

public void mouseClicked(){
if(mouseX<=632 && mouseX>=350 && mouseY<=630&& mouseY>=500 && dataIsStored)
animationGo=true;
if(story==true && mouseX>=780 && mouseX<=950 && mouseY>=300 && mouseY<=400)
animationOver=true;
}

public boolean isAnimationOver(){
return animationOver;
}

public void setDataIsstored(boolean in){
dataIsStored = in;
}
}
50 changes: 50 additions & 0 deletions src/bar/BottomBar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package bar;

import main.Game;
import main.Help;
import java.awt.Rectangle;
import processing.core.PApplet;
import processing.core.PImage;

@SuppressWarnings("serial")
public class BottomBar extends PApplet {
private Rectangle bound;
private PImage bagImg = new PImage();
private PImage emptyTreasureImg = new PImage();
private PImage [][] treasure = new PImage[Game.MAX_LEVEL][3];
private PImage [] treasureGet = new PImage[Game.MAX_LEVEL];

public BottomBar (Rectangle bounds, int [] a) {
initTreasure();
bound = bounds;
for (int i=0; i<Game.MAX_LEVEL; i++)
treasureGet[i] = treasure[i][a[i]];
}
private void initTreasure () {
bagImg = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/bottomBar/bag.png"));
emptyTreasureImg = Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/bottomBar/emptytreasure.jpg"));
for (int i=0; i<Game.MAX_LEVEL; i++)
for (int j=0; j<2; j++)
treasure[i][j]= Help.loadPImageFromStream(this.getClass().getResourceAsStream("/res/bottomBar/data" + (i+1) + "_" + (j+1) + ".png"));
for (int i=0; i<Game.MAX_LEVEL; i++)
treasure[i][2]= emptyTreasureImg;
}
public void updateData (int [] a) {
for (int i=0; i<Game.MAX_LEVEL; i++)
treasureGet[i] = treasure[i][a[i]];
this.redraw();
}
@Override
public void setup () {
this.setFocusable(false);
size(bound.width, 50);
setLocation(0,670);
}
@Override
public void draw () {
background(63,90,108);
image(bagImg,0,0);
for (int i=0; i<Game.MAX_LEVEL; i++)
image(treasureGet[i], 70+i*60, 0);
}
}
Loading

0 comments on commit 66257ee

Please sign in to comment.