Updates
This commit is contained in:
parent
8e8088fddf
commit
6b0cf7729e
6 changed files with 1517 additions and 0 deletions
42
global game jam/src/IO/IOFile.java
Normal file
42
global game jam/src/IO/IOFile.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package IO;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import Tools.*;
|
||||
|
||||
public class IOFile {
|
||||
|
||||
public static String getStringByFile(String url){
|
||||
String fileData = "";
|
||||
try {
|
||||
BufferedInputStream ois = new BufferedInputStream(new FileInputStream(new File(url)));
|
||||
Scanner fEntree = new Scanner(ois);
|
||||
String line, tab[];
|
||||
|
||||
while(fEntree.hasNext()){
|
||||
line = fEntree.nextLine();
|
||||
fileData += line + " ";
|
||||
}
|
||||
fEntree.close();
|
||||
ois.close();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return fileData;
|
||||
}
|
||||
|
||||
public static void saveFileByString(String data,String url){
|
||||
try {
|
||||
BufferedOutputStream oos = new BufferedOutputStream(new FileOutputStream(new File(url)));
|
||||
oos.write(data.getBytes());
|
||||
oos.flush();
|
||||
oos.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
84
global game jam/src/Input/EcranListeners.java
Normal file
84
global game jam/src/Input/EcranListeners.java
Normal file
|
@ -0,0 +1,84 @@
|
|||
package Input;
|
||||
/*
|
||||
* Cette classe sert a récupérer les actions de la souris et a déclancher le timer qui lui correspond.
|
||||
* Ce timer est ensuite utilisé dans la classe Jeu de la meme manière qu'un " public void mouseClicked(MouseEvent e) "
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import acm.util.SwingTimer;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class EcranListeners extends JPanel implements MouseListener, MouseMotionListener{
|
||||
public int posiSourisX, posiSourisY, noBouton;
|
||||
public SwingTimer sourisClicked = new SwingTimer(0, null), sourisEntered = new SwingTimer(0, null), sourisExited = new SwingTimer(0, null), sourisPressed = new SwingTimer(0, null), sourisReleased = new SwingTimer(0, null), sourisDragged = new SwingTimer(0, null), sourisMoved = new SwingTimer(0, null);
|
||||
|
||||
public EcranListeners(Dimension dm){
|
||||
this.addMouseListener(this);
|
||||
this.addMouseMotionListener(this);
|
||||
this.setSize(dm);
|
||||
this.setOpaque(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
posiSourisX = e.getX();
|
||||
posiSourisY = e.getY();
|
||||
noBouton = e.getButton();
|
||||
sourisClicked.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
posiSourisX = e.getX();
|
||||
posiSourisY = e.getY();
|
||||
noBouton = e.getButton();
|
||||
sourisEntered.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
posiSourisX = e.getX();
|
||||
posiSourisY = e.getY();
|
||||
noBouton = e.getButton();
|
||||
sourisExited.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
posiSourisX = e.getX();
|
||||
posiSourisY = e.getY();
|
||||
noBouton = e.getButton();
|
||||
sourisPressed.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
posiSourisX = e.getX();
|
||||
posiSourisY = e.getY();
|
||||
noBouton = e.getButton();
|
||||
sourisReleased.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
posiSourisX = e.getX();
|
||||
posiSourisY = e.getY();
|
||||
noBouton = e.getModifiers();
|
||||
sourisDragged.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
posiSourisX = e.getX();
|
||||
posiSourisY = e.getY();
|
||||
sourisMoved.start();
|
||||
}
|
||||
|
||||
}
|
104
global game jam/src/Input/Joystick.java
Normal file
104
global game jam/src/Input/Joystick.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package Input;
|
||||
|
||||
import World.*;
|
||||
import net.java.games.input.*;
|
||||
import net.java.games.input.Component.*;
|
||||
import net.java.games.util.Version;
|
||||
|
||||
public class Joystick {
|
||||
|
||||
public static Controller con;
|
||||
public static float previousValueOfA = 0,previousValueOfX = 0,previousValueOfB = 0;
|
||||
public static float x = 0;
|
||||
public static float y = 0;
|
||||
|
||||
public static void init(){
|
||||
System.out.println("JInput version: " + Version.getVersion());
|
||||
Controller[] cs = ControllerEnvironment.getDefaultEnvironment().getControllers();
|
||||
for(Controller c : cs){
|
||||
if(c.getType() == Controller.Type.GAMEPAD){
|
||||
System.out.println(c.getType());
|
||||
con = c;
|
||||
break;
|
||||
}else{
|
||||
con = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void update(){
|
||||
if(con != null){
|
||||
for(Component c : con.getComponents()){
|
||||
Identifier componentIdentifier = c.getIdentifier();
|
||||
con.poll();
|
||||
if(c.isAnalog()){
|
||||
float a = c.getPollData();
|
||||
if(componentIdentifier == Component.Identifier.Axis.X){
|
||||
x = c.getPollData();
|
||||
x = (Math.sqrt(x*x) > 0.03)?(x*0.33f):0;
|
||||
}
|
||||
if(componentIdentifier == Component.Identifier.Axis.Y){
|
||||
y = c.getPollData();
|
||||
y = (Math.sqrt(y*y) > 0.03)?(y*0.33f):0;
|
||||
}
|
||||
}
|
||||
if(componentIdentifier == Component.Identifier.Button.A || componentIdentifier == Component.Identifier.Button._0){
|
||||
if(Jeu.Jeu.jeu.dialogPhase && c.getPollData() == 1.0f && c.getPollData() != previousValueOfA){
|
||||
previousValueOfA = 1.0f;
|
||||
Jeu.Jeu.jeu.nextDialogueReplique();
|
||||
}
|
||||
if(c.getPollData() != 1.0f && previousValueOfA == 1.0f){
|
||||
previousValueOfA = 0.0f;
|
||||
}
|
||||
}
|
||||
if(componentIdentifier == Component.Identifier.Button.B || componentIdentifier == Component.Identifier.Button._2){
|
||||
if(c.getPollData() == 1.0f && c.getPollData() != previousValueOfB){
|
||||
previousValueOfB = 1.0f;
|
||||
if(!Jeu.Jeu.jeu.dialogPhase && World.getUltiList().size() > 0){
|
||||
switch(World.getUltiList().size()){
|
||||
case 4:
|
||||
World.getUltiList().get(0).sacrifice();
|
||||
break;
|
||||
case 3:
|
||||
World.getUltiList().get(2).sacrifice();
|
||||
break;
|
||||
default:
|
||||
World.getUltiList().get(0).sacrifice();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(c.getPollData() != 1.0f && previousValueOfB == 1.0f){
|
||||
previousValueOfB = 0.0f;
|
||||
}
|
||||
}
|
||||
if(componentIdentifier == Component.Identifier.Button.X || componentIdentifier == Component.Identifier.Button._1){
|
||||
if(!Jeu.Jeu.jeu.dialogPhase && c.getPollData() == 1.0f && c.getPollData() != previousValueOfX){
|
||||
previousValueOfX = 1.0f;
|
||||
if(Jeu.Jeu.jeu.player.getNbRepAnimSpell() == 0 && Jeu.Jeu.jeu.player.getSpellLevel() >= 1 && !Jeu.Jeu.jeu.dialogPhase){
|
||||
Jeu.Jeu.jeu.player.setSpellLevel(Jeu.Jeu.jeu.player.getSpellLevel() -1);
|
||||
Jeu.Jeu.jeu.player.setXCenterSpell(Jeu.Jeu.jeu.player.getX() + (Jeu.Jeu.jeu.player.getImage().getWidth() / 2) / Jeu.Jeu.jeu.resolution.getWidth());
|
||||
Jeu.Jeu.jeu.player.setYCenterSpell(Jeu.Jeu.jeu.player.getY() + (Jeu.Jeu.jeu.player.getImage().getHeight() / 2) / Jeu.Jeu.jeu.resolution.getHeight());
|
||||
Jeu.Jeu.jeu.player.getTimerAnimSpell().start();
|
||||
Jeu.Jeu.jeu.player.getImageSpell().setSize((Jeu.Jeu.jeu.player.getWidthSpell() * (double)Jeu.Jeu.jeu.player.getNbRepAnimSpell()) / 5.0, (Jeu.Jeu.jeu.player.getHeightSpell() * (double)Jeu.Jeu.jeu.player.getNbRepAnimSpell()) / 5.0);
|
||||
Jeu.Jeu.jeu.player.getImageSpell().setLocation(Jeu.Jeu.jeu.resolution.getWidth() * Jeu.Jeu.jeu.player.getXCenterSpell() - Jeu.Jeu.jeu.player.getImageSpell().getHeight() / 2.0,
|
||||
Jeu.Jeu.jeu.resolution.getHeight() * Jeu.Jeu.jeu.player.getYCenterSpell() - Jeu.Jeu.jeu.player.getImageSpell().getWidth() / 2.0);
|
||||
Jeu.Jeu.jeu.gc.add(Jeu.Jeu.jeu.player.getImageSpell());
|
||||
}
|
||||
}
|
||||
if(c.getPollData() != 1.0f && previousValueOfX == 1.0f){
|
||||
previousValueOfX = 0.0f;
|
||||
}
|
||||
}
|
||||
if(componentIdentifier == Component.Identifier.Button.LEFT_THUMB || componentIdentifier == Component.Identifier.Button._4){
|
||||
if(!Jeu.Jeu.jeu.dialogPhase && c.getPollData() == 1.0f){
|
||||
Jeu.Jeu.jeu.keyShift = true;
|
||||
}else{
|
||||
Jeu.Jeu.jeu.keyShift = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
56
global game jam/src/Input/KeyCode.java
Normal file
56
global game jam/src/Input/KeyCode.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package Input;
|
||||
|
||||
public class KeyCode {
|
||||
|
||||
public final static int
|
||||
KEY_A = 65,
|
||||
KEY_B = 66,
|
||||
KEY_C = 67,
|
||||
KEY_D = 68,
|
||||
KEY_E = 69,
|
||||
KEY_F = 70,
|
||||
KEY_G = 71,
|
||||
KEY_H = 72,
|
||||
KEY_I = 73,
|
||||
KEY_J = 74,
|
||||
KEY_K = 75,
|
||||
KEY_L = 76,
|
||||
KEY_M = 77,
|
||||
KEY_N = 78,
|
||||
KEY_O = 79,
|
||||
KEY_P = 80,
|
||||
KEY_Q = 81,
|
||||
KEY_R = 82,
|
||||
KEY_S = 83,
|
||||
KEY_T = 84,
|
||||
KEY_U = 85,
|
||||
KEY_V = 86,
|
||||
KEY_W = 87,
|
||||
KEY_X = 88,
|
||||
KEY_Y = 89,
|
||||
KEY_Z = 90,
|
||||
|
||||
KEY_LEFT = 37,
|
||||
KEY_UP = 38,
|
||||
KEY_RIGHT = 39,
|
||||
KEY_DOWN = 40,
|
||||
|
||||
KEY_ESCAPE = 27,
|
||||
KEY_SPACE = 32,
|
||||
KEY_SHIFT = 16,
|
||||
KEY_ENTER = 10,
|
||||
|
||||
KEY_0 = 48,
|
||||
KEY_1 = 49,
|
||||
KEY_2 = 50,
|
||||
KEY_3 = 51,
|
||||
KEY_4 = 52,
|
||||
KEY_5 = 53,
|
||||
KEY_6 = 54,
|
||||
KEY_7 = 55,
|
||||
KEY_8 = 56,
|
||||
KEY_9 = 57,
|
||||
|
||||
KEY_F2 = 113;
|
||||
|
||||
}
|
1220
global game jam/src/Jeu/Jeu.java
Normal file
1220
global game jam/src/Jeu/Jeu.java
Normal file
File diff suppressed because it is too large
Load diff
11
global game jam/src/Tools/CoordD.java
Normal file
11
global game jam/src/Tools/CoordD.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package Tools;
|
||||
|
||||
public class CoordD {
|
||||
|
||||
public double x, y;
|
||||
|
||||
public CoordD(double x, double y){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
Reference in a new issue