initial commit

This commit is contained in:
2022-08-23 15:29:30 +02:00
commit c88e14769f
11 changed files with 276 additions and 0 deletions

BIN
data/.DS_Store vendored Normal file

Binary file not shown.

19
data/WIRELESS Normal file
View File

@@ -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

21
data/XBOX Normal file
View File

@@ -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

BIN
data/saves/.DS_Store vendored Normal file

Binary file not shown.

BIN
data/saves/giers.sav Normal file

Binary file not shown.

23
entities.pde Normal file
View File

@@ -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{
}

178
gamepad_input.pde Normal file
View File

@@ -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;
}
}

28
geemudesu.pde Normal file
View File

@@ -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);
}

7
helper_functions.pde Normal file
View File

@@ -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;
}

0
menu.pde Normal file
View File

0
ui.pde Normal file
View File