Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangoMango committed Jul 9, 2023
1 parent b0fb236 commit cb3af50
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 23 deletions.
Binary file added icon.ico
Binary file not shown.
Binary file added icon.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: 2 additions & 0 deletions src/main/java/com/orangomango/retoohs/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public void start(Stage stage){
Scene scene = new Scene(hs.getLayout(), WIDTH, HEIGHT);
stage.setScene(scene);
stage.setResizable(false);
stage.setTitle("Retoohs by OrangoMango");
stage.getIcons().add(loadImage("icon.png"));
stage.show();
}

Expand Down
26 changes: 22 additions & 4 deletions src/main/java/com/orangomango/retoohs/game/Boss.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.orangomango.retoohs.game;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import javafx.scene.image.Image;

import java.util.Random;

Expand All @@ -15,12 +15,28 @@ public class Boss extends GameObject{
private double speed;
private long lastSuper;
private Double fixedAngle;
private Image image = MainApplication.loadImage("boss_smash.png");
private int smashFrameIndex;
private boolean smash;

public Boss(GraphicsContext gc, double x, double y){
super(gc, x, y, 128, 128);
this.speed = SPEED;
this.hp = HEALTH;
this.lastSuper = System.currentTimeMillis();
startAnimation(3, 250);
startSmashAnimation(10, 150);
}

private void startSmashAnimation(int frames, int time){
MainApplication.schedulePeriodic(() -> {
if (!GameScreen.getInstance().isPaused()){
this.smashFrameIndex++;
if (this.smashFrameIndex == frames){
this.smashFrameIndex = 0;
}
}
}, time);
}

private void makeSuper(){
Expand All @@ -30,7 +46,10 @@ private void makeSuper(){
this.hp += 50;
switch (n){
case 0:
for (int i = 0; i < 5; i++){
int amount = random.nextInt(2);
this.smash = true;
MainApplication.schedule(() -> this.smash = false, 1500);
for (int i = 0; i < 3+amount; i++){
Enemy e = new Enemy(this.gc, random.nextInt(MainApplication.WIDTH-200)+100, random.nextInt(MainApplication.HEIGHT-200)+100, GameScreen.getInstance().getPlayer(), 0);
GameScreen.getInstance().getGameObjects().add(e);
}
Expand All @@ -49,11 +68,10 @@ private void makeSuper(){

@Override
public void render(){
gc.setFill(Color.BLACK);
gc.fillOval(this.x-this.w/2, this.y-this.h/2, this.w, this.h);
Player player = GameScreen.getInstance().getPlayer();
double angle = this.fixedAngle != null ? this.fixedAngle : Math.atan2(player.getY()-this.y, player.getX()-this.x);
double distance = Math.sqrt(Math.pow(player.getX()-this.x, 2)+Math.pow(player.getY()-this.y, 2));
gc.drawImage(this.image, 1+(128+2)*(this.smash ? this.smashFrameIndex : this.frameIndex), 1, 128, 128, this.x-this.w/2, this.y-this.h/2, this.w, this.h);
if (distance < this.w/2+40){
if (this.attack){
player.damage(25);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/orangomango/retoohs/ui/CreditsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import javafx.scene.layout.StackPane;
import javafx.scene.canvas.*;
import javafx.scene.paint.Color;
import javafx.scene.image.Image;
import javafx.animation.*;
import javafx.util.Duration;
import javafx.scene.input.MouseButton;
Expand All @@ -18,6 +19,7 @@ public class CreditsScreen{
private double scroll;
private String credits;
private MediaPlayer mediaPlayer;
private Image background = MainApplication.loadImage("background.png");

public CreditsScreen(){
this.mediaPlayer = MainApplication.playSound(MainApplication.MENU_BACKGROUND_MUSIC, true);
Expand Down Expand Up @@ -57,8 +59,7 @@ public StackPane getLayout(){

private void update(GraphicsContext gc){
gc.clearRect(0, 0, MainApplication.WIDTH, MainApplication.HEIGHT);
gc.setFill(Color.YELLOW);
gc.fillRect(0, 0, MainApplication.WIDTH, MainApplication.HEIGHT);
gc.drawImage(this.background, 0, 0, MainApplication.WIDTH, MainApplication.HEIGHT);
gc.setFill(Color.BLACK);
gc.save();
gc.setFont(GameScreen.FONT_30);
Expand Down
26 changes: 21 additions & 5 deletions src/main/java/com/orangomango/retoohs/ui/GameOverScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@
import javafx.scene.paint.Color;
import javafx.animation.*;
import javafx.util.Duration;
import javafx.scene.text.TextAlignment;
import javafx.scene.input.MouseButton;
import javafx.scene.media.MediaPlayer;

import com.orangomango.retoohs.MainApplication;

public class GameOverScreen{
private MediaPlayer mediaPlayer;
private long time;
private int score;
private int bossesKilled;

public GameOverScreen(){
public GameOverScreen(long time, int s, int b){
this.time = time;
this.score = s;
this.bossesKilled = b;
MainApplication.schedule(() -> this.mediaPlayer = MainApplication.playSound(MainApplication.GAMEOVER_BACKGROUND_MUSIC, true), 500);
}

Expand All @@ -22,9 +30,11 @@ public StackPane getLayout(){
GraphicsContext gc = canvas.getGraphicsContext2D();

canvas.setOnMousePressed(e -> {
if (this.mediaPlayer != null) this.mediaPlayer.stop();
HomeScreen hs = new HomeScreen();
MainApplication.stage.getScene().setRoot(hs.getLayout());
if (e.getButton() == MouseButton.PRIMARY){
if (this.mediaPlayer != null) this.mediaPlayer.stop();
HomeScreen hs = new HomeScreen();
MainApplication.stage.getScene().setRoot(hs.getLayout());
}
});

Timeline loop = new Timeline(new KeyFrame(Duration.millis(1000.0/MainApplication.FPS), e -> update(gc)));
Expand All @@ -36,6 +46,12 @@ public StackPane getLayout(){
}

private void update(GraphicsContext gc){

gc.clearRect(0, 0, MainApplication.WIDTH, MainApplication.HEIGHT);
gc.setFill(Color.ORANGE);
gc.fillRect(0, 0, MainApplication.WIDTH, MainApplication.HEIGHT);
gc.setFill(Color.BLACK);
gc.setFont(GameScreen.FONT_45);
gc.setTextAlign(TextAlignment.CENTER);
gc.fillText("GAME OVER\n\nYou survived "+(this.time/1000)+" seconds\nwith a score of "+this.score+"\nand killed "+this.bossesKilled+" bosses\n\nClick the screen to exit", MainApplication.WIDTH/2, 125);
}
}
15 changes: 9 additions & 6 deletions src/main/java/com/orangomango/retoohs/ui/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class GameScreen{
public boolean playsPlayer = true;
private Reverser reverser;
private List<MenuButton> pauseButtons = new ArrayList<>();
private int bossesKilled;

private Image groundImage = MainApplication.loadImage("ground.png");
private Image[] stoneGroundImages = new Image[]{MainApplication.loadImage("ground_stone_0.png"), MainApplication.loadImage("ground_stone_1.png")};
Expand Down Expand Up @@ -197,13 +198,13 @@ public StackPane getLayout(){

this.startTime = System.currentTimeMillis();

Image homeButtonImage = MainApplication.loadImage("warning.png");
Image homeButtonImage = MainApplication.loadImage("button_home.jpg");
this.pauseButtons.add(new MenuButton(gc, 420, 300, 64, 64, homeButtonImage, () -> {
quit();
HomeScreen hs = new HomeScreen();
MainApplication.stage.getScene().setRoot(hs.getLayout());
}));
Image resumeButtonImage = MainApplication.loadImage("warning.png");
Image resumeButtonImage = MainApplication.loadImage("button_resume.jpg");
this.pauseButtons.add(new MenuButton(gc, 520, 300, 64, 64, resumeButtonImage, () -> setPause(false)));

this.loop = new Timeline(new KeyFrame(Duration.millis(1000.0/MainApplication.FPS), e -> update(gc)));
Expand Down Expand Up @@ -381,6 +382,8 @@ private void update(GraphicsContext gc){
// Render bonuspoint
this.bpoint1.render();
this.bpoint2.render();

long diff = System.currentTimeMillis()-this.startTime-this.pausedTime;

// Render gameObjects
for (int i = 0; i < this.gameObjects.size(); i++){
Expand All @@ -401,7 +404,7 @@ private void update(GraphicsContext gc){
if (this.playsPlayer){
MainApplication.playSound(MainApplication.DEATH_SOUND, false);
quit();
GameOverScreen gos = new GameOverScreen();
GameOverScreen gos = new GameOverScreen(diff, this.score, this.bossesKilled);
MainApplication.stage.getScene().setRoot(gos.getLayout());
return;
} else {
Expand All @@ -422,6 +425,7 @@ private void update(GraphicsContext gc){
if (obj instanceof Boss){
this.currentBoss = null;
this.score += 400;
this.bossesKilled++;
this.bossExtraScore += this.score-this.lastBossScore;
changeMusic(MainApplication.BACKGROUND_MUSIC);
}
Expand Down Expand Up @@ -554,8 +558,8 @@ private void update(GraphicsContext gc){

if ((this.keys.getOrDefault(KeyCode.Q, false) && this.player.getHP() < 90) || this.player.getHP() < 40){
// heal
long diff = System.currentTimeMillis()-this.lastHeal;
if (diff > 30000){
long hdiff = System.currentTimeMillis()-this.lastHeal;
if (hdiff > 30000){
MainApplication.playSound(MainApplication.HEAL_SOUND, false);
this.player.heal(60);
this.lastHeal = System.currentTimeMillis();
Expand Down Expand Up @@ -634,7 +638,6 @@ private void update(GraphicsContext gc){
// Time
gc.setFill(Color.BLACK);
gc.setFont(FONT_30);
long diff = System.currentTimeMillis()-this.startTime-this.pausedTime;
gc.fillText(String.format("%2d:%02d", diff/60000, diff/1000%60), 20, MainApplication.HEIGHT-20);

this.reverser.render();
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/orangomango/retoohs/ui/HomeScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import javafx.scene.layout.StackPane;
import javafx.scene.canvas.*;
import javafx.scene.paint.Color;
import javafx.scene.image.Image;
import javafx.animation.*;
import javafx.util.Duration;
Expand All @@ -17,6 +16,8 @@ public class HomeScreen{
private MediaPlayer mediaPlayer;
private Timeline loop;
private List<MenuButton> buttons = new ArrayList<>();
private Image background = MainApplication.loadImage("background.png");
private Image logo = MainApplication.loadImage("logo.png");

public HomeScreen(){
this.mediaPlayer = MainApplication.playSound(MainApplication.MENU_BACKGROUND_MUSIC, true);
Expand All @@ -35,15 +36,15 @@ public StackPane getLayout(){
}
});

Image playButtonImage = MainApplication.loadImage("warning.png"); //placeholder
MenuButton playButton = new MenuButton(gc, 425, 250, 150, 50, playButtonImage, () -> {
Image playButtonImage = MainApplication.loadImage("button_play.jpg"); //placeholder
MenuButton playButton = new MenuButton(gc, 425, 300, 150, 50, playButtonImage, () -> {
this.loop.stop();
if (this.mediaPlayer != null) this.mediaPlayer.stop();
GameScreen gs = new GameScreen();
MainApplication.stage.getScene().setRoot(gs.getLayout());
});
this.buttons.add(playButton);
Image creditsButtonImage = MainApplication.loadImage("warning.png"); //placeholder
Image creditsButtonImage = MainApplication.loadImage("button_credits.jpg"); //placeholder
MenuButton creditsButton = new MenuButton(gc, 425, 400, 150, 50, creditsButtonImage, () -> {
this.loop.stop();
if (this.mediaPlayer != null) this.mediaPlayer.stop();
Expand All @@ -62,8 +63,8 @@ public StackPane getLayout(){

private void update(GraphicsContext gc){
gc.clearRect(0, 0, MainApplication.WIDTH, MainApplication.HEIGHT);
gc.setFill(Color.LIME);
gc.fillRect(0, 0, MainApplication.WIDTH, MainApplication.HEIGHT);
gc.drawImage(this.background, 0, 0, MainApplication.WIDTH, MainApplication.HEIGHT);
gc.drawImage(this.logo, 350, 150, 300, 100);
for (MenuButton mb : this.buttons){
mb.render();
}
Expand Down
Binary file added src/main/resources/audio/space_gun.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions src/main/resources/bulletConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,29 @@
},
"angles" : [0],
"screenShake" : true
},
"space_gun" : {
"audioName" : "space_gun.wav",
"imageName" : "normal_gun.png",
"speed" : 15,
"damage" : 40,
"ammo" : 5,
"ammoAmount" : 2,
"cooldown" : 500,
"maxDistance" : 800,
"rarity" : 1,
"goPast" : false,
"explode" : false,
"timing" : {
"amount" : 1,
"time" : 0
},
"distanceDamage" : {
"min" : 0,
"max" : 0,
"increment" : 0
},
"angles" : [0],
"screenShake" : true
}
}
Binary file added src/main/resources/images/background.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 src/main/resources/images/boss_smash.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 src/main/resources/images/button_credits.jpg
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 src/main/resources/images/button_home.jpg
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 src/main/resources/images/button_play.jpg
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 src/main/resources/images/button_resume.jpg
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 src/main/resources/images/icon.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 src/main/resources/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cb3af50

Please sign in to comment.