Ä und RIGHT haben den selben keyCode in Processing. Scheint ein bug zu sein. (Man kann auch mit den Pfeiltasten navigieren)
So funktioniert das Adden von chars:
if (key != BACKSPACE && key != DELETE && key != ENTER && key != TAB && key != SHIFT && key != ' ' && key != ',' && key != '.' && keyCode != RIGHT && keyCode != LEFT && keyCode != UP && keyCode != DOWN || key == 'ä' || key == 'Ä') {
t.dataList.set((i * 8 + j), Data + key);
}
Und so wechselt man das ausgewählte Feld:
if (keyCode == TAB && t.dataList.size() > 0) {
t.field[1]++;
}
Whoops, hab einen gefunden: http://www.uploadedit.com
Wirkt zwar nicht sehr professionell, aber zum Dinge ausprobieren reicht es ;)
Der Livestream darf nicht auf privat gestellt sein.
car = spieler, tree = object, habe aber keine Librarys oder so importiert, nur halt die für images
@Flummy1337 Ich hab mir schon gedacht, dass so was kommen wird XD Wir empfiehlst du mir denn die Variabeln leserlich zu machen? In einem Array zusammenfassen?
Der ganze Code(zum Starten vom Spiel Enter drücken; wichtiger Teil unten):
int kart_x;
int kart_y;
int kart_wide;
int kart_length;
int lane1;
int lane2;
int lane3;
int lane4;
int random_int[];
int spawn_chance;
int score;
int food_x;
int food_y;
float lanes[];
float spawn_time;
float object_y;
float random[];
float object_x[];
float randomFood;
boolean pressed;
boolean running;
void setup(){
size(1000, 800);
spawn_time = 0;
kart_x = 125;
kart_y = 600;
kart_wide = 100;
kart_length = 140;
lane1 = 125;
lane2 = 375;
lane3 = 625;
lane4 = 875;
object_y = -125;
food_x = 1;
food_y = -100;
pressed = false;
running = false;
lanes = new float[]{lane1, lane2, lane3, lane4};
random = new float[5];
random_int = new int[3];
object_x = new float[3];
}
void draw(){
background(0);
rectMode(CENTER);
// Kart wird gezeichnet
rect(kart_x - 50, kart_y - 70, kart_wide, kart_length);
// food wird gezeichnet
fill(255, 255, 255);
ellipse(food_x,food_y, 100, 100);
// Start text
// spawn_time wird berechnet
spawnTime();
// Start text wird gezeigt
if(running == false){
}
//Score wird gezählt
if(running == true && spawn_time >= 1){
score = score + 1;
}
// Spiel wird gestartet
if(keyPressed && key == ENTER){
running = true;
spawn_time = 0;
}
// lane berechnen, objekte zeichnen
if(spawn_time <= 1){
object();
spawnObject2();
spawnObject3();
food();
}
// Objekte werden zurückgesetzt sobald off screen
if(spawn_time >= 1){
object_y = -125;
spawn_time = 0;
object_x[0] = 0;
object_x[1] = 0;
object_x[2] = 0;
spawnCheck();
food_y = -100;
food_x = 1;
}
// Tod bei Kollison
if(kart_y - 70 <= object_y + 50 && kart_y - 70 >= object_y - 50){
if(kart_x == object_x[0]){
death();
}
if(kart_x == object_x[1]){
death();
}
if(kart_x == object_x[2]){
death();
}
}
// Objekte bewegen sich, kart bewegt sich
if(running == true){
object_y = object_y + 16;
food_y = food_y + 16;
if(pressed == false){
if(keyPressed == true && keyCode == RIGHT){
if(kart_x != lane4){
kart_x = kart_x + 250;
pressed = true;
}
}
if(keyPressed == true && keyCode == LEFT){
if(kart_x != lane1){
kart_x = kart_x - 250;
pressed = true;
}
}
}
}
}
//
void keyReleased(){
pressed = false;
}
// spawn_time wird berechnet
void spawnTime(){
spawn_time = spawn_time + 1/frameRate;
}
// Spieler stirbt
void death(){
spawn_time = 0;
object_y = -125;
object_x[0] = 0;
object_x[1] = 0;
kart_x = lane1;
score = 0;
food_x = 1;
food_y = -100;
running = false;
}
//Erstes Objekt wird berechnet/gezeichnet
void object(){
random[0] = random(0, 3);
random_int[0] = int(random[0]);
rect(object_x[0] -70, object_y -70, 150, 150);
if(object_x[0] == 0){
object_x[0] = lanes[random_int[0]];
}
}
//Zweites Objekt wird berechnet/gezeichnet
void spawnObject2(){
random[1] = random(0, 3);
random[1] = round(random[1]);
random_int[1] = int(random[1]);
if(spawn_chance == 1){
rect(object_x[1] - 70, object_y - 70, 150, 150);
if(object_x[1] == 0){
object_x[1] = lanes[random_int[1]];
}
}
}
//Drittes Objekt wird berechnet/gezeichnet
void spawnObject3(){
random[2] = random(0,3);
random[2] = round(random[2]);
random_int[2] = int(random[2]);
if(spawn_chance == 1){
rect(object_x[2] - 70, object_y - 70, 150, 150);
if(object_x[2] == 0){
object_x[2] = lanes[random_int[2]];
}
}
}
// Berechnung ob Objekt 2/3 spawnen darf
void spawnCheck(){
float r = random(0, 1);
r = round(r);
spawn_chance = int(r);
}
// Essen wird berechnet/gezeichnet
void food(){
while(food_x == 1){
float i = random(0, 4);
randomFood = i;
println(randomFood);
if(randomFood >= 0 || randomFood < 1){
if(object_x[0] != lane1 && object_x[1] != lane1 && object_x[2] != lane1){
food_x = lane1;
}
}
if(randomFood >= 1 && randomFood < 2){
if(object_x[0] != lane2 && object_x[1] != lane2 && object_x[2] != lane2){
food_x = lane2;
}
}
if(randomFood >= 2 || randomFood < 3){
if(object_x[0] != lane3 && object_x[1] != lane3 && object_x[2] != lane3){
food_x = lane3;
}
}
if(randomFood >= 3 || randomFood <= 4){
if(object_x[0] != lane4 && object_x[1] != lane4 && object_x[2] != lane4){
food_x = lane4;
}
}
}
}
void food(){
while(food_x == 1){
float i = random(0, 4);
randomFood = i;
println(randomFood);
if(randomFood >= 0 || randomFood < 1){
if(object_x[0] != lane1 && object_x[1] != lane1 && object_x[2] != lane1){
food_x = lane1;
}
}
if(randomFood >= 1 && randomFood < 2){
if(object_x[0] != lane2 && object_x[1] != lane2 && object_x[2] != lane2){
food_x = lane2;
}
}
if(randomFood >= 2 || randomFood < 3){
if(object_x[0] != lane3 && object_x[1] != lane3 && object_x[2] != lane3){
food_x = lane3;
}
}
if(randomFood >= 3 || randomFood <= 4){
if(object_x[0] != lane4 && object_x[1] != lane4 && object_x[2] != lane4){
food_x = lane4;
}
}
}
}
@priesterin Das war nur ein Beispiel :P Aber danke, mache ich so
Der Code:
if(pause == false){
if(touchIsStarted){
if(mouseX >=980 && mouseY <= 100){
int time1 = millis();
int time2 = millis();
ability1 = true;
track_ball_speed_y = ball_speed_y;
ball_speed_y = ball_speed_y * 0.9;
ball_speed_x = ball_speed_x * 0.9;
}
}
}
if(time1 >= time1 + 5000){
ability1 = false;
ball_speed_y = track_ball_speed_y;
}
Die Variablen:
int time1;
int time2;
int score;
float player_x;
float player_y;
float ball_x;
float ball_y;
float ball_speed_x;
float ball_speed_y;
float track_ball_speed_y;
PImage start;
PImage pause_image;
PImage continue_image;
PImage top_bar;
boolean pause = false;
boolean ability1 = false;
Ja guuut, die Seite hab ich gefunden, habe aber keine Ahnung wie ich die Library runterlade...
Ok, habs selber gefunden, sorry😅
Also, falls es irgendwann noch jemand wissen will:
if(mouseY >= 501){
if(touchIsStarted){
player_y = player_y + 13;
}
}
if(mouseY <= 500){
if(touchIsStarted){
player_y = player_y - 13;
}
}
Damit habe ich das Feld in zwei Hälften geteilt. (1. Untere Hälfte, 2. Obere Hälfte)
Für ein Viereck kann man das so aufbauen:
if(mouseY >= 0 && mouseY <= 50){
if(mouseX >= 0 && mouseX <= 50){
println("Dein Befehl");
}
}
Und void draw(){
} nicht vergessen!
Natürlich kann so ein standard Intro nervig sein, aber dafür dass es in der Regel nur ca. 10 Sekunden dauert, ist es als Einleitung schon angebracht, denke ich.
Das mit OBS hat sich erledigt, laggt zu sehr auf meinem PC, aber trotzdem würde ich gerne wissen wie man Live seine Stimme verändern kann. ;)
Falls ich dich richtig verstanden habe, und du diese Fahrstuhl Musik suchst, und wir die selbe meinen, dann gib einfach mal bei Youtube Elevator music/Fahrstuhl Musik ein. :)
Das hier benutze ich z um Beispiel:
https://youtube.com/watch?v=jj0ChLVTpaA
Kannste' dann mit nem Mp4toMp3 converter runterladen: http://convert2mp3.net/index.php