Last GGL commit
BIN
res/audio/background.ogg
Normal file
BIN
res/audio/macarena_court.ogg
Normal file
BIN
res/textures/ballon.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
res/textures/coffre.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
res/textures/default_transp.png
Normal file
After Width: | Height: | Size: 135 B |
BIN
res/textures/gel.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
res/textures/inverser.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 187 B |
BIN
res/textures/noteMusic.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
res/textures/stop.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
|
@ -1,20 +1,42 @@
|
|||
package globalgamejam;
|
||||
|
||||
//http://www.tomdalling.com/blog/modern-opengl/08-even-more-lighting-directional-lights-spotlights-multiple-lights/
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_RESIZABLE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_SAMPLES;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_VISIBLE;
|
||||
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
||||
import static org.lwjgl.glfw.GLFW.glfwDefaultWindowHints;
|
||||
import static org.lwjgl.glfw.GLFW.glfwDestroyWindow;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetVideoMode;
|
||||
import static org.lwjgl.glfw.GLFW.glfwInit;
|
||||
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
|
||||
import static org.lwjgl.glfw.GLFW.glfwPollEvents;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetWindowPos;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetWindowTitle;
|
||||
import static org.lwjgl.glfw.GLFW.glfwShowWindow;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
|
||||
import static org.lwjgl.glfw.GLFW.glfwTerminate;
|
||||
import static org.lwjgl.glfw.GLFW.glfwWindowHint;
|
||||
import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose;
|
||||
import static org.lwjgl.opengl.GL11.GL_VERSION;
|
||||
import static org.lwjgl.opengl.GL11.glGetString;
|
||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
||||
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL13.GL_MULTISAMPLE;
|
||||
import static org.lwjgl.system.MemoryUtil.*;
|
||||
import java.io.File;
|
||||
|
||||
import org.lwjgl.glfw.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||
import org.lwjgl.glfw.GLFWVidMode;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import globalgamejam.audio.*;
|
||||
import globalgamejam.game.*;
|
||||
import globalgamejam.input.*;
|
||||
import globalgamejam.math.*;
|
||||
import globalgamejam.render.*;
|
||||
import globalgamejam.audio.Audio;
|
||||
import globalgamejam.game.Game;
|
||||
import globalgamejam.game.MainMenuGame;
|
||||
import globalgamejam.input.Input;
|
||||
import globalgamejam.render.Camera;
|
||||
import globalgamejam.render.DisplayManager;
|
||||
|
||||
/**
|
||||
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
|
||||
|
@ -23,7 +45,7 @@ public class Main {
|
|||
|
||||
//Valeur de la fenetre
|
||||
public static final int WIDTH = 800,HEIGHT = 600;
|
||||
public static final String TITLE = "Test Shader OpenGL";
|
||||
public static final String TITLE = "Beach Fighter (OpenGL)";
|
||||
|
||||
//Variable pour la gestion de la fenetre
|
||||
public static long windowID = 0;
|
||||
|
@ -35,7 +57,10 @@ public class Main {
|
|||
public static long previous = System.currentTimeMillis(),previousInfo = System.currentTimeMillis(),previousTicks = System.currentTimeMillis();
|
||||
public static int FPS = 0,TICKS = 0;
|
||||
|
||||
public static boolean isDestroy = false;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.setProperty("org.lwjgl.librarypath", new File("libs").getAbsolutePath());
|
||||
//Creation de la fenetre
|
||||
//------------------------------------------------------------------------------------
|
||||
errorCallback = new GLFWErrorCallback() {
|
||||
|
@ -73,12 +98,12 @@ public class Main {
|
|||
//------------------------------------------------------------------------------------
|
||||
//glEnable(GL_MULTISAMPLE);//Activation du MSAA
|
||||
Input.init();
|
||||
game = new MainGame();
|
||||
game = new MainMenuGame();
|
||||
|
||||
Camera.transform();
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
while(!glfwWindowShouldClose(windowID)){
|
||||
while(!glfwWindowShouldClose(windowID) && !isDestroy){
|
||||
|
||||
if(System.currentTimeMillis() - previousTicks >= 1000/120){//Update TICKS
|
||||
glfwPollEvents();
|
||||
|
@ -105,7 +130,10 @@ public class Main {
|
|||
previousInfo = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void destroy(){
|
||||
game.destroy();
|
||||
Audio.destroy();
|
||||
glfwDestroyWindow(windowID);
|
||||
|
@ -115,7 +143,6 @@ public class Main {
|
|||
public static void changeGame(Game g){
|
||||
game.destroy();
|
||||
game = g;
|
||||
g.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,8 +50,9 @@ public class Audio {
|
|||
}
|
||||
|
||||
public static void destroy(){
|
||||
alcCloseDevice(device);
|
||||
alcDestroyContext(context);
|
||||
alcCloseDevice(device);
|
||||
ALC.destroy();
|
||||
}
|
||||
//------------------------------------------------------
|
||||
|
||||
|
|
26
src/globalgamejam/game/Coffre.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package globalgamejam.game;
|
||||
|
||||
import globalgamejam.physics.PhysicalEntity;
|
||||
import globalgamejam.tiles.CoffreTile;
|
||||
import globalgamejam.tiles.Tile;
|
||||
|
||||
public class Coffre extends PhysicalEntity {
|
||||
|
||||
private final Tile tile;
|
||||
|
||||
public Coffre(String texturePath, float x, float y){
|
||||
super(x, y, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
this.tile = new CoffreTile(texturePath, x, y);
|
||||
|
||||
this.setSizeXY(this.tile.getTexture().width, this.tile.getTexture().height);
|
||||
}
|
||||
|
||||
public Tile getTile(){
|
||||
return this.tile;
|
||||
}
|
||||
|
||||
public void makeEffect(int numPlayerHitCoffre){
|
||||
|
||||
}
|
||||
}
|
|
@ -2,9 +2,10 @@ package globalgamejam.game;
|
|||
|
||||
public enum EObjetType {
|
||||
|
||||
POISSON("res/textures/dechets1.png",-2, 0.75f),POMME("res/textures/dechets.png",-3, 0.75f),
|
||||
POISSON("res/textures/dechets1.png",-2, 0.5f),POMME("res/textures/dechets.png",-3, 0.75f),
|
||||
ETOILE_DE_MER("res/textures/bonus1.png",2, 0.75f),COQUILLAGE("res/textures/bonus2.png",3, 0.75f),
|
||||
COQUILLAGE2("res/textures/bonus3.png",4, 0.75f),BANANE("res/textures/banane.png",-5, 0.75f);
|
||||
COQUILLAGE2("res/textures/bonus3.png",4, 0.85f),BANANE("res/textures/banane.png",-5, 0.9f),
|
||||
BALLON("res/textures/ballon.png", 1, 0.5f);
|
||||
|
||||
private int points;
|
||||
private String filename;
|
||||
|
|
13
src/globalgamejam/game/EffectEnum.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package globalgamejam.game;
|
||||
|
||||
public enum EffectEnum {
|
||||
|
||||
INVERSE_SCREEN,
|
||||
SCORE_FREEZE,
|
||||
MUSIC_MULTIPLICATOR_J1,
|
||||
MUSIC_MULTIPLICATOR_J2,
|
||||
INVERSE_COMMAND_J1,
|
||||
INVERSE_COMMAND_J2,
|
||||
HEAVY_J1,
|
||||
HEAVY_J2
|
||||
}
|
66
src/globalgamejam/game/HighScore.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package globalgamejam.game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class HighScore implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 182903812903812908L;
|
||||
|
||||
private int[] topScore;
|
||||
private int length;
|
||||
|
||||
public HighScore(){
|
||||
this.topScore = new int[10];
|
||||
this.length = 10;
|
||||
}
|
||||
|
||||
public void put(int data){
|
||||
ArrayList<Integer> scores = new ArrayList<Integer>();
|
||||
boolean alreadyExist = false;
|
||||
for(int i : topScore){
|
||||
scores.add(i);
|
||||
if(i == data){
|
||||
alreadyExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!alreadyExist){
|
||||
scores.add(data);
|
||||
scores.sort(new Comparator<Integer>() {
|
||||
@Override
|
||||
public int compare(Integer o1, Integer o2) {
|
||||
return o2.compareTo(o1);
|
||||
}
|
||||
});
|
||||
|
||||
for(int i = 0;i < this.topScore.length;i++){
|
||||
this.topScore[i] = scores.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int[] getTopScores(){
|
||||
return this.topScore;
|
||||
}
|
||||
|
||||
public int getTopScore(){
|
||||
return this.topScore[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[");
|
||||
for(int i = 0;i < this.topScore.length;i++){
|
||||
sb.append(this.topScore[i]);
|
||||
if(i != this.topScore.length - 1)sb.append(",");
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,8 +2,14 @@ package globalgamejam.game;
|
|||
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import globalgamejam.Main;
|
||||
import globalgamejam.audio.Audio;
|
||||
import globalgamejam.gui.GUILabel;
|
||||
import globalgamejam.input.IO;
|
||||
import globalgamejam.interfaces.MainInterfaces;
|
||||
import globalgamejam.world.MainWorld;
|
||||
|
||||
|
@ -11,23 +17,52 @@ import globalgamejam.world.MainWorld;
|
|||
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
|
||||
*/
|
||||
public class MainGame extends Game{
|
||||
|
||||
public Audio audioBackground;
|
||||
public Audio audioMacarena;
|
||||
public Audio audioBennyHill;
|
||||
public Audio audioEffect;
|
||||
|
||||
public static final int SCORE_INIT = 200;
|
||||
public static final int SCORE_INIT = 500;
|
||||
public static final float START_TIMER = 300;
|
||||
public static float time_in_sec = 0;
|
||||
private MainWorld world;
|
||||
private MainInterfaces interfaces;
|
||||
public float[] scores;
|
||||
public final int helpKey = GLFW.GLFW_KEY_H;
|
||||
|
||||
public final int HELP_KEY = GLFW.GLFW_KEY_H;
|
||||
public HighScore highScore;
|
||||
public boolean isEnd = false;
|
||||
private GUILabel loading;
|
||||
@Override
|
||||
public void init() {
|
||||
loading = new GUILabel("Loading",10,10,Color.WHITE,"Arial",16);
|
||||
loading.render();
|
||||
|
||||
// load audio
|
||||
try{
|
||||
audioMacarena = new Audio("res/audio/macarena_court.ogg");
|
||||
audioMacarena.setGain(0.4f);
|
||||
|
||||
audioBennyHill = new Audio("res/audio/background.ogg");
|
||||
audioBennyHill.setGain(0.4f);
|
||||
} catch(Exception e){}
|
||||
|
||||
this.scores = new float[2];
|
||||
this.scores[0] = SCORE_INIT;
|
||||
this.scores[1] = SCORE_INIT;
|
||||
time_in_sec = START_TIMER;
|
||||
try{
|
||||
this.highScore = IO.loadHighScore("res/highscore");
|
||||
}catch(Exception e){
|
||||
this.highScore = new HighScore();
|
||||
}
|
||||
world = new MainWorld(this);
|
||||
interfaces = new MainInterfaces(this);
|
||||
loading.destroy();
|
||||
}
|
||||
|
||||
public void saveHighScore(){
|
||||
IO.writeHighScore("res/highscore", this.highScore);
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
|
@ -35,6 +70,7 @@ public class MainGame extends Game{
|
|||
this.scores[1] = SCORE_INIT;
|
||||
time_in_sec = START_TIMER;
|
||||
world.destroy();
|
||||
isEnd = false;
|
||||
world = new MainWorld(this);
|
||||
world.init();
|
||||
}
|
||||
|
@ -61,6 +97,6 @@ public class MainGame extends Game{
|
|||
interfaces.destroy();
|
||||
world.destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
99
src/globalgamejam/game/MainMenuGame.java
Normal file
|
@ -0,0 +1,99 @@
|
|||
package globalgamejam.game;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import globalgamejam.Main;
|
||||
import globalgamejam.gui.ActionGUI;
|
||||
import globalgamejam.gui.GUILabel;
|
||||
|
||||
public class MainMenuGame extends Game{
|
||||
|
||||
private GUILabel menuLabel;
|
||||
private GUILabel jouerLabel;
|
||||
private GUILabel quitterLabel;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
menuLabel = new GUILabel("MENU", 0, 10, Color.WHITE, "Arial", 32);
|
||||
menuLabel.setPosition(Main.WIDTH/2 - menuLabel.getWitdh()/2, 10);
|
||||
jouerLabel = new GUILabel("JOUER (A)", 0, 60, Color.WHITE, "Arial", 24);
|
||||
jouerLabel.setPosition(Main.WIDTH/2 - jouerLabel.getWitdh()/2, 70);
|
||||
jouerLabel.setAction(new ActionGUI(){
|
||||
@Override
|
||||
public void enter(float mouseX,float mouseY){
|
||||
jouerLabel.setColor(new Color(1, 1, 1, 0.5f));
|
||||
}
|
||||
@Override
|
||||
public void leave(float mouseX,float mouseY){
|
||||
jouerLabel.setColor(Color.WHITE);
|
||||
}
|
||||
@Override
|
||||
public void clicked(float mouseX, float mouseY, int buttonKey, int buttonState) {
|
||||
Main.changeGame(new MainGame());
|
||||
}
|
||||
@Override
|
||||
public void joystickButtonState(int idJoy,int id,int state){
|
||||
if(idJoy == GLFW.GLFW_JOYSTICK_1){
|
||||
if(state == 1 && id == 0){
|
||||
Main.changeGame(new MainGame());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
quitterLabel = new GUILabel("QUITTER (B)", 0, 80, Color.WHITE, "Arial", 24);
|
||||
quitterLabel.setPosition(Main.WIDTH/2 - quitterLabel.getWitdh()/2, 100);
|
||||
quitterLabel.setAction(new ActionGUI(){
|
||||
@Override
|
||||
public void enter(float mouseX,float mouseY){
|
||||
quitterLabel.setColor(new Color(1, 1, 1, 0.5f));
|
||||
}
|
||||
@Override
|
||||
public void leave(float mouseX,float mouseY){
|
||||
quitterLabel.setColor(Color.WHITE);
|
||||
}
|
||||
@Override
|
||||
public void clicked(float mouseX, float mouseY, int buttonKey, int buttonState) {
|
||||
Main.isDestroy = true;
|
||||
}
|
||||
@Override
|
||||
public void joystickButtonState(int idJoy,int id,int state){
|
||||
if(idJoy == GLFW.GLFW_JOYSTICK_1){
|
||||
if(state == 1 && id == 1){
|
||||
Main.isDestroy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
menuLabel.update();
|
||||
jouerLabel.update();
|
||||
quitterLabel.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render2D() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderGUI() {
|
||||
menuLabel.render();
|
||||
jouerLabel.render();
|
||||
quitterLabel.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
menuLabel.destroy();
|
||||
jouerLabel.destroy();
|
||||
quitterLabel.destroy();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package globalgamejam.game;
|
||||
|
||||
import globalgamejam.Main;
|
||||
import globalgamejam.math.Vector2f;
|
||||
import globalgamejam.physics.PhysicalEntity;
|
||||
import globalgamejam.render.Texture;
|
||||
|
@ -22,7 +23,7 @@ public class Player extends PhysicalEntity {
|
|||
private final float longueurBalai;
|
||||
|
||||
public Player(String path, float x, float y){
|
||||
super(x, y, 0, 0, 3, 0, 0, 10);
|
||||
super(x, y, 100, 0, 3, 0, 0, 10);
|
||||
this.tile = new PlayerTile(path, x, y);
|
||||
|
||||
this.setSizeXY(this.tile.getTexture().width, this.tile.getTexture().width);
|
||||
|
@ -42,27 +43,32 @@ public class Player extends PhysicalEntity {
|
|||
}
|
||||
|
||||
public void move(float x, float y){
|
||||
float oldX = this.x;
|
||||
float deltaX = 0;
|
||||
float oldY = this.y;
|
||||
float deltaY = 0;
|
||||
this.addPosition(x, y);
|
||||
|
||||
if(this.x - this.tile.getTexture().width / 2 < 30){
|
||||
this.x = this.tile.getTexture().width / 2 + 30;
|
||||
}
|
||||
else if(this.x + this.tile.getTexture().width / 2 > Main.WIDTH - 30){
|
||||
this.x = Main.WIDTH - this.tile.getTexture().width / 2 - 30;
|
||||
}
|
||||
|
||||
if(this.y - this.tile.getTexture().height / 2 < 34){
|
||||
this.y = this.tile.getTexture().height / 2 + 34;
|
||||
}
|
||||
else if(this.y + this.tile.getTexture().height / 2 > Main.HEIGHT + 18){
|
||||
this.y = Main.HEIGHT - this.tile.getTexture().height / 2 + 18;
|
||||
}
|
||||
|
||||
this.tile.setPosition(new Vector2f(this.x, this.y));
|
||||
this.tile.applyTransform();
|
||||
|
||||
this.brosse.addPosition(x, y);
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public boolean collideWithMur(PhysicalEntity entity){
|
||||
float distX = this.x - entity.getX();
|
||||
float distY = this.y - entity.getY();
|
||||
|
||||
float dist = (float)Math.sqrt( distX * distX + distY * distY );
|
||||
|
||||
return dist <= this.sizeRadius + entity.sizeRadius;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void resolveCollideWith(PhysicalEntity entity){
|
||||
|
||||
|
||||
deltaX = this.x - oldX;
|
||||
deltaY = this.y - oldY;
|
||||
this.brosse.addPosition(deltaX, deltaY);
|
||||
}
|
||||
|
||||
public void rotate(float angleRotation){
|
||||
|
|
|
@ -7,27 +7,23 @@ public class ActionGUI implements IActionGUI{
|
|||
|
||||
|
||||
@Override
|
||||
public void enter(float mouseX, float mouseY) {
|
||||
|
||||
}
|
||||
public void enter(float mouseX, float mouseY) {}
|
||||
|
||||
@Override
|
||||
public void leave(float mouseX, float mouseY) {
|
||||
|
||||
}
|
||||
public void leave(float mouseX, float mouseY) {}
|
||||
|
||||
@Override
|
||||
public void move(float mouseX, float mouseY) {
|
||||
|
||||
}
|
||||
public void move(float mouseX, float mouseY) {}
|
||||
|
||||
@Override
|
||||
public void hover(float mouseX, float mouseY) {
|
||||
|
||||
}
|
||||
public void hover(float mouseX, float mouseY) {}
|
||||
|
||||
@Override
|
||||
public void clicked(float mouseX, float mouseY, int buttonKey, int buttonState) {
|
||||
|
||||
}
|
||||
public void clicked(float mouseX, float mouseY, int buttonKey, int buttonState) {}
|
||||
|
||||
@Override
|
||||
public void joystickButtonState(int idJoy,int id,int state){}
|
||||
|
||||
@Override
|
||||
public void joystickAxisState(int idJoy,int id,float value){}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package globalgamejam.gui;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import globalgamejam.input.Input;
|
||||
|
||||
/**
|
||||
|
@ -50,6 +53,18 @@ public abstract class GUI {
|
|||
action.leave(mouseX,mouseY);
|
||||
}
|
||||
}
|
||||
for(int id : Input.getJoysticks()){
|
||||
try{
|
||||
FloatBuffer axis = Input.getJoysticksAxis(id);
|
||||
for(int i = 0;i < axis.capacity();i++){
|
||||
action.joystickAxisState(id, i, axis.get(i));
|
||||
}
|
||||
ByteBuffer buttons = Input.getJoysticksButton(id);
|
||||
for(int i = 0;i < buttons.capacity();i++){
|
||||
action.joystickButtonState(id, i, buttons.get(i));
|
||||
}
|
||||
}catch(Exception e){}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void render();
|
||||
|
|
|
@ -9,4 +9,6 @@ public interface IActionGUI {
|
|||
public void move(float mouseX,float mouseY);
|
||||
public void hover(float mouseX,float mouseY);
|
||||
public void clicked(float mouseX,float mouseY,int buttonKey,int buttonState);
|
||||
public void joystickButtonState(int idJoy,int id,int state);
|
||||
public void joystickAxisState(int idJoy,int id,float value);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package globalgamejam.input;
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import globalgamejam.game.HighScore;
|
||||
|
||||
/**
|
||||
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
|
||||
|
@ -17,4 +24,21 @@ public class IO {
|
|||
return r;
|
||||
}
|
||||
|
||||
public static HighScore loadHighScore(String path) throws Exception{
|
||||
FileInputStream fin = new FileInputStream(path);
|
||||
ObjectInputStream ois = new ObjectInputStream(fin);
|
||||
return (HighScore) ois.readObject();
|
||||
}
|
||||
|
||||
public static void writeHighScore(String path,HighScore highscore) {
|
||||
try (ObjectOutputStream oos =
|
||||
new ObjectOutputStream(new FileOutputStream(path))) {
|
||||
oos.writeObject(highscore);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package globalgamejam.interfaces;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import globalgamejam.Main;
|
||||
import globalgamejam.game.MainGame;
|
||||
import globalgamejam.gui.ActionGUI;
|
||||
|
@ -7,11 +13,6 @@ import globalgamejam.gui.GUI;
|
|||
import globalgamejam.gui.GUILabel;
|
||||
import globalgamejam.input.Input;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* Created by trexr on 20/01/2017.
|
||||
*/
|
||||
|
@ -45,6 +46,8 @@ public class MainInterfaces {
|
|||
private ArrayList<GUI> guisPartieTerminer;
|
||||
private GUILabel labelPartieTerminer;
|
||||
private GUILabel recommencerPartie;
|
||||
private GUILabel quitter;
|
||||
private GUILabel[] highScoresLabel;
|
||||
|
||||
|
||||
public MainInterfaces(MainGame game){
|
||||
|
@ -125,7 +128,8 @@ public class MainInterfaces {
|
|||
//Menu Partie Terminer
|
||||
labelPartieTerminer = new GUILabel("PARTIE TERMINER",Main.WIDTH/2,10,Color.WHITE,"Arial",32);
|
||||
labelPartieTerminer.setX(Main.WIDTH/2 - labelPartieTerminer.getWitdh()/2);
|
||||
recommencerPartie = new GUILabel("RECOMMENCER",Main.WIDTH/2,100,Color.WHITE,"Arial",16);
|
||||
|
||||
recommencerPartie = new GUILabel("RECOMMENCER (A)",Main.WIDTH/2,100,Color.WHITE,"Arial",16);
|
||||
recommencerPartie.setX(Main.WIDTH/2 - recommencerPartie.getWitdh()/2);
|
||||
recommencerPartie.setAction(new ActionGUI(){
|
||||
@Override
|
||||
|
@ -140,15 +144,87 @@ public class MainInterfaces {
|
|||
public void clicked(float mouseX,float mouseY,int buttonKey,int buttonState){
|
||||
game.reset();
|
||||
}
|
||||
@Override
|
||||
public void joystickButtonState(int idJoy,int id,int state){
|
||||
if(idJoy == GLFW.GLFW_JOYSTICK_1){
|
||||
if(state == 1 && id == 0){
|
||||
game.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
quitter = new GUILabel("QUITTER (B)", Main.WIDTH/2, 120, Color.WHITE, "Arial", 16);
|
||||
quitter.setX(Main.WIDTH/2 - quitter.getWitdh()/2);
|
||||
quitter.setAction(new ActionGUI(){
|
||||
@Override
|
||||
public void enter(float mouseX,float mouseY){
|
||||
quitter.setColor(new Color(1, 1, 1, 0.5f));
|
||||
}
|
||||
@Override
|
||||
public void leave(float mouseX,float mouseY){
|
||||
quitter.setColor(Color.WHITE);
|
||||
}
|
||||
@Override
|
||||
public void clicked(float mouseX,float mouseY,int buttonKey,int buttonState){
|
||||
Main.isDestroy = true;
|
||||
}
|
||||
@Override
|
||||
public void joystickButtonState(int idJoy,int id,int state){
|
||||
if(idJoy == GLFW.GLFW_JOYSTICK_1){
|
||||
if(state == 1 && id == 1){
|
||||
Main.isDestroy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
highScoresLabel = new GUILabel[10];
|
||||
for(int i = 0;i<10;i++){
|
||||
highScoresLabel[i] = new GUILabel(this.game.highScore.getTopScores()[i] + "",Main.WIDTH/2,150 + 20 * i,Color.WHITE,"Arial",16);
|
||||
highScoresLabel[i].setX(Main.WIDTH/2 - highScoresLabel[i].getWitdh()/2);
|
||||
guisPartieTerminer.add(highScoresLabel[i]);
|
||||
}
|
||||
guisPartieTerminer.add(labelPartieTerminer);
|
||||
guisPartieTerminer.add(recommencerPartie);
|
||||
guisPartieTerminer.add(quitter);
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(Input.isKey(this.game.helpKey)){
|
||||
boolean joysticksHelp = false;
|
||||
if(Input.getJoysticks().size() > 0){
|
||||
try{
|
||||
ByteBuffer b = Input.getJoysticksButton(0);
|
||||
if(b.get(3) == 1)joysticksHelp = true;
|
||||
}catch(Exception e){}
|
||||
}
|
||||
if(Input.isKey(this.game.HELP_KEY) || joysticksHelp){
|
||||
for(GUI g : guisHelp)g.update();
|
||||
}else if(this.game.scores[0] <= 0 || this.game.scores[1] <= 0 || MainGame.time_in_sec <= 0){
|
||||
int score = 0;
|
||||
if(!this.game.isEnd){
|
||||
if(this.game.scores[1]<this.game.scores[0]){
|
||||
this.game.highScore.put((int)this.game.scores[0]);
|
||||
score = (int)this.game.scores[0];
|
||||
}else{
|
||||
this.game.highScore.put((int)this.game.scores[1]);
|
||||
score = (int)this.game.scores[1];
|
||||
}
|
||||
this.game.saveHighScore();
|
||||
game.audioBackground.pauseSound();
|
||||
if(game.audioEffect != null){
|
||||
game.audioEffect.pauseSound();
|
||||
}
|
||||
}
|
||||
for(int i = 0;i<10;i++){
|
||||
highScoresLabel[i].setText(this.game.highScore.getTopScores()[i] + "");
|
||||
highScoresLabel[i].setX(Main.WIDTH/2 - highScoresLabel[i].getWitdh()/2);
|
||||
if(this.game.highScore.getTopScores()[i] == score){
|
||||
highScoresLabel[i].setColor(Color.RED);
|
||||
}else{
|
||||
highScoresLabel[i].setColor(Color.WHITE);
|
||||
}
|
||||
}
|
||||
for(GUI g : guisPartieTerminer)g.update();
|
||||
}else{
|
||||
p1.setText("Player 1 : " + (int)this.game.scores[0]);
|
||||
|
@ -166,7 +242,14 @@ public class MainInterfaces {
|
|||
}
|
||||
|
||||
public void render(){
|
||||
if(Input.isKey(this.game.helpKey)){
|
||||
boolean joysticksHelp = false;
|
||||
if(Input.getJoysticks().size() > 0){
|
||||
try{
|
||||
ByteBuffer b = Input.getJoysticksButton(0);
|
||||
if(b.get(3) == 1)joysticksHelp = true;
|
||||
}catch(Exception e){}
|
||||
}
|
||||
if(Input.isKey(this.game.HELP_KEY) || joysticksHelp){
|
||||
for(GUI g : guisHelp)g.render();
|
||||
}else if(this.game.scores[0] <= 0 || this.game.scores[1] <= 0){
|
||||
if(this.game.scores[0] <= 0){
|
||||
|
|
|
@ -14,7 +14,7 @@ public class PhysicalEntity {
|
|||
protected float x;
|
||||
protected float y;
|
||||
|
||||
// private float sizeRadius;
|
||||
private float sizeRadius;
|
||||
private float sizeX;
|
||||
private float sizeY;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class PhysicalEntity {
|
|||
this.y = y;
|
||||
this.sizeX = sizeX;
|
||||
this.sizeY = sizeY;
|
||||
// this.sizeRadius = -1;
|
||||
this.sizeRadius = sizeX / 2;
|
||||
this.xVelocity = xVelocity;
|
||||
this.yVelocity = yVelocity;
|
||||
this.frictionFactor = frictionFactor;
|
||||
|
@ -53,6 +53,9 @@ public class PhysicalEntity {
|
|||
}
|
||||
|
||||
public boolean collideWith(PhysicalEntity entity){
|
||||
if(entity == null){
|
||||
return false;
|
||||
}
|
||||
// if(this.sizeRadius == -1 || entity.sizeRadius == -1){
|
||||
return this.collideWithSquareHitBox(entity);
|
||||
/* }
|
||||
|
@ -69,17 +72,20 @@ public class PhysicalEntity {
|
|||
&& this.y + this.sizeY / 2 >= entity.y - entity.sizeY / 2
|
||||
&& this.y - this.sizeY / 2 <= entity.y + entity.sizeY / 2);
|
||||
}
|
||||
/*
|
||||
|
||||
public boolean collideWithRoundHitBox(PhysicalEntity entity){
|
||||
|
||||
float distX = this.x - entity.x;
|
||||
float distY = this.y - entity.y;
|
||||
if(entity == null){
|
||||
return false;
|
||||
}
|
||||
float distX = Math.abs(this.x - entity.x);
|
||||
float distY = Math.abs(this.y - entity.y);
|
||||
|
||||
float dist = (float)Math.sqrt( distX * distX + distY * distY );
|
||||
|
||||
return dist <= this.sizeRadius + entity.sizeRadius;
|
||||
}
|
||||
*/
|
||||
|
||||
public void resolveCollideWith(PhysicalEntity entity){
|
||||
|
||||
if(entity instanceof Mur){
|
||||
|
@ -213,6 +219,20 @@ public class PhysicalEntity {
|
|||
this.sizeY = sizeY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the xVelocity
|
||||
*/
|
||||
public float getxVelocity() {
|
||||
return xVelocity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the yVelocity
|
||||
*/
|
||||
public float getyVelocity() {
|
||||
return yVelocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return this.x + " " + this.y;
|
||||
|
|
14
src/globalgamejam/tiles/CoffreTile.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package globalgamejam.tiles;
|
||||
|
||||
import globalgamejam.math.Vector2f;
|
||||
import globalgamejam.render.Texture;
|
||||
|
||||
public class CoffreTile extends Tile {
|
||||
public CoffreTile(String texturePath, float x, float y){
|
||||
super();
|
||||
super.setTexture(Texture.loadTexture(texturePath));
|
||||
super.setScale(new Vector2f(this.getTexture().width, this.getTexture().height));
|
||||
super.setPosition(new Vector2f(x, y));
|
||||
super.applyTransform();
|
||||
}
|
||||
}
|
27
src/globalgamejam/tiles/EffectTile.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package globalgamejam.tiles;
|
||||
|
||||
import globalgamejam.math.Color4f;
|
||||
import globalgamejam.math.Vector2f;
|
||||
import globalgamejam.render.Texture;
|
||||
|
||||
public class EffectTile extends Tile {
|
||||
|
||||
public EffectTile(String texturePath, float x, float y){
|
||||
super();
|
||||
super.setTexture(Texture.loadTexture(texturePath));
|
||||
super.setColor(new Color4f(1, 1, 1, 0));
|
||||
super.setScale(new Vector2f(this.getTexture().width, this.getTexture().height));
|
||||
super.setPosition(new Vector2f(x, y));
|
||||
super.applyTransform();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexture(String path){
|
||||
super.setTexture(Texture.loadTexture(path));
|
||||
super.setColor(new Color4f(1, 1, 1, 1));
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
super.setColor(new Color4f(1, 1, 1, 0));
|
||||
}
|
||||
}
|
|
@ -86,9 +86,16 @@ public abstract class Tile {
|
|||
}
|
||||
|
||||
public void setTexture(Texture texture) {
|
||||
|
||||
this.texture.destroy();
|
||||
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public void setTexture(String path) {
|
||||
this.setTexture(Texture.loadTexture(path));
|
||||
}
|
||||
|
||||
public Color4f getColor() {
|
||||
return color;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package globalgamejam.world;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import globalgamejam.Main;
|
||||
import globalgamejam.audio.Audio;
|
||||
import globalgamejam.game.Coffre;
|
||||
import globalgamejam.game.EObjetType;
|
||||
import globalgamejam.game.EffectEnum;
|
||||
import globalgamejam.game.MainGame;
|
||||
import globalgamejam.game.Mur;
|
||||
import globalgamejam.game.Objet;
|
||||
|
@ -14,6 +19,8 @@ import globalgamejam.game.Player;
|
|||
import globalgamejam.input.Input;
|
||||
import globalgamejam.math.Mathf;
|
||||
import globalgamejam.math.Vector2f;
|
||||
import globalgamejam.tiles.CoffreTile;
|
||||
import globalgamejam.tiles.EffectTile;
|
||||
import globalgamejam.tiles.Fond;
|
||||
import globalgamejam.tiles.Tile;
|
||||
import globalgamejam.tiles.VaguesTile;
|
||||
|
@ -44,18 +51,38 @@ public class MainWorld {
|
|||
private boolean despawnVagueACalculer = false;
|
||||
|
||||
private int nextVagueHeight;
|
||||
|
||||
private Coffre coffre;
|
||||
private int compteurVague;
|
||||
private boolean vagueCoffre;
|
||||
|
||||
private EffectEnum actualEffect;
|
||||
private EffectTile effectTileJ1;
|
||||
private EffectTile effectTileJ2;
|
||||
private long timeStartEffect;
|
||||
private long durationEffect;
|
||||
private long timeElapsedEffect;
|
||||
|
||||
public MainWorld(MainGame game){
|
||||
this.game = game;
|
||||
init();
|
||||
}
|
||||
|
||||
public void init(){
|
||||
|
||||
try {
|
||||
if(game.audioBackground != null){
|
||||
game.audioBackground.pauseSound();
|
||||
}
|
||||
game.audioBackground = game.audioBennyHill;
|
||||
game.audioBackground.rewindSound();
|
||||
} catch (Exception e) {}
|
||||
|
||||
arrierePlan = new ArrayList<>();
|
||||
objetPlan = new ArrayList<>();
|
||||
premierPlan = new ArrayList<>();
|
||||
listObjet = new ArrayList<>();
|
||||
listMur = new ArrayList<>();
|
||||
init();
|
||||
}
|
||||
|
||||
public void init(){
|
||||
player1 = new Player("res/textures/perso.png", Main.WIDTH/4-20, 150);
|
||||
player2 = new Player("res/textures/perso2.png", Main.WIDTH/4 * 3-20, 150);
|
||||
|
||||
|
@ -84,10 +111,6 @@ public class MainWorld {
|
|||
arrierePlan.add(murHaut.getTile());
|
||||
arrierePlan.add(murBas.getTile());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
listMur.add(mur1);
|
||||
listMur.add(mur2);
|
||||
listMur.add(mur3);
|
||||
|
@ -108,16 +131,43 @@ public class MainWorld {
|
|||
maxVague = 0;
|
||||
maxVagueAtteint = false;
|
||||
despawnVagueACalculer = false;
|
||||
compteurVague=0;
|
||||
vagueCoffre = true;
|
||||
actualEffect = null;
|
||||
|
||||
genererBonusMalus(3);
|
||||
effectTileJ1 = new EffectTile("res/textures/default_transp.png", 100, 583);
|
||||
effectTileJ2 = new EffectTile("res/textures/default_transp.png", 500, 583);
|
||||
premierPlan.add(effectTileJ1);
|
||||
premierPlan.add(effectTileJ2);
|
||||
|
||||
genererBonusMalus(4);
|
||||
|
||||
game.audioBackground.playSound();
|
||||
}
|
||||
|
||||
public void update(){
|
||||
|
||||
if(actualEffect != null){
|
||||
timeElapsedEffect = System.currentTimeMillis() - timeStartEffect;
|
||||
if(timeElapsedEffect >= durationEffect){
|
||||
actualEffect = null;
|
||||
effectTileJ1.clear();
|
||||
effectTileJ2.clear();
|
||||
game.audioEffect.pauseSound();
|
||||
game.audioBackground.setGain(0.4f);
|
||||
}
|
||||
}
|
||||
|
||||
boolean joysticksHelp = false;
|
||||
if(Input.getJoysticks().size() > 0){
|
||||
try{
|
||||
ByteBuffer b = Input.getJoysticksButton(0);
|
||||
if(b.get(3) == 1)joysticksHelp = true;
|
||||
}catch(Exception e){}
|
||||
}
|
||||
this.moveObjets();
|
||||
|
||||
if(!Input.isKey(this.game.helpKey)){
|
||||
if(!Input.isKey(this.game.HELP_KEY) && !joysticksHelp){
|
||||
//Player 1
|
||||
boolean keyBoard1Enable = false;
|
||||
float xDep = 0, yDep = 0;
|
||||
|
@ -127,37 +177,44 @@ public class MainWorld {
|
|||
xDep = bufferAxis.get(0) * player1.getSpeed();
|
||||
yDep = bufferAxis.get(1) * player1.getSpeed();
|
||||
|
||||
if(xDep != 0.0 && yDep != 0.0){
|
||||
/* if(xDep != 0.0 && yDep != 0.0){
|
||||
xDep *= Math.cos(Math.PI / 4);
|
||||
yDep *= Math.cos(Math.PI / 4);
|
||||
}
|
||||
|
||||
player1.move(xDep, yDep);
|
||||
}*/
|
||||
float rot = player1.getSpeed() * -bufferAxis.get(2) / 2.0f;
|
||||
if(actualEffect == EffectEnum.INVERSE_COMMAND_J1){
|
||||
xDep *= -1;
|
||||
yDep *= -1;
|
||||
rot *= -1;
|
||||
}
|
||||
|
||||
if(actualEffect != EffectEnum.HEAVY_J1){
|
||||
player1.move(xDep, yDep);
|
||||
}
|
||||
|
||||
player1.rotate(player1.getSpeed() * -bufferAxis.get(2) / 2.0f);
|
||||
player1.rotate(rot);
|
||||
}catch(Exception e){
|
||||
keyBoard1Enable = true;
|
||||
}
|
||||
}else{
|
||||
keyBoard1Enable = true;
|
||||
}
|
||||
|
||||
if(keyBoard1Enable){
|
||||
if(Input.isKey(GLFW.GLFW_KEY_W)){
|
||||
xDep = player1.getSpeed() * Mathf.cos(Mathf.toRadians(player1.getAngle() + 90));
|
||||
yDep = player1.getSpeed() * Mathf.sin(Mathf.toRadians(player1.getAngle() + 90));
|
||||
// xDep = player1.getSpeed() * Mathf.cos(Mathf.toRadians(player1.getAngle() + 90));
|
||||
// yDep = player1.getSpeed() * Mathf.sin(Mathf.toRadians(player1.getAngle() + 90));
|
||||
yDep = player1.getSpeed() / 2.0f;
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_S)){
|
||||
xDep = player1.getSpeed() * Mathf.cos(Mathf.toRadians(player1.getAngle() - 90));
|
||||
yDep = player1.getSpeed() * Mathf.sin(Mathf.toRadians(player1.getAngle() - 90));
|
||||
// xDep = player1.getSpeed() * Mathf.cos(Mathf.toRadians(player1.getAngle() - 90));
|
||||
// yDep = player1.getSpeed() * Mathf.sin(Mathf.toRadians(player1.getAngle() - 90));
|
||||
yDep = -player1.getSpeed() / 2.0f;
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_A)){
|
||||
xDep = player1.getSpeed() * Mathf.cos(Mathf.toRadians(player1.getAngle() - 180));
|
||||
yDep = player1.getSpeed() * Mathf.sin(Mathf.toRadians(player1.getAngle() - 180));
|
||||
xDep = -player1.getSpeed() / 2.0f;
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_D)){
|
||||
xDep = player1.getSpeed() * Mathf.cos(Mathf.toRadians(player1.getAngle()));
|
||||
yDep = player1.getSpeed() * Mathf.sin(Mathf.toRadians(player1.getAngle()));
|
||||
xDep = player1.getSpeed() / 2.0f;
|
||||
}
|
||||
|
||||
if(xDep != 0.0 && yDep != 0.0){
|
||||
|
@ -165,17 +222,33 @@ public class MainWorld {
|
|||
yDep *= Math.cos(Math.PI / 4);
|
||||
}
|
||||
|
||||
player1.move(xDep, yDep);
|
||||
|
||||
float rot = 0;
|
||||
if(Input.isKey(GLFW.GLFW_KEY_Q)){
|
||||
player1.rotate(player1.getSpeed());
|
||||
rot = player1.getSpeed()/2.0f;
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_E)){
|
||||
player1.rotate(-player1.getSpeed());
|
||||
rot = -player1.getSpeed()/2.0f;
|
||||
}
|
||||
if(actualEffect == EffectEnum.INVERSE_COMMAND_J1){
|
||||
xDep *= -1;
|
||||
yDep *= -1;
|
||||
rot *= -1;
|
||||
}
|
||||
|
||||
if(actualEffect != EffectEnum.HEAVY_J1){
|
||||
player1.move(xDep, yDep);
|
||||
}
|
||||
|
||||
player1.rotate(rot);
|
||||
}
|
||||
|
||||
|
||||
if(player1.collideWithRoundHitBox(coffre)){
|
||||
System.out.println("coffre collide J1");
|
||||
coffre.makeEffect(1);
|
||||
objetPlan.remove(coffre.getTile());
|
||||
coffre = null;
|
||||
}
|
||||
|
||||
//Player 2
|
||||
boolean keyBoard2Enable = false;
|
||||
|
@ -187,14 +260,23 @@ public class MainWorld {
|
|||
xDep = bufferAxis.get(0) * player2.getSpeed();
|
||||
yDep = bufferAxis.get(1) * player2.getSpeed();
|
||||
|
||||
if(xDep != 0.0 && yDep != 0.0){
|
||||
/* if(xDep != 0.0 && yDep != 0.0){
|
||||
xDep *= Math.cos(Math.PI / 4);
|
||||
yDep *= Math.cos(Math.PI / 4);
|
||||
}
|
||||
|
||||
player2.move(xDep, yDep);
|
||||
|
||||
player2.rotate(player2.getSpeed() * -bufferAxis.get(2) / 2.0f);
|
||||
}*/
|
||||
|
||||
float rot = player2.getSpeed() * -bufferAxis.get(2) / 2.0f;
|
||||
if(actualEffect == EffectEnum.INVERSE_COMMAND_J2){
|
||||
xDep *= -1;
|
||||
yDep *= -1;
|
||||
rot *= -1;
|
||||
}
|
||||
|
||||
if(actualEffect != EffectEnum.HEAVY_J2){
|
||||
player2.move(xDep, yDep);
|
||||
}
|
||||
|
||||
player2.rotate(rot);
|
||||
}catch(Exception e){
|
||||
keyBoard2Enable = true;
|
||||
}
|
||||
|
@ -204,20 +286,24 @@ public class MainWorld {
|
|||
|
||||
if(keyBoard2Enable){
|
||||
if(Input.isKey(GLFW.GLFW_KEY_I)){
|
||||
xDep = player2.getSpeed() * Mathf.cos(Mathf.toRadians(player2.getAngle() + 90));
|
||||
yDep = player2.getSpeed() * Mathf.sin(Mathf.toRadians(player2.getAngle() + 90));
|
||||
// xDep = player2.getSpeed() * Mathf.cos(Mathf.toRadians(player2.getAngle() + 90));
|
||||
// yDep = player2.getSpeed() * Mathf.sin(Mathf.toRadians(player2.getAngle() + 90));
|
||||
yDep = player1.getSpeed() / 2.0f;
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_K)){
|
||||
xDep = player2.getSpeed() * Mathf.cos(Mathf.toRadians(player2.getAngle() - 90));
|
||||
yDep = player2.getSpeed() * Mathf.sin(Mathf.toRadians(player2.getAngle() - 90));
|
||||
// xDep = player2.getSpeed() * Mathf.cos(Mathf.toRadians(player2.getAngle() - 90));
|
||||
// yDep = player2.getSpeed() * Mathf.sin(Mathf.toRadians(player2.getAngle() - 90));
|
||||
yDep = -player1.getSpeed() / 2.0f;
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_J)){
|
||||
xDep = player2.getSpeed() * Mathf.cos(Mathf.toRadians(player2.getAngle() - 180));
|
||||
yDep = player2.getSpeed() * Mathf.sin(Mathf.toRadians(player2.getAngle() - 180));
|
||||
// xDep = player2.getSpeed() * Mathf.cos(Mathf.toRadians(player2.getAngle() - 180));
|
||||
// yDep = player2.getSpeed() * Mathf.sin(Mathf.toRadians(player2.getAngle() - 180));
|
||||
xDep = -player1.getSpeed() / 2.0f;
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_L)){
|
||||
xDep = player2.getSpeed() * Mathf.cos(Mathf.toRadians(player2.getAngle()));
|
||||
yDep = player2.getSpeed() * Mathf.sin(Mathf.toRadians(player2.getAngle()));
|
||||
// xDep = player2.getSpeed() * Mathf.cos(Mathf.toRadians(player2.getAngle()));
|
||||
// yDep = player2.getSpeed() * Mathf.sin(Mathf.toRadians(player2.getAngle()));
|
||||
xDep = player1.getSpeed() / 2.0f;
|
||||
}
|
||||
|
||||
if(xDep != 0.0 && yDep != 0.0){
|
||||
|
@ -225,25 +311,59 @@ public class MainWorld {
|
|||
yDep *= Math.cos(Math.PI / 4);
|
||||
}
|
||||
|
||||
|
||||
player2.move(xDep, yDep);
|
||||
|
||||
if(Input.isKey(GLFW.GLFW_KEY_U)){
|
||||
player2.rotate(player2.getSpeed());
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_O)){
|
||||
player2.rotate(-player2.getSpeed());
|
||||
}
|
||||
float rot = 0;
|
||||
if(Input.isKey(GLFW.GLFW_KEY_U)){
|
||||
rot = player2.getSpeed()/2.0f;
|
||||
}
|
||||
if(Input.isKey(GLFW.GLFW_KEY_O)){
|
||||
rot = -player2.getSpeed()/2.0f;
|
||||
}
|
||||
if(actualEffect == EffectEnum.INVERSE_COMMAND_J2){
|
||||
xDep *= -1;
|
||||
yDep *= -1;
|
||||
rot *= -1;
|
||||
}
|
||||
|
||||
if(actualEffect != EffectEnum.HEAVY_J2){
|
||||
player2.move(xDep, yDep);
|
||||
}
|
||||
|
||||
player2.rotate(rot);
|
||||
}
|
||||
|
||||
for(Objet o : this.listObjet){
|
||||
|
||||
if(o.getTile().getPosition().x < Main.WIDTH/2.0f){
|
||||
this.game.scores[0] += o.getType().getPoints() * Main.delta;
|
||||
}else{
|
||||
this.game.scores[1] += o.getType().getPoints() * Main.delta;
|
||||
}
|
||||
}
|
||||
if(player2.collideWithRoundHitBox(coffre)){
|
||||
System.out.println("coffre collide J2");
|
||||
coffre.makeEffect(2);
|
||||
objetPlan.remove(coffre.getTile());
|
||||
coffre = null;
|
||||
}
|
||||
|
||||
if(!Input.isKey(this.game.HELP_KEY) && this.game.scores[0] > 0 && this.game.scores[1] > 0 && MainGame.time_in_sec > 0){
|
||||
if(actualEffect != EffectEnum.SCORE_FREEZE){
|
||||
for(Objet o : this.listObjet){
|
||||
|
||||
float gainScore = o.getType().getPoints() * Main.delta;
|
||||
|
||||
if(o.getTile().getPosition().x < Main.WIDTH/2.0f){
|
||||
|
||||
if(actualEffect == EffectEnum.MUSIC_MULTIPLICATOR_J1){
|
||||
gainScore = (float)Math.max(gainScore, 2.0);
|
||||
gainScore *= 1.5;
|
||||
}
|
||||
|
||||
this.game.scores[0] += gainScore;
|
||||
}else{
|
||||
|
||||
if(actualEffect == EffectEnum.MUSIC_MULTIPLICATOR_J2){
|
||||
gainScore = (float)Math.max(gainScore, 0.0);
|
||||
gainScore *= 1.5;
|
||||
}
|
||||
|
||||
this.game.scores[1] += gainScore;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<Objet> listObjetADespawn = new ArrayList<>();
|
||||
|
||||
|
@ -264,36 +384,29 @@ public class MainWorld {
|
|||
}
|
||||
|
||||
genererBonusMalus((int)(Math.random() * 4) + 2);
|
||||
GenererCoffre();
|
||||
}
|
||||
|
||||
for(Objet o : this.listObjet){
|
||||
|
||||
if(o.underWave(this.vagues.getPosition().y + this.vagues.getTexture().height / 2)){
|
||||
if(o.shouldDespawn()){
|
||||
listObjetADespawn.add(o);
|
||||
if(player1.brosseCollideWith(o)){
|
||||
o.resolveCollideWith(player1.getBrosse());
|
||||
}
|
||||
|
||||
if(player2.brosseCollideWith(o)){
|
||||
o.resolveCollideWith(player2.getBrosse());
|
||||
}
|
||||
|
||||
for(Objet o2 : this.listObjet){
|
||||
if(!o.equals(o2) && o.collideWith(o2)){
|
||||
o.resolveCollideWith(o2);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
if(player1.brosseCollideWith(o)){
|
||||
o.resolveCollideWith(player1.getBrosse());
|
||||
}
|
||||
|
||||
if(player2.brosseCollideWith(o)){
|
||||
o.resolveCollideWith(player2.getBrosse());
|
||||
}
|
||||
|
||||
for(Objet o2 : this.listObjet){
|
||||
if(!o.equals(o2) && o.collideWith(o2)){
|
||||
o.resolveCollideWith(o2);
|
||||
}
|
||||
}
|
||||
|
||||
for(Mur m : this.listMur){
|
||||
if(o.collideWith(m)){
|
||||
o.resolveCollideWith(m);
|
||||
}
|
||||
}
|
||||
for(Mur m : this.listMur){
|
||||
if(o.collideWith(m)){
|
||||
o.resolveCollideWith(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,11 +416,12 @@ public class MainWorld {
|
|||
applyVaguesCoeff((Math.cos(vaguesValue)>0.5)?
|
||||
((float)Math.cos(vaguesValue)-0.5f)*2:0,(int)Main.HEIGHT/8,nextVagueHeight);
|
||||
if(vagues.getPosition().y==-225.0f && etatVague){
|
||||
System.out.println("aaaaaaa");
|
||||
tempsEntreVague = (long) (Math.random() * 5000 + 5000);
|
||||
TempsAncienneVague=System.currentTimeMillis();
|
||||
etatVague =false;
|
||||
nextVagueHeight = (int)(Math.random() * (Main.HEIGHT/4f*3f - 160f) + 160f);
|
||||
compteurVague++;
|
||||
System.out.println(compteurVague);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,8 +429,19 @@ public class MainWorld {
|
|||
}
|
||||
|
||||
public void render(){
|
||||
if(!Input.isKey(this.game.helpKey) && this.game.scores[0] > 0 && this.game.scores[1] > 0 && MainGame.time_in_sec > 0){
|
||||
boolean joysticksHelp = false;
|
||||
if(Input.getJoysticks().size() > 0){
|
||||
try{
|
||||
ByteBuffer b = Input.getJoysticksButton(0);
|
||||
if(b.get(3) == 1)joysticksHelp = true;
|
||||
}catch(Exception e){}
|
||||
}
|
||||
if(!Input.isKey(this.game.HELP_KEY) && this.game.scores[0] > 0 && this.game.scores[1] > 0 && MainGame.time_in_sec > 0 && !joysticksHelp){
|
||||
for(Tile t : arrierePlan)t.render();
|
||||
if(coffre!=null){
|
||||
//System.out.println("dd");
|
||||
coffre.getTile().render();
|
||||
}
|
||||
for(Tile t : objetPlan)t.render();
|
||||
for(Tile t : premierPlan)t.render();
|
||||
}
|
||||
|
@ -325,20 +450,24 @@ public class MainWorld {
|
|||
public void destroy(){
|
||||
for(Tile t : arrierePlan)t.destroy();
|
||||
arrierePlan.clear();
|
||||
|
||||
for(Tile t : objetPlan)t.destroy();
|
||||
objetPlan.clear();
|
||||
for(Tile t : premierPlan)t.destroy();
|
||||
premierPlan.clear();
|
||||
for(Objet t : listObjet)t.getTile().destroy();;
|
||||
listObjet.clear();
|
||||
for(Mur t : listMur)t.getTile().destroy();
|
||||
listMur.clear();
|
||||
|
||||
}
|
||||
|
||||
public void genererBonusMalus(int nombre){
|
||||
int minWidth = 50;
|
||||
int minHeight = Main.WIDTH - minWidth;
|
||||
int minWidth = 80;
|
||||
int maxWidth = Main.WIDTH - minWidth;
|
||||
EObjetType[] types = EObjetType.values();
|
||||
for(int i = 0;i < nombre;i++){
|
||||
EObjetType type = types[(int)(Math.random() * types.length)];
|
||||
Objet o = new Objet(type.getFilename(), (float)(Math.random() * (minHeight - minWidth)), 150, 0, 0, 5, 0.02f);
|
||||
Objet o = new Objet(type.getFilename(), (float)(Math.random() * (maxWidth - minWidth)) + minWidth, 150, 0, 0, 5, 0.02f);
|
||||
o.setType(type);
|
||||
objetPlan.add(o.getTile());
|
||||
listObjet.add(o);
|
||||
|
@ -372,5 +501,110 @@ public class MainWorld {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void inverserObjetGaucheDroite(){
|
||||
for(Objet o : this.listObjet){
|
||||
|
||||
float distMilieu = Main.WIDTH/2.0f - o.getX();
|
||||
|
||||
o.setPosition(Main.WIDTH/2.0f + distMilieu, o.getY());
|
||||
|
||||
o.setVelocity(-o.getxVelocity(), o.getyVelocity());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void GenererCoffre(){
|
||||
|
||||
if(coffre != null){
|
||||
objetPlan.remove(coffre.getTile());
|
||||
coffre = null;
|
||||
}
|
||||
|
||||
final float ChancePop = 0.6f;
|
||||
int minHeight = 150;
|
||||
int maxHeight = Main.HEIGHT - 50;
|
||||
int minWidth = 80;
|
||||
int maxWidth = Main.HEIGHT - minWidth;
|
||||
if(!vagueCoffre){
|
||||
vagueCoffre=true;
|
||||
}
|
||||
else{
|
||||
if(Math.random()>=1-ChancePop&& compteurVague>=4){
|
||||
System.out.println("dfjkl");
|
||||
vagueCoffre = false;
|
||||
coffre = new Coffre("res/textures/coffre.png",(float) (Math.random() *(maxWidth-minWidth) + minWidth),(float) (Math.random() *(maxHeight-minHeight) + minHeight)){
|
||||
|
||||
@Override
|
||||
public void makeEffect(int numPlayerHitCoffre){
|
||||
effectTileJ1.clear();
|
||||
effectTileJ2.clear();
|
||||
|
||||
double effectRand = Math.random();
|
||||
|
||||
if(effectRand < 0.2){
|
||||
// effet 1 avec 20% de chance
|
||||
actualEffect = EffectEnum.INVERSE_SCREEN;
|
||||
inverserObjetGaucheDroite();
|
||||
}
|
||||
else if(effectRand < 0.4){
|
||||
// effet 2 avec 20% de chance
|
||||
if(numPlayerHitCoffre == 1){
|
||||
actualEffect = EffectEnum.MUSIC_MULTIPLICATOR_J1;
|
||||
effectTileJ1.setTexture("res/textures/noteMusic.png");
|
||||
}
|
||||
else{
|
||||
actualEffect = EffectEnum.MUSIC_MULTIPLICATOR_J2;
|
||||
effectTileJ2.setTexture("res/textures/noteMusic.png");
|
||||
}
|
||||
if(game.audioEffect != null){
|
||||
game.audioEffect.pauseSound();
|
||||
game.audioEffect.rewindSound();
|
||||
}
|
||||
try{
|
||||
game.audioBackground.setGain(0.1f);
|
||||
game.audioEffect = game.audioMacarena;
|
||||
game.audioEffect.playSound();
|
||||
} catch(Exception e){}
|
||||
}
|
||||
else if(effectRand < 0.6){
|
||||
// effet 3 avec 20% de chance
|
||||
if(numPlayerHitCoffre == 1){
|
||||
actualEffect = EffectEnum.INVERSE_COMMAND_J2;
|
||||
effectTileJ2.setTexture("res/textures/inverser.png");
|
||||
}
|
||||
else{
|
||||
actualEffect = EffectEnum.INVERSE_COMMAND_J1;
|
||||
effectTileJ1.setTexture("res/textures/inverser.png");
|
||||
}
|
||||
}
|
||||
else if(effectRand < 0.8){
|
||||
// effet 4 avec 20% de chance
|
||||
actualEffect = EffectEnum.SCORE_FREEZE;
|
||||
effectTileJ1.setTexture("res/textures/gel.png");
|
||||
effectTileJ2.setTexture("res/textures/gel.png");
|
||||
|
||||
}
|
||||
else{
|
||||
// effet 5 avec 20% de chance
|
||||
if(numPlayerHitCoffre == 1){
|
||||
actualEffect = EffectEnum.HEAVY_J2;
|
||||
effectTileJ2.setTexture("res/textures/stop.png");
|
||||
}
|
||||
else{
|
||||
actualEffect = EffectEnum.HEAVY_J1;
|
||||
effectTileJ1.setTexture("res/textures/stop.png");
|
||||
}
|
||||
}
|
||||
|
||||
durationEffect = 7_000; // ms
|
||||
timeStartEffect = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|