commit c88e14769fe7264ffa1f0705ce126670a8026340 Author: Victor Giers Date: Tue Aug 23 15:29:30 2022 +0200 initial commit diff --git a/data/.DS_Store b/data/.DS_Store new file mode 100644 index 0000000..2c3ef2c Binary files /dev/null and b/data/.DS_Store differ diff --git a/data/WIRELESS b/data/WIRELESS new file mode 100644 index 0000000..2a8797a --- /dev/null +++ b/data/WIRELESS @@ -0,0 +1,19 @@ +GENERAL WIRELESS GAMEPAD CONTROLS +LSTICK_X LEFT STICK RIGHT-LEFT 3 SLIDER x 0 1.0 0.0 +LSTICK_Y LEFT STICK UP-DOWN 3 SLIDER y 0 1.0 0.0 +RSTICK_X RIGHT STICK RIGHT-LEFT 3 SLIDER z 0 1.0 0.0 +RSTICK_Y RIGHT STICK UP-DOWN 3 SLIDER rz 0 1.0 0.0 +L1 LEFT SHOULDER 1 1 BUTTON 4 0 0.0 0.0 +L2 LEFT SHOULDER 2 1 BUTTON 6 0 0.0 0.0 +L3 LEFT STICK BUTTON 1 BUTTON 10 0 0.0 0.0 +R1 RIGHT SHOULDER 1 1 BUTTON 5 0 0.0 0.0 +R2 RIGHT SHOULDER 2 1 BUTTON 7 0 0.0 0.0 +R3 RIGHT STICK BUTTON 1 BUTTON 11 0 0.0 0.0 +DPAD DPAD 2 HAT cooliehat: pov 0 1.0 0.0 +SELECT SELECT 1 BUTTON 8 0 0.0 0.0 +START START 1 BUTTON 9 0 0.0 0.0 +A A 1 BUTTON 2 0 0.0 0.0 +B B 1 BUTTON 1 0 0.0 0.0 +X X 1 BUTTON 3 0 0.0 0.0 +Y Y 1 BUTTON 0 0 0.0 0.0 +XBOX XBOX BUTTON 1 BUTTON 12 0 0.0 0.0 diff --git a/data/XBOX b/data/XBOX new file mode 100644 index 0000000..39524c3 --- /dev/null +++ b/data/XBOX @@ -0,0 +1,21 @@ +GENERAL XBOX CONTROLLER +LSTICK_X LEFT STICK LEFT / RIGHT 3 SLIDER x 0 1.0 0.0 +LSTICK_Y LEFT STICK UP / DOWN 3 SLIDER y 0 1.0 0.0 +RSTICK_X RIGHT STICK LEFT / RIGHT 3 SLIDER rx 0 1.0 0.0 +RSTICK_Y RIGHT STICK UP / DOWN 3 SLIDER ry 0 1.0 0.0 +L3 LEFT STICK PRESS 1 BUTTON 6 0 0.0 0.0 +R3 RIGHT STICK PRESS 1 BUTTON 7 0 0.0 0.0 +L1 FIRST LEFT SHOULDER 1 BUTTON 4 0 0.0 0.0 +L2 SECOND LEFT SHOULDER 3 SLIDER z 0 1.0 0.0 +R2 SECOND RIGHT SHOULDER 3 SLIDER rz 0 1.0 0.0 +SELECT SELECT 1 BUTTON 9 0 0.0 0.0 +START START 1 BUTTON 8 0 0.0 0.0 +DPAD_UP DPAD UP 1 BUTTON 11 0 0.0 0.0 +DPAD_DOWN DPAD DOWN 1 BUTTON 12 0 0.0 0.0 +DPAD_LEFT DPAD LEFT 1 BUTTON 13 0 0.0 0.0 +DPAD_RIGHT DPAD RIGHT 1 BUTTON 14 0 0.0 0.0 +A A / CONFIRM 1 BUTTON 0 0 0.0 0.0 +B B / CANCEL 1 BUTTON 1 0 0.0 0.0 +X X 1 BUTTON 2 0 0.0 0.0 +Y Y 1 BUTTON 3 0 0.0 0.0 +XBOX MIDDLE BUTTON 1 BUTTON 10 0 0.0 0.0 diff --git a/data/saves/.DS_Store b/data/saves/.DS_Store new file mode 100644 index 0000000..f86711e Binary files /dev/null and b/data/saves/.DS_Store differ diff --git a/data/saves/giers.sav b/data/saves/giers.sav new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/data/saves/giers.sav differ diff --git a/entities.pde b/entities.pde new file mode 100644 index 0000000..c4ddc46 --- /dev/null +++ b/entities.pde @@ -0,0 +1,23 @@ +class Entity{ + PVector position; + PVector direction; + float velocity; + Hitbox touchbox; //multiple required + PGraphics graphic; +} + +class Hitbox{ + +} + +class Character extends Entity{ + +} + +class PlayerCharacter extends Character{ + +} + +class NonPlayerCharacter extends Character{ + +} diff --git a/gamepad_input.pde b/gamepad_input.pde new file mode 100644 index 0000000..d17d988 --- /dev/null +++ b/gamepad_input.pde @@ -0,0 +1,178 @@ +public static int L1 = 0; +public static int L2 = 1; +public static int L3 = 2; +public static int R1 = 3; +public static int R2 = 4; +public static int R3 = 5; +public static int SELECT = 6; +public static int START = 7; +public static int A = 8; +public static int B = 9; +public static int X = 10; +public static int Y = 11; +public static int XBOX = 12; +public static int DPAD_UP = 13; +public static int DPAD_DOWN = 14; +public static int DPAD_LEFT = 15; +public static int DPAD_RIGHT = 16; + + + +import org.gamecontrolplus.gui.*; +import org.gamecontrolplus.*; +import net.java.games.input.*; + +ControlIO controlIO; +Configuration gpad_config; +ControlDevice gpad; + +boolean gamePadAvailable = false; +boolean[] gpadButtonPresses = new boolean[17]; +boolean[] dpadButtons = new boolean[4]; +String[] buttonNames = {"L1", "L2", "L3", "R1", "R2", "R3", "SELECT", "START", "A", "B", "X", "Y", "XBOX", "DPAD_UP", "DPAD_DOWN", "DPAD_LEFT", "DPAD_RIGHT"}; + +PVector LSTICK, RSTICK; + + +void initGamepad() { + controlIO = ControlIO.getInstance(this); + //gpad = controlIO.filter(GCP.GAMEPAD).getMatchedDevice("WIRELESS"); + if (gpad == null) { + println("No suitable device configured"); + } else { + gamePadAvailable = true; + } + LSTICK = new PVector(0, 0); + RSTICK = new PVector(0, 0); +} + +public void getUserInput() { + if (gamePadAvailable) { + dpadButtons[0] = gpad.getHat("DPAD").up(); + dpadButtons[1] = gpad.getHat("DPAD").down(); + dpadButtons[2] = gpad.getHat("DPAD").left(); + dpadButtons[3] = gpad.getHat("DPAD").right(); + for (int i = 0; i < 17; i++) { + boolean thisButton = (i < 13) ? gpad.getButton(buttonNames[i]).pressed() : dpadButtons[i-13]; + if (gpadButtonPresses[i] != thisButton) { + if (gpadButtonPresses[i]) buttonReleased(i); + else buttonPressed(i); + } + gpadButtonPresses[i] = thisButton; + } + LSTICK.set(roundFloat(gpad.getSlider("LSTICK_X").getValue(), 2), roundFloat(gpad.getSlider("LSTICK_Y").getValue(), 2)); + RSTICK.set(roundFloat(gpad.getSlider("RSTICK_X").getValue(), 2), roundFloat(gpad.getSlider("RSTICK_Y").getValue(), 2)); + } +} + + +void buttonPressed(int btn) { + println("Pressed " + buttonNames[btn]); +} +void buttonReleased(int btn) { + println("Released " + buttonNames[btn]); +} + + +void keyPressed() { + switch(key) { + case('w'): + LSTICK.y = 1.0; + break; + case('a'): + LSTICK.x = -1.0; + break; + case('s'): + LSTICK.y = -1.0; + break; + case('d'): + LSTICK.x = 1.0; + break; + case('Q'): + buttonPressed(0); + break; + case('E'): + buttonPressed(0); + break; + case(' '): + buttonPressed(0); + break; + case(RETURN): + buttonPressed(0); + break; + case(SHIFT): + buttonPressed(0); + break; + case(CONTROL): + buttonPressed(0); + break; + case(ALT): + buttonPressed(0); + break; + case(UP): + buttonPressed(0); + break; + case(DOWN): + buttonPressed(0); + break; + case(LEFT): + buttonPressed(0); + break; + case(RIGHT): + buttonPressed(0); + break; + default: + break; + } +} +void keyReleased() { + switch(key) { + case('w'): + LSTICK.y = 0; + break; + case('a'): + LSTICK.x = 0; + break; + case('s'): + LSTICK.y = 0; + break; + case('d'): + LSTICK.x = 0; + break; + case('Q'): + buttonPressed(0); + break; + case('E'): + buttonPressed(0); + break; + case(' '): + buttonPressed(0); + break; + case(RETURN): + buttonPressed(0); + break; + case(SHIFT): + buttonPressed(0); + break; + case(CONTROL): + buttonPressed(0); + break; + case(ALT): + buttonPressed(0); + break; + case(UP): + buttonPressed(0); + break; + case(DOWN): + buttonPressed(0); + break; + case(LEFT): + buttonPressed(0); + break; + case(RIGHT): + buttonPressed(0); + break; + default: + break; + } +} diff --git a/geemudesu.pde b/geemudesu.pde new file mode 100644 index 0000000..0bf7b7a --- /dev/null +++ b/geemudesu.pde @@ -0,0 +1,28 @@ +String gameID = "giers"; + +public void setup() { + size(400, 240); + initGamepad(); + saveStates(gameID); + loadSave(gameID); +} + +float ellipsex, ellipsey; + +public void draw() { + getUserInput(); + background(255); + ellipsex+=LSTICK.x; + ellipsey-=LSTICK.y; + circle(width/2+ellipsex,height/2+ellipsey,10); +} + + +void loadSave(String gid){ + byte[] savedStates = loadBytes(dataPath("") + "/saves/" + gid + ".sav"); +} + +void saveStates(String gid){ + byte[] savebytes = new byte[1]; + saveBytes(dataPath("") + "/saves/" + gid + ".sav", savebytes); +} diff --git a/helper_functions.pde b/helper_functions.pde new file mode 100644 index 0000000..6d7ad55 --- /dev/null +++ b/helper_functions.pde @@ -0,0 +1,7 @@ +public float roundFloat(float f, int decimals) { + int pow = 10; + for (int i = 1; i < decimals; i++) + pow *= 10; + float tmp = f * pow; + return ( (float) ( (int) ((tmp - (int) tmp) >= 0.5f ? tmp + 1 : tmp) ) ) / pow; +} diff --git a/menu.pde b/menu.pde new file mode 100644 index 0000000..e69de29 diff --git a/ui.pde b/ui.pde new file mode 100644 index 0000000..e69de29