Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing old classes and reuploading images (for posterity's sake) #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Bird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package strategictoastinsertion;

/*
Creators: Matthew Godfrey, Seth Thomson, Jonah Monaghan
Created: May 18th, 2016
Purpose: player character class for the game "Strategic Toast Insertion"
*/
public class Bird extends STIObject{
int score;
public Bird(){
xPos = 25;
yPos = 25;
speed = 3;
type = "null";
imageString = "null";
score = 0;
}
public Bird(String birdType){
this();
this.type = birdType;
if(birdType.equalsIgnoreCase("hummer")||birdType.equalsIgnoreCase("pelican")||birdType.equalsIgnoreCase("flamingo")||birdType.equalsIgnoreCase("owl")||birdType.equalsIgnoreCase("tweeter")||birdType.equalsIgnoreCase("parrot")||birdType.equalsIgnoreCase("pigeon")){
imageString = "res/" + birdType + ".png";
}else{
System.out.println("ERROR: Invalid birdType");
}
}
public Bird(String birdType, int x, int y){
this(birdType);
xPos = x;
yPos = y;
}

public void moveUp(){
yPos += speed;
}

public void moveDown(){
yPos -= speed;
}

public void shoot(){

}
}
40 changes: 40 additions & 0 deletions Credits.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package strategictoastinsertion;

//Imports
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

/**
*
* @author Jonah Monaghan
* @version 1.00
*/
public class Credits extends BasicGameState {

public Credits(int state){

}


@Override
public int getID() {
return 2;
}

@Override
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {

}

@Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {


}

@Override
public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException {

}

}
40 changes: 40 additions & 0 deletions Menu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package strategictoastinsertion;

//Imports
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

/**
*
* @author Jonah Monaghan
* @version 1.00
*/
public class Menu extends BasicGameState {

public Menu(int state){

}


@Override
public int getID() {
return 0;
}

@Override
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {

}

@Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {


}

@Override
public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException {

}

}
83 changes: 83 additions & 0 deletions Play.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package strategictoastinsertion;
/*
Creators: Matthew Godfrey, Seth Thomson, Jonah Monaghan
Created: May 18th, 2016
Purpose: The state for basic gameplay
*/
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
/**
*
* @author Jonah Monaghan & Matthew Godfrey
* @version 1.00
*/
public class Play extends BasicGameState{
public Play(int state){

}
@Override
public int getID() {
return 1;
}
/**
*
* @author Matthew Godfrey & Jonah Monaghan
* @version 1.01
*/
Music themeSong;
Image bg;
Input input;

int bgX1, bgX2, bgY;


@Override
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
themeSong = new Music("res/portent.wav");
themeSong.loop();
background();
}
@Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics grphcs) throws SlickException {
bgX1-=3;
bgX2-=3;
bg.draw(bgX1,bgY);
bg.draw(bgX2, bgY);
if(bgX1 < -1000){
bgX1 = 996;
}else if(bgX2 < -1000){
bgX2 = 996;
}
}
@Override
public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException {
input = gc.getInput();
if(!input.isKeyPressed(Input.KEY_R)){
} else {
background();
}
}






public void background() throws SlickException{
String imagePath = "res/images/cave.png";
switch (((int)((Math.random()*4)-0))){
case 0: imagePath = "res/images/cave.png";
break;
case 1: imagePath = "res/images/sunset.png";
break;
case 2: imagePath = "res/images/starry.png";
break;
case 3: imagePath = "res/images/beach.png";
break;
}
bg = new Image(imagePath);
bgX1 = 0;
bgX2 = 1000;
bgY = 0;
}
}
80 changes: 80 additions & 0 deletions STIObject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
Creators: Matthew Godfrey, Seth Thomson, Jonah Monaghan
Created: May 18th, 2016
Purpose: abstract class to handle objects for the game "Strategic Toast Insertion"
*/
package strategictoastinsertion;

/**
*
* @author Seth Thomson
*/
public class STIObject {
int xPos, yPos, speed;
String type, imageString;

public STIObject() {
xPos = 0;
yPos = 0;
speed = 1;
type = "null";
imageString = "null";
}

public STIObject(int xPos, int yPos) {
this.xPos = xPos;
this.yPos = yPos;
}

public STIObject(int xPos, int yPos, int speed) {
this(xPos, yPos);
this.speed = speed;
}

public STIObject(int xPos, int yPos, int speed, String type) {
this(xPos, yPos, speed);
this.type = type;
}


public int getxPos() {
return xPos;
}

public void setxPos(int xPos) {
this.xPos = xPos;
}

public int getyPos() {
return yPos;
}

public void setyPos(int yPos) {
this.yPos = yPos;
}

public int getSpeed() {
return speed;
}

public void setSpeed(int speed) {
this.speed = speed;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getImageString() {
return imageString;
}

public void setImageString(String imageString) {
this.imageString = imageString;
}

}
60 changes: 60 additions & 0 deletions SettingUp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package strategictoastinsertion;

//Imports
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

/**
*
* @author Jonah Monaghan
* @version 1.01
*/
public class SettingUp extends StateBasedGame {

static int width = 640;
static int height = 480;

static boolean fullscreen = false;
static boolean showFPS = true;

static final String title = "Strategic Toast Insertion (STI)";
static final int fpslimit = 60;
static final int menu = 0;
static final int play = 1;
static final int credits = 2;

public SettingUp(String title) {
super(title);
this.addState(new Menu(menu));
this.addState(new Play(play));
this.addState(new Credits(credits));
}

@Override
public void initStatesList(GameContainer gc) throws SlickException {
this.getState(menu).init(gc, this);
this.getState(play).init(gc, this);
this.getState(credits).init(gc, this);

//this.enterState(menu) [ACTUAL LINE OF CODE]
this.enterState(play); //ONLY FOR TESTING
}

public static void main(String[] args) throws SlickException {

AppGameContainer app;
try{
app = new AppGameContainer(new SettingUp(title));
app.setDisplayMode(width, height, fullscreen);
app.setSmoothDeltas(true);
app.setTargetFrameRate(fpslimit);
app.setShowFPS(showFPS);
app.start();
}catch(SlickException e){
e.printStackTrace();
}
}



}
Loading