Skip to content

Commit

Permalink
Add skyscraper game
Browse files Browse the repository at this point in the history
  • Loading branch information
aardvarrk committed Jan 25, 2013
1 parent 22751be commit f974337
Show file tree
Hide file tree
Showing 62 changed files with 4,098 additions and 1,346 deletions.
Binary file added Brick.class
Binary file not shown.
5 changes: 5 additions & 0 deletions Brick.ctxt
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.params=
comment0.target=void\ act()
comment0.text=\n\ Act\ -\ do\ whatever\ the\ Brick\ wants\ to\ do.\ This\ method\ is\ called\ whenever\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\n
numComments=1
19 changes: 19 additions & 0 deletions Brick.java
@@ -0,0 +1,19 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Brick here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Brick extends Surface
{
/**
* Act - do whatever the Brick wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}
Binary file added Enemy.class
Binary file not shown.
7 changes: 7 additions & 0 deletions Enemy.ctxt
@@ -0,0 +1,7 @@
#BlueJ class context
comment0.params=
comment0.target=void\ act()
comment0.text=\n\ Act\ -\ do\ whatever\ the\ Enemy\ wants\ to\ do.\ This\ method\ is\ called\ whenever\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\n
comment1.params=
comment1.target=int\ getPoints()
numComments=2
23 changes: 23 additions & 0 deletions Enemy.java
@@ -0,0 +1,23 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Enemy here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Enemy extends Actor
{
/**
* Act - do whatever the Enemy wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
public int getPoints()
{
return 0;
}
}
Binary file modified Game4.class
Binary file not shown.
12 changes: 7 additions & 5 deletions Game4.java
@@ -1,7 +1,9 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import greenfoot.*;


public class Game4 extends Buttons public class Game4 extends Buttons {
{ public void act() {
public void act() { if (Greenfoot.mouseClicked(this)) {
} Greenfoot.setWorld(new SkyscraperWorld());
}
}
} }
Binary file added GameOverScreen.class
Binary file not shown.
17 changes: 17 additions & 0 deletions GameOverScreen.ctxt
@@ -0,0 +1,17 @@
#BlueJ class context
comment0.params=
comment0.target=void\ act()
comment0.text=\n\ Act\ -\ do\ whatever\ the\ menuBar\ wants\ to\ do.\ This\ method\ is\ called\ whenever\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\n
comment1.params=
comment1.target=GameOverScreen()
comment1.text=\n\ Create\ a\ score\ board\ with\ dummy\ result\ for\ testing.\n
comment2.params=score\ coins\ total
comment2.target=GameOverScreen(int,\ int,\ int)
comment3.params=title\ prefix\ score
comment3.target=void\ makeScoreImage(java.lang.String,\ java.lang.String,\ int)
comment3.text=\n\ Make\ the\ score\ board\ image.\n
comment4.params=title\ prefix\ coins
comment4.target=void\ makeCoinImage(java.lang.String,\ java.lang.String,\ int)
comment5.params=title\ prefix\ total
comment5.target=void\ makeTotalImage(java.lang.String,\ java.lang.String,\ int)
numComments=6
73 changes: 73 additions & 0 deletions GameOverScreen.java
@@ -0,0 +1,73 @@
import greenfoot.*;
import java.awt.Color; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Font;
import java.util.Calendar;
/**
* Write a description of class Gameoverscreen here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class GameOverScreen extends Actor
{
/**
* Act - do whatever the menuBar wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
}
public static final float FONT_SIZE = 48.0f;
/**
* Create a score board with dummy result for testing.
*/
/**
* Create a score board with dummy result for testing.
*/
public GameOverScreen(){

//Counter.getValue(); + Coins.getCoinValue(); = total
}

public GameOverScreen(int score, int coins, int total){
makeScoreImage("Game Over", "Score: ", score);
makeCoinImage("Game Over", "Coins: ", coins);
makeTotalImage("Game Over", "Total: ", total);
}

/**
* Make the score board image.
*/
private void makeScoreImage(String title, String prefix, int score) {
GreenfootImage image = getImage();
image.scale(800, 800);
Font font = image.getFont();
font = font.deriveFont(FONT_SIZE);
image.setFont(font);
image.setColor(Color.BLUE);
image.drawString(prefix + score, 280, 400);
setImage(image);
}

private void makeCoinImage(String title, String prefix, int coins) {
GreenfootImage image = getImage();
image.scale(800, 800);
Font font = image.getFont();
font = font.deriveFont(FONT_SIZE);
image.setFont(font);
image.setColor(Color.BLUE);
image.drawString(prefix + coins, 280, 500);
setImage(image);
}

private void makeTotalImage(String title, String prefix, int total) {
GreenfootImage image = getImage();
image.scale(800, 800);
Font font = image.getFont();
font = font.deriveFont(FONT_SIZE);
image.setFont(font);
image.setColor(Color.BLUE);
image.drawString(prefix + total, 280, 600);
setImage(image);
}
}
Binary file added Ground.class
Binary file not shown.
5 changes: 5 additions & 0 deletions Ground.ctxt
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.params=
comment0.target=void\ act()
comment0.text=\n\ Act\ -\ do\ whatever\ the\ Ground\ wants\ to\ do.\ This\ method\ is\ called\ whenever\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\n
numComments=1
19 changes: 19 additions & 0 deletions Ground.java
@@ -0,0 +1,19 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Ground here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Ground extends Surface
{
/**
* Act - do whatever the Ground wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}
Binary file modified MenuBar.class
Binary file not shown.
6 changes: 4 additions & 2 deletions MenuBar.ctxt
@@ -1,4 +1,6 @@
#BlueJ class context #BlueJ class context
comment0.params= comment0.params=
comment0.target=MenuBar() comment0.target=void\ act()
numComments=1 comment1.params=
comment1.target=MenuBar()
numComments=2
13 changes: 5 additions & 8 deletions MenuBar.java
@@ -1,15 +1,12 @@
import greenfoot.*; import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Dit is de menubar die onderaan wordt getoond.
*
* Project 42
*/


public class MenuBar extends Actor public class MenuBar extends Actor
{ {
public void act()
{
}

public MenuBar(){ public MenuBar(){
getImage(); getImage();
} }
} }

Binary file added MovingBrickLeft.class
Binary file not shown.
12 changes: 12 additions & 0 deletions MovingBrickLeft.ctxt
@@ -0,0 +1,12 @@
#BlueJ class context
comment0.params=leftT\ rightT
comment0.target=MovingBrickLeft(int,\ int)
comment0.text=\n\ Move\ in\ the\ direction\ we\ are\ currently\ moving\ in.\ Turn\ if\ we\ reach\ a\ turning\ point.\n
comment1.params=
comment1.target=void\ act()
comment2.params=
comment2.target=boolean\ atTurningPoint()
comment2.text=\n\ Test\ if\ we\ are\ at\ one\ of\ the\ turning\ points.\n
comment3.params=
comment3.target=int\ getMovingBrickLeftSpeed()
numComments=4
43 changes: 43 additions & 0 deletions MovingBrickLeft.java
@@ -0,0 +1,43 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class MovingBrick here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MovingBrickLeft extends Surface
{
private int speed = -1;
private int leftTurn;
private int rightTurn;

/**
* Move in the direction we are currently moving in. Turn if we reach a turning point.
*/
public MovingBrickLeft(int leftT, int rightT) {
leftTurn = leftT;
rightTurn = rightT;
}

public void act()
{
setLocation ( getX() + speed, getY() );

if (atTurningPoint()) {
speed = -speed;
}
}

/**
* Test if we are at one of the turning points.
*/
public boolean atTurningPoint()
{
return (getX() <= leftTurn || getX() >= rightTurn);
}

public int getMovingBrickLeftSpeed(){
return speed;
}
}
Binary file added MovingBrickRight.class
Binary file not shown.
12 changes: 12 additions & 0 deletions MovingBrickRight.ctxt
@@ -0,0 +1,12 @@
#BlueJ class context
comment0.params=leftT\ rightT
comment0.target=MovingBrickRight(int,\ int)
comment0.text=\n\ Move\ in\ the\ direction\ we\ are\ currently\ moving\ in.\ Turn\ if\ we\ reach\ a\ turning\ point.\n
comment1.params=
comment1.target=void\ act()
comment2.params=
comment2.target=boolean\ atTurningPoint()
comment2.text=\n\ Test\ if\ we\ are\ at\ one\ of\ the\ turning\ points.\n
comment3.params=
comment3.target=int\ getMovingBrickRightSpeed()
numComments=4
43 changes: 43 additions & 0 deletions MovingBrickRight.java
@@ -0,0 +1,43 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class MovingBrick here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MovingBrickRight extends Surface
{
private int speed = 1;
private int leftTurn;
private int rightTurn;

/**
* Move in the direction we are currently moving in. Turn if we reach a turning point.
*/
public MovingBrickRight(int leftT, int rightT) {
leftTurn = leftT;
rightTurn = rightT;
}

public void act()
{
setLocation ( getX() + speed, getY() );

if (atTurningPoint()) {
speed = -speed;
}
}

/**
* Test if we are at one of the turning points.
*/
public boolean atTurningPoint()
{
return (getX() <= leftTurn || getX() >= rightTurn);
}

public int getMovingBrickRightSpeed(){
return speed;
}
}
Binary file added MovingBrickUp.class
Binary file not shown.
12 changes: 12 additions & 0 deletions MovingBrickUp.ctxt
@@ -0,0 +1,12 @@
#BlueJ class context
comment0.params=topT\ bottomT
comment0.target=MovingBrickUp(int,\ int)
comment0.text=\n\ Move\ in\ the\ direction\ we\ are\ currently\ moving\ in.\ Turn\ if\ we\ reach\ a\ turning\ point.\n
comment1.params=
comment1.target=void\ act()
comment2.params=
comment2.target=boolean\ atTurningPoint()
comment2.text=\n\ Test\ if\ we\ are\ at\ one\ of\ the\ turning\ points.\n
comment3.params=
comment3.target=int\ getMovingBrickUpSpeed()
numComments=4
43 changes: 43 additions & 0 deletions MovingBrickUp.java
@@ -0,0 +1,43 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class MovingBrick here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MovingBrickUp extends Surface
{
private int speed = 1;
private int topTurn;
private int bottomTurn;

/**
* Move in the direction we are currently moving in. Turn if we reach a turning point.
*/
public MovingBrickUp(int topT, int bottomT) {
topTurn = topT;
bottomTurn = bottomT;
}

public void act()
{
setLocation ( getX(), getY()+ speed );

if (atTurningPoint()) {
speed = -speed;
}
}

/**
* Test if we are at one of the turning points.
*/
public boolean atTurningPoint()
{
return (getY() <= topTurn || getY() >= bottomTurn);
}

public int getMovingBrickUpSpeed(){
return speed;
}
}
Binary file added MovingWater.class
Binary file not shown.

0 comments on commit f974337

Please sign in to comment.