Skip to content
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
3 changes: 0 additions & 3 deletions gameNoName/bin/.gitignore

This file was deleted.

Binary file added gameNoName/bin/PixelRush-Title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gameNoName/bin/PixelRush-TitleS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gameNoName/bin/audio/Temp/level2.wav
Binary file not shown.
Binary file modified gameNoName/bin/audio/level2.wav
Binary file not shown.
Binary file added gameNoName/bin/backgroundMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gameNoName/bin/entities/Player.class
Binary file not shown.
Binary file added gameNoName/bin/explode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gameNoName/bin/gamestates/Credits.class
Binary file not shown.
Binary file modified gameNoName/bin/gamestates/GameOptions.class
Binary file not shown.
Binary file modified gameNoName/bin/gamestates/Menu.class
Binary file not shown.
Binary file modified gameNoName/bin/gamestates/Playing.class
Binary file not shown.
Binary file modified gameNoName/bin/levels/LevelManager.class
Binary file not shown.
Binary file modified gameNoName/bin/main/Game.class
Binary file not shown.
Binary file added gameNoName/bin/objects/BackgroundTree.class
Binary file not shown.
Binary file added gameNoName/bin/objects/Explosion.class
Binary file not shown.
Binary file added gameNoName/bin/objects/Grass.class
Binary file not shown.
Binary file modified gameNoName/bin/objects/ObjectManager.class
Binary file not shown.
Binary file added gameNoName/bin/outside_sprites_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gameNoName/bin/ui/GameCompletedOverlay.class
Binary file not shown.
Binary file added gameNoName/bin/utils/Constants$Dialogue.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$Directions.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$EnemyConstants.class
Binary file not shown.
Binary file added gameNoName/bin/utils/Constants$Environment.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$ObjectConstants.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$PlayerConstants.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$UI$Buttons.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$UI$PauseButtons.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$UI$URMButtons.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$UI$VolumeButtons.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/Constants$UI.class
Binary file not shown.
Binary file modified gameNoName/bin/utils/LoadSave.class
Binary file not shown.
Binary file added gameNoName/res/PixelRush-Title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gameNoName/res/PixelRush-TitleS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gameNoName/res/audio/Temp/level2.wav
Binary file not shown.
Binary file modified gameNoName/res/audio/level2.wav
Binary file not shown.
Binary file added gameNoName/res/backgroundMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gameNoName/res/explode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gameNoName/res/outside_sprites_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gameNoName/src/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Player extends Entity {
private float yDrawOffset = 4 * Game.SCALE;

// Jumping / Gravity
private float jumpSpeed = -2.25f * Game.SCALE;
private float jumpSpeed = -2.50f * Game.SCALE;
private float fallSpeedAfterCollision = 0.5f * Game.SCALE;

// StatusBarUI
Expand Down
16 changes: 11 additions & 5 deletions gameNoName/src/gamestates/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@
import ui.MenuButton;
import utils.LoadSave;

import static utils.Constants.UI.LOGO_HEIGHT;
import static utils.Constants.UI.LOGO_WIDTH;

public class Menu extends State implements Statemethods {

private MenuButton[] buttons = new MenuButton[3];
private BufferedImage backgroundImg, backgroundImgPink;
private BufferedImage backgroundImg, backgroundImgPink, logo;
private int menuX, menuY, menuWidth, menuHeight;
private int menuButtonX = Game.GAME_WIDTH / 4;

public Menu(Game game) {
super(game);
loadButtons();
loadBackground();
backgroundImgPink = LoadSave.GetSpriteAtlas(LoadSave.MENU_BACKGROUND_IMG);
logo = LoadSave.GetSpriteAtlas(LoadSave.LOGO);

}

Expand All @@ -32,9 +37,9 @@ private void loadBackground() {
}

private void loadButtons() {
buttons[0] = new MenuButton(Game.GAME_WIDTH / 2, (int) (130 * Game.SCALE), 0, Gamestate.PLAYING);
buttons[1] = new MenuButton(Game.GAME_WIDTH / 2, (int) (200 * Game.SCALE), 1, Gamestate.OPTIONS);
buttons[2] = new MenuButton(Game.GAME_WIDTH / 2, (int) (270 * Game.SCALE), 2, Gamestate.QUIT);
buttons[0] = new MenuButton(menuButtonX, (int) (130 * Game.SCALE + 90), 0, Gamestate.PLAYING);
buttons[1] = new MenuButton(menuButtonX, (int) (200 * Game.SCALE + 90), 1, Gamestate.OPTIONS);
buttons[2] = new MenuButton(menuButtonX, (int) (270 * Game.SCALE + 90), 2, Gamestate.QUIT);
}

@Override
Expand All @@ -46,7 +51,8 @@ public void update() {
@Override
public void draw(Graphics g) {
g.drawImage(backgroundImgPink, 0, 0, Game.GAME_WIDTH, Game.GAME_HEIGHT, null);
g.drawImage(backgroundImg, menuX, menuY, menuWidth, menuHeight, null);
// g.drawImage(backgroundImg, menuX, menuY, menuWidth, menuHeight, null);
g.drawImage(logo, 40, 30, LOGO_WIDTH, LOGO_HEIGHT, null);

for (MenuButton mb : buttons)
mb.draw(g);
Expand Down
6 changes: 3 additions & 3 deletions gameNoName/src/gamestates/Playing.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public class Playing extends State implements Statemethods {
private boolean paused = false;

private int xLvlOffset;
private int leftBorder = (int) (0.25 * Game.GAME_WIDTH);
private int rightBorder = (int) (0.75 * Game.GAME_WIDTH);
private int leftBorder = (int) (0.45 * Game.GAME_WIDTH);
private int rightBorder = (int) (0.55 * Game.GAME_WIDTH);
private int maxLvlOffsetX;

private BufferedImage backgroundImg, bigCloud, smallCloud, shipImgs[];
Expand Down Expand Up @@ -358,7 +358,7 @@ public void keyPressed(KeyEvent e) {
case KeyEvent.VK_E:
player.setAttacking(true);
break;
case KeyEvent.VK_R:
case KeyEvent.VK_Q:
player.powerAttack();
break;
case KeyEvent.VK_ESCAPE:
Expand Down
4 changes: 2 additions & 2 deletions gameNoName/src/levels/LevelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ private void buildAllLevels() {
private void importOutsideSprites() {
BufferedImage img = LoadSave.GetSpriteAtlas(LoadSave.LEVEL_ATLAS);
levelSprite = new BufferedImage[48];
for (int j = 0; j < 4; j++)
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 4; j++) // traverse in y axis
for (int i = 0; i < 12; i++) { // traverse in x axis
int index = j * 12 + i;
levelSprite[index] = img.getSubimage(i * 32, j * 32, 32, 32);
}
Expand Down
4 changes: 2 additions & 2 deletions gameNoName/src/main/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Game implements Runnable {

private GamePanel gamePanel;
private Thread gameThread;
private final int FPS_SET = 120;
private final int FPS_SET = 60;
private final int UPS_SET = 200;

private Playing playing;
Expand All @@ -32,7 +32,7 @@ public class Game implements Runnable {
public final static int GAME_WIDTH = TILES_SIZE * TILES_IN_WIDTH;
public final static int GAME_HEIGHT = TILES_SIZE * TILES_IN_HEIGHT;

private final boolean SHOW_FPS_UPS = true;
private final boolean SHOW_FPS_UPS = false;

public Game() {
System.out.println("size: " + GAME_WIDTH + " : " + GAME_HEIGHT);
Expand Down
2 changes: 1 addition & 1 deletion gameNoName/src/main/MainClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public static void main(String[] args) {
new Game();
}

}
}
14 changes: 14 additions & 0 deletions gameNoName/src/objects/Explosion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package objects;

import static utils.Constants.ObjectConstants.*;

public class Explosion extends GameObject {
public Explosion(int x, int y) {
super(x, y, EXPLOSION);
setAnimation(true);
}

public void update() {
updateAnimationTick();
}
}
40 changes: 37 additions & 3 deletions gameNoName/src/objects/ObjectManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ public class ObjectManager {

private Playing playing;
private BufferedImage[][] potionImgs, containerImgs;
private BufferedImage[] cannonImgs, grassImgs;
private BufferedImage[] cannonImgs, grassImgs, explosionImg;
private BufferedImage[][] treeImgs;
private BufferedImage spikeImg, cannonBallImg;
private ArrayList<Potion> potions;
private ArrayList<GameContainer> containers;
private ArrayList<Projectile> projectiles = new ArrayList<>();
private ArrayList<Explosion> explosions = new ArrayList<>();

private Level currentLevel;

Expand Down Expand Up @@ -110,6 +111,13 @@ private void loadImgs() {
cannonImgs[i] = temp.getSubimage(i * 40, 0, 40, 26);

cannonBallImg = LoadSave.GetSpriteAtlas(LoadSave.CANNON_BALL);

explosionImg = new BufferedImage[7];
BufferedImage exp = LoadSave.GetSpriteAtlas(LoadSave.EXPLOSION);

for (int i = 0; i < explosionImg.length; i++)
explosionImg[i] = exp.getSubimage(i * 54, 0, 54, 60);

treeImgs = new BufferedImage[2][4];
BufferedImage treeOneImg = LoadSave.GetSpriteAtlas(LoadSave.TREE_ONE_ATLAS);
for (int i = 0; i < 4; i++)
Expand Down Expand Up @@ -137,6 +145,7 @@ public void update(int[][] lvlData, Player player) {

updateCannons(lvlData, player);
updateProjectiles(lvlData, player);
updateExplosion();

}

Expand All @@ -150,13 +159,31 @@ private void updateProjectiles(int[][] lvlData, Player player) {
if (p.isActive()) {
p.updatePos();
if (p.getHitbox().intersects(player.getHitbox())) {
explosion((int) (p.getHitbox().x), (int) (p.getHitbox().y - 30));
player.changeHealth(-25);
p.setActive(false);
} else if (IsProjectileHittingLevel(p, lvlData))
} else if (IsProjectileHittingLevel(p, lvlData)) {
explosion((int) (p.getHitbox().x), (int) (p.getHitbox().y - 30));
p.setActive(false);
}

}
}

private void explosion(int x, int y) {
explosions.add(new Explosion(x, y));
}

private void updateExplosion() {
for (Explosion e : explosions) {
if (e.isActive())
e.update();

if (e.getAniIndex() == 6 && e.getAniTick() == 0)
e.setActive(false);
}
}

private boolean isPlayerInRange(Cannon c, Player player) {
int absValue = (int) Math.abs(player.getHitbox().x - c.getHitbox().x);
return absValue <= Game.TILES_SIZE * 5;
Expand Down Expand Up @@ -201,9 +228,17 @@ public void draw(Graphics g, int xLvlOffset) {
drawTraps(g, xLvlOffset);
drawCannons(g, xLvlOffset);
drawProjectiles(g, xLvlOffset);
drawExplosions(g, xLvlOffset);
drawGrass(g, xLvlOffset);
}

private void drawExplosions(Graphics g, int xLvlOffset) {
for (Explosion e : explosions) {
g.drawImage(explosionImg[e.getAniIndex()], (e.x - EXPLOSION_WIDTH / 2) - xLvlOffset, e.y,
EXPLOSION_WIDTH, EXPLOSION_HEIGHT, null);
}
}

private void drawGrass(Graphics g, int xLvlOffset) {
for (Grass grass : currentLevel.getGrass())
g.drawImage(grassImgs[grass.getType()], grass.getX() - xLvlOffset, grass.getY(), (int) (32 * Game.SCALE), (int) (32 * Game.SCALE), null);
Expand Down Expand Up @@ -242,7 +277,6 @@ private void drawCannons(Graphics g, int xLvlOffset) {
private void drawTraps(Graphics g, int xLvlOffset) {
for (Spike s : currentLevel.getSpikes())
g.drawImage(spikeImg, (int) (s.getHitbox().x - xLvlOffset), (int) (s.getHitbox().y - s.getyDrawOffset()), SPIKE_WIDTH, SPIKE_HEIGHT, null);

}

private void drawContainers(Graphics g, int xLvlOffset) {
Expand Down
14 changes: 13 additions & 1 deletion gameNoName/src/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static class ObjectConstants {
public static final int TREE_ONE = 7;
public static final int TREE_TWO = 8;
public static final int TREE_THREE = 9;
public static final int EXPLOSION = 10;

public static final int RED_POTION_VALUE = 15;
public static final int BLUE_POTION_VALUE = 10;
Expand All @@ -69,13 +70,18 @@ public static class ObjectConstants {
public static final int CANNON_WIDTH = (int) (CANNON_WIDTH_DEFAULT * Game.SCALE);
public static final int CANNON_HEIGHT = (int) (CANNON_HEIGHT_DEFAULT * Game.SCALE);

public static final int EXPLOSION_WIDTH_DEFAULT = 54;
public static final int EXPLOSION_HEIGHT_DEFAULT = 60;
public static final int EXPLOSION_WIDTH = (int) (EXPLOSION_WIDTH_DEFAULT * Game.SCALE);
public static final int EXPLOSION_HEIGHT = (int) (EXPLOSION_HEIGHT_DEFAULT * Game.SCALE);

public static int GetSpriteAmount(int object_type) {
switch (object_type) {
case RED_POTION, BLUE_POTION:
return 7;
case BARREL, BOX:
return 8;
case CANNON_LEFT, CANNON_RIGHT:
case CANNON_LEFT, CANNON_RIGHT, EXPLOSION:
return 7;
}
return 1;
Expand Down Expand Up @@ -226,6 +232,12 @@ public static class Environment {
}

public static class UI {

public static final int LOGO_WIDTH_DEFAULT = 344;
public static final int LOGO_HEIGHT_DEFAULT = 148;
public static final int LOGO_WIDTH = (int) (LOGO_WIDTH_DEFAULT * Game.SCALE);
public static final int LOGO_HEIGHT = (int) (LOGO_HEIGHT_DEFAULT * Game.SCALE);

public static class Buttons {
public static final int B_WIDTH_DEFAULT = 140;
public static final int B_HEIGHT_DEFAULT = 56;
Expand Down
6 changes: 4 additions & 2 deletions gameNoName/src/utils/LoadSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
public class LoadSave {

public static final String PLAYER_ATLAS = "player_sprites.png";
public static final String LEVEL_ATLAS = "outside_sprites.png";
public static final String LEVEL_ATLAS = "outside_sprites_alt.png";
public static final String MENU_BUTTONS = "button_atlas.png";
public static final String MENU_BACKGROUND = "menu_background.png";
public static final String PAUSE_BACKGROUND = "pause_menu.png";
public static final String SOUND_BUTTONS = "sound_button.png";
public static final String URM_BUTTONS = "urm_buttons.png";
public static final String VOLUME_BUTTONS = "volume_buttons.png";
public static final String MENU_BACKGROUND_IMG = "background_menu.png";
public static final String MENU_BACKGROUND_IMG = "backgroundMenu.png";
public static final String PLAYING_BG_IMG = "playing_bg_img.png";
public static final String BIG_CLOUDS = "big_clouds.png";
public static final String SMALL_CLOUDS = "small_clouds.png";
Expand All @@ -46,6 +46,8 @@ public class LoadSave {
public static final String WATER_TOP = "water_atlas_animation.png";
public static final String WATER_BOTTOM = "water.png";
public static final String SHIP = "ship.png";
public static final String EXPLOSION = "explode.png";
public static final String LOGO = "PixelRush-TitleS.png";

public static BufferedImage GetSpriteAtlas(String fileName) {
BufferedImage img = null;
Expand Down