commit 5db287dacbc543a2fec0ec5e712bfb7ed323ea2e Author: DerCrafter <65090450+DerCrafter@users.noreply.github.com> Date: Thu Jul 15 19:27:13 2021 +0200 Added Code diff --git a/Client_new/Client_new.pde b/Client_new/Client_new.pde new file mode 100644 index 0000000..7af9a10 --- /dev/null +++ b/Client_new/Client_new.pde @@ -0,0 +1,20 @@ +void setup() +{ + size(1920, 1080); + clientRunning = false; + + backgroundgame = loadImage("backgroundgame.png"); + + Mario_character = loadImage("Mario.png"); + Luigi_character = loadImage("Luigi.png"); + gun = loadImage("gun.png"); + Background_Start =loadImage("Status0.png"); + menu =loadImage("Menubutton.png"); + x = loadImage("x.png"); + y = loadImage("y.png"); + backgroundminimap = loadImage("backgroundminimap.png"); + Startmusik = new SoundFile(this, "LoadingScreenMusic.mp3"); + + soundon = true; + noCursor(); +} diff --git a/Client_new/Draw.pde b/Client_new/Draw.pde new file mode 100644 index 0000000..a8bcfb0 --- /dev/null +++ b/Client_new/Draw.pde @@ -0,0 +1,571 @@ +void draw() +{ + //STARTSCREEN + if (status==0 ) + { + if (mousePressed && mouseX>100 && mouseX<300 && mouseY>10 && mouseY<60 && player_character_client !=0) + { + status = 1; + background(255); + heal_client = 100000; + if (!clientRunning) + { + c = new Client(this, ip_connect, 4444); // starte den Client + clientRunning = true; + } + } + //Background + image(Background_Start, 0, 0); + + // abfrage für vorschau + if (mousePressed && mouseX>175 && mouseX<225 && mouseY>400 && mouseY<450) + { + player_character_client = 1; + } + if (mousePressed && mouseX>100 && mouseX<150 && mouseY>400 && mouseY<450) + { + player_character_client = 2; + } + + if (mousePressed && mouseX>250 && mouseX<300 && mouseY>400 && mouseY<450) + { + player_character_client = 3; + } + + //Menu button + if (mousePressed && mouseX>1800 && mouseX<1900 && mouseY>100 && mouseY<200) + { + status=2; + } + + textSize(19); + fill(#03F9FF); + rect(100, 700, 100, 50); + fill(#6A6262); + text("Localhost", 105, 730); + + if (mousePressed && mouseX>100 && mouseX<200 && mouseY>700 && mouseY<750) + { + ip_connect = "localhost"; + } + + fill(#03F9FF); + rect(100, 800, 100, 50); + fill(#6A6262); + text("Custom IP", 105, 830); + textSize(12); + + if (mousePressed && mouseX>100 && mouseX<200 && mouseY>800 && mouseY<850) + { + status = 50; + } + + // vorschau mainscreen + fill(255); + textSize(22); + text("Character auswahl", 110, 150); + textSize(12); + + //Default IMAGE + if ( player_character_client== 1) + { + fill(#FAAB00); + ellipse(200, 230, 64, 64); + fill(255); + fill(0); + } + //Mario + if ( player_character_client == 2) + { + image(Mario_character, 175, 200); + } + //Luigi + if ( player_character_client == 3) + { + image(Luigi_character, 175, 200); + } + + + //Namen Text Feld + switch (state) { + case 0: + fill(0); + textSize(32); + text("Gib deinem charakter einen namen \n" + ": "+player_name_client, 600, 100); + textSize(12); + noFill(); + break; + case 1: + fill(255, 2, 2); + textSize(32); + text ("Dein name ist \n"+":"+player_name_client, 600, 100); + textSize(12); + fill(0); + noFill(); + break; + } + + textSize(22); + text("!!Du darfst nur 8 Buchstaben / Zahlen verwenden!!", 620, 200); + textSize(12); + + //Server Start button + fill(#00E7FA); + rect(100, 10, 200, 40); + fill(0); + text("Joine Multiplayer Session", 120, 35); + noFill(); + + //Mario select button + fill(#F50A0A); + rect(100, 400, 50, 50); + fill(0); + text("Mario", 110, 430); + noFill(); + + //Luigi select button + fill(#08FA4E); + rect(250, 400, 50, 50); + fill(0); + text("Luigi", 260, 430); + noFill(); + + //Default select button + fill(#FFB108); + rect(175, 400, 50, 50); + fill(0); + text("Balli", 185, 430); + noFill(); + + //Menu + fill(#FF1F1F); + image(menu, 1800, 100); + fill(0); + textSize(32); + fill(#05C7FF); + text("Menü", 1805, 100); + fill(0); + textSize(12); + + + if (!Startmusik.isPlaying() && soundon == true) + { + Startmusik.play(); + } + if (soundon == false) + { + Startmusik.stop(); + } + + //IP Show + textSize(20); + + text("IP : " + Server.ip(), 100, 600); + text("IP connect zum server : " + ip_connect, 100, 650); + textSize(12); + } + //MAIN GAME---------------------------MAINGAME-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + if (status==1) + { + image(backgroundgame, 0, 0); + Startmusik.stop(); + + //BOARDER + noFill(); + strokeWeight(4); + rect(110, 100, 1540, 900); + strokeWeight(1); + + //Player SHOW INGAME--CLIENT------------ + if (player_character_client == 1) + { + fill(#FAAB00); + ellipse(client_x, client_y, 64, 64); + fill(255); + noFill(); + } + if (player_character_client== 2) + { + image(Mario_character, client_x-20, client_y-20); + } + if (player_character_client == 3) + { + image(Luigi_character, client_x-20, client_y-20); + } + + //Player SHOW INGAME--SERVER------------ + + if (player_character_server == 1 && status_server == 1) + { + fill(#FAAB00); + ellipse(server_x, server_y, 64, 64); + fill(255); + noFill(); + } + if (player_character_server== 2 && status_server == 1) + { + image(Mario_character, server_x-20, server_y-20); + } + if (player_character_server == 3 && status_server == 1) + { + image(Luigi_character, server_x-20, server_y-20); + } + //debug + if (debug == true) + { + rect(server_x-5, server_y-5, 10, 10); + rect(client_x-5, client_y-5, 10, 10); + } + // TEXT ZEICHNEN CLIENT + if (player_character_client !=0) + { + fill(0, 0, 0); + textSize(22); + text(player_name_client, client_x-10, client_y-20); + textSize(12); + } + // TEXT ZEICHNEN SERVER + if (player_character_server !=0) + { + fill(0, 0, 0); + textSize(22); + text(player_name_server, server_x-10, server_y-20); + textSize(12); + } + //MINIMAP + fill(#766D6D); + rect(1699, 19, 201, 201); + fill(#870CF5); + image(backgroundminimap, 1700, 20); + ellipse(client_x/9.6+1700, client_y/5.4+20, 16, 16); + fill(#FF0303); + ellipse(server_x/9.6+1700, server_y/5.4+20, 16, 16); + noFill(); + + //Heal Bar + fill(#1BF078); + //player_heal + rect(100, 30, heal_client/500, 10); + noFill(); + if (player_character_server !=0 && status_server == 1) + { + fill(#FF1A12); + rect(server_x -30, server_y -50, heal_server/1000, 10); + noFill(); + } + if (heal_client <= 100) + { + status = 4; + player_character_client = 0; + heal_client = 100000; + } + if (heal_server <= 100) + { + player_character_server = 0; + heal_server = 100000; + points++; + } + + // Punktesystem + textSize(20); + text(points, 400, 50); + textSize(12); + + //Menu + fill(#FF1F1F); + image(menu, 10, 980); + menu.resize(0, 50); + fill(0); + textSize(22); + fill(255); + text("Menü", 10, 980); + fill(0); + textSize(12); + //button trigger menu ingame + if (mousePressed && mouseX>10 && mouseX<60 && mouseY>980 && mouseY<1030) + { + menu_ingame = true; + } + + //TRY TO ENABLE SHOOTINGS + //ENABLE SHOOTINGS SERVER SIDE + + mouseX_client = mouseX; + mouseY_client = mouseY; + + for (int n=0; n<50; n++) + { + fill(50); + ellipse(KugelX_server[n], KugelY_server[n], 10, 10); + KugelX_server[n] += cos(radians(KugelRichtung_server[n]))*5; + KugelY_server[n] += sin(radians(KugelRichtung_server[n]))*5; + //abstand von kugel berechnen und leben abziehen + for (int i=0; i<50; i++) + { + if (abstand(x_client[i], y_client[i], KugelX_client[n], KugelY_client[n]) < 60 && player_character_server !=0) + { + heal_server = heal_server -1; + } + } + } + for (int n=0; n<50; n++) + + { + x_client[n] = server_x; + y_client[n] = server_y; + } + if (mousepressed_server == 1 && player_character_server !=0) + { + KugelX_server[nummer_server] = server_x+25; + KugelY_server[nummer_server] = server_y+25; + KugelRichtung_server[nummer_server] = richtungMaus_server(server_x, server_y); + nummer_server = (nummer_server+1)%50; + } + + // ENABLE SHOOTINGS CLIENT + for (int n=0; n<50; n++) + { + fill(50); + ellipse(KugelX_client[n], KugelY_client[n], 10, 10); + KugelX_client[n] += cos(radians(KugelRichtung_client[n]))*5; + KugelY_client[n] += sin(radians(KugelRichtung_client[n]))*5; + } + if (mousepressed_client == 1 && player_character_client !=0) + { + KugelX_client[nummer_client] = client_x+25; + KugelY_client[nummer_client] = client_y+25; + KugelRichtung_client[nummer_client] = richtungMaus_client(client_x, client_y); + nummer_client = (nummer_client+1)%50; + } + //Gun + if (status_server == 1) + { + spielerZeichnen_server(server_x+25, server_y+25); + } + spielerZeichnen_client(client_x+25, client_y+25); + } + //Menu------------------------STARTSCREEN----------------MENUUUUUUU----------------------------- + if (status==2) + { + image(Background_Start, 0, 0); + fill(255); + rect(810, 390, 300, 300); + fill(0); + textSize(22); + text("MENÜ", 920, 430); + fill(0); + textSize(12); + + + //SOUNDBUTTON true or false + rect(840, 450, 49, 49); + if (buttonCooldown > 0) buttonCooldown --; + if ( mousePressed && mouseX>840 && mouseX<890 && mouseY>450 && mouseY<500 && buttonCooldown == 0) + { + buttonCooldown = 30; + if (soundon == true) + { + soundon=false; + } else if (soundon == false) + { + soundon=true; + } + } + if (soundon==true) + { + image(y, 840, 450); + fill(0); + textSize(18); + text("Musik ist AN!", 910, 480); + textSize(12); + if (!Startmusik.isPlaying()) + { + Startmusik.play(); + } + } + if (soundon==false) + { + image(x, 840, 450); + fill(0); + textSize(18); + text("Musik ist AUS!", 910, 480); + textSize(12); + Startmusik.stop(); + } + //buton exit + fill(#0FDBCC); + rect(1040, 630, 50, 50); + fill(0); + textSize(14); + text("Zurück", 1040, 660); + textSize(12); + //button trigger + if (mousePressed && mouseX>1040 && mouseX<1090 && mouseY>630 && mouseY<680) + { + status = 0; + } + } + //Menu ingame; + + if (menu_ingame) + { + fill(255); + rect(810, 390, 300, 300); + fill(0); + + textSize(22); + text("MENÜ", 920, 430); + fill(0); + textSize(12); + + //buton exit + fill(#0FDBCC); + rect(1040, 630, 50, 50); + fill(0); + textSize(14); + text("Zurück", 1040, 660); + textSize(12); + + if (mousePressed && mouseX>1040 && mouseX<1090 && mouseY>630 && mouseY<680) + { + menu_ingame = false; + } + //reconnect + fill(255); + rect(840, 450, 49, 49); + fill(0); + + //reconnect abfrage + if (clientRunning == true) + { + image(y, 840, 450); + fill(0); + textSize(18); + text("Client ist ON!", 910, 480); + textSize(12); + } + if (clientRunning == false) + { + image(x, 840, 450); + fill(0); + textSize(18); + text("Client ist OFF!", 910, 480); + textSize(12); + } + if (debug == true) + { + if (buttonCooldown > 0) buttonCooldown --; + if (mousePressed && mouseX>840 && mouseX<890 && mouseY>450 && mouseY<500 && buttonCooldown == 0) + { + buttonCooldown = 30; + if (clientRunning == true) + { + clientRunning = false; + } else if (clientRunning== false) + { + clientRunning=true; + } + } + } + } + //-----------LOOSING SCREEN---------------------------------------------------------- + if (status == 4) + { + points = 0; + image(Background_Start, 0, 0); + fill(#391A7C); + rect(300, 300, 200, 50); + textSize(15); + fill(0); + text("Click here to Respawn", 300, 350); + textSize(12); + state = 0; + noFill(); + if (mousePressed && mouseX>300 && mouseX<500 && mouseY>300 && mouseY<350) + { + status = 0; + clientRunning = false; + player_character_client = 0; + heal_server = 100000; + heal_client = 100000; + } + } + //----------------------------------------------------------------------------------------------------------- + + if (status == 50) + { + background(#C7D8FC); + + switch (state_ip) { + case 0: + fill(0); + textSize(32); + text("IP ADRESSE von Server \n" + ": "+ip_connect, 600, 100); + textSize(12); + noFill(); + break; + case 1: + fill(#54C3CB); + textSize(32); + text ("Selected \n"+":"+ip_connect, 600, 100); + textSize(12); + fill(0); + noFill(); + } + + fill(#FFFFFF); + rect(300, 300, 50, 50); + fill(0); + textSize(15); + text("Exit", 310, 325); + textSize(12); + + if (mousePressed && mouseX>300 && mouseX<350 && mouseY>300 && mouseY<350) + { + status = 0; + } + } + + if (clientRunning) + { + datenLesenClient(); + if (taste[0] && client_y>100) { + client_y= client_y-5*(60/frameRate); + } + if (taste[1] && client_x>110) { + client_x= client_x-5*(60/frameRate); + } + if (taste[2] && client_y<1000) { + client_y= client_y+5*(60/frameRate); + } + if (taste[3] && client_x<1650) { + client_x= client_x+5*(60/frameRate); + } + datenSchreibenClient(); + } + + //DEBUG MODE + if (debug == true && status == 1) + { + fill(#FF0000); + text(frameRate, 1600, 20); + text(frameCount, 1600, 40); + text(server_x, 1300, 20); + text(server_y, 1400, 20); + text(mouseX_server, 1200, 20); + text(mouseY_server, 1100, 20); + text(heal_server, 1000, 20); + text(status, 900, 20); + + text(client_x, 1300, 40); + text(client_y, 1400, 40); + text(mouseX_client, 1200, 40); + text(mouseY_client, 1100, 40); + text(heal_client, 1000, 40); + fill(0); + } + + fill(#00F4FF); + ellipse(mouseX, mouseY, 10, 10); +} diff --git a/Client_new/Variable.pde b/Client_new/Variable.pde new file mode 100644 index 0000000..5bc6275 --- /dev/null +++ b/Client_new/Variable.pde @@ -0,0 +1,81 @@ +//OtherLibrarys +import processing.sound.*; +import processing.video.*; + +//Network Library +import processing.net.*; +Client c; // Variable für den Client + +boolean clientRunning; +int playernummer = 0; + +String ip_connect = "localhost"; + +//PlayerVariable/Eigenmschaften +float server_x= 100; // x-Koordinate +float server_y= 100; // y-Koordinate +float client_x = 1550; // x-Koordinate +float client_y= 900; // y-Koordinate +//mousevariable +float mouseX_server=70; +float mouseY_server= 80; +float mouseX_client= 1650; +float mouseY_client= 1000; +//playercharacter variable +float player_character_server = 0; +float player_character_client = 0; +//playername +String player_name_client=""; +String player_name_server=""; +//check status from server +int status_server; +//Heal +int heal_server = 100000; +int heal_client = 100000; +//ImageDeklarieren +PImage Mario_character, Luigi_character; +PImage gun; +PImage Background_Start; +PImage backgroundgame; +PImage backgroundminimap; +//DEBUG +boolean debug = false; +//TastenSteuerung +boolean[] taste = new boolean[4]; +//textfelder +int state; +int state_ip; +//punktesystem +int points; +//MENU +PImage menu; +PImage x; +PImage y; +//berechnung von abstand player kugeln +float[] x_client = new float[100]; +float[] y_client = new float[100]; +//INGAME MENU + +//STATUS Anzeige +int status = 0; +boolean menu_ingame = false; + +//Musik +SoundFile Startmusik; +boolean soundon; +int buttonCooldown; + +//SHOOTINGS +float playerRichtung_server; +float[] KugelRichtung_server = new float[50]; +float[] KugelX_server = new float[50]; +float[] KugelY_server = new float[50]; +int nummer_server=0; +float mousepressed_server; + +float playerRichtung_client; +float[] KugelX_client = new float[50]; +float[] KugelY_client = new float[50]; +float[] KugelRichtung_client = new float[50]; +int nummer_client=0; +float mousepressed_client; diff --git a/Client_new/Void_KeyPressedReleased.pde b/Client_new/Void_KeyPressedReleased.pde new file mode 100644 index 0000000..1b7d29e --- /dev/null +++ b/Client_new/Void_KeyPressedReleased.pde @@ -0,0 +1,189 @@ +// VOID KEY PRESSED +void keyPressed() +{ + if (key == 49 && status == 1) + { + debug = true; + } + + if (key == 50 && status == 1) + { + debug = false; + } + + if (status==1) + { + switch(key) + { + case 'w': + taste[0] = true; + break; + case 'W': + taste[0] = true; + break; + + case 'a': + taste[1] = true; + break; + case 'A': + + taste[1] = true; + break; + case 's': + taste[2] = true; + break; + case 'S': + taste[2] = true; + break; + + case 'd': + taste[3] = true; + break; + case 'D': + taste[3] = true; + break; + } + } + + if (status==0) + { + if (key==ENTER || key==RETURN) + { + if (player_name_client.length()!=0) + { + state=1; + return; + } + } + + if (keyCode == 32) + { + return; + } + + if (state==0) + { + if (player_name_client.length()<8) + { + player_name_client = player_name_client + key; + } + + if (keyCode == 8 && player_name_client.length()>1) + { + player_name_client = player_name_client.substring(0, player_name_client.length() - 2); + } + } + } + + if (status == 2) + { + if ( keyCode == 32) + { + if (soundon == true) + { + soundon=false; + } else + { + if (soundon == false) + { + soundon=true; + } + } + } + } + if (menu_ingame) + { + if ( keyCode == 32 && debug == true) + { + if (clientRunning == true) + { + clientRunning=false; + } else + { + if (clientRunning == false) + { + clientRunning=true; + } + } + } + } + + if (status==50) + { + if (ip_connect.length()<15) + { + ip_connect = ip_connect + key; + } + + if (keyCode == 8 && ip_connect.length()>1) + { + ip_connect = ip_connect.substring(0, ip_connect.length() - 2); + } + } + + if (status == 50) + { + if (key==ENTER || key==RETURN) + { + if (ip_connect.length()!=0) + { + state_ip=1; + return; + } + } + } +} +// VOID KEY RELEASED +void keyReleased() +{ + if (status==1) + { + switch(key) + { + case 'w': + taste[0] = false; + break; + case 'W': + taste[0] = false; + break; + + case 'a': + taste[1] = false; + break; + case 'A': + taste[1] = false; + break; + + case 's': + taste[2] = false; + break; + case 'S': + taste[2] = false; + break; + + case 'd': + taste[3] = false; + break; + case 'D': + taste[3] = false; + break; + } + } +} + +void mousePressed() +{ + if (status == 1 && menu_ingame == false) + { + mousepressed_client = 1; + } +} + +void mouseReleased() +{ + + if (status == 1) + { + mousepressed_client = 0; + } +} diff --git a/Client_new/WriteReadDataClient.pde b/Client_new/WriteReadDataClient.pde new file mode 100644 index 0000000..7bddc05 --- /dev/null +++ b/Client_new/WriteReadDataClient.pde @@ -0,0 +1,35 @@ +void datenLesenClient() +{ + String input; + String data[]; + String zeile[]; + while (c.available() > 0) + { + input = c.readString(); + data = split(input, '\n'); // Split values into an array + for (String n : data) + { + zeile = split(n, ' '); + if (zeile[0].equals("Spieler")) + { + server_x = float(zeile[1]); + server_y = float(zeile[2]); + player_character_server = float(zeile[3]); + playerRichtung_server = float(zeile[4]); + mousepressed_server= float(zeile[5]); + nummer_server = int(zeile[6]); + mouseX_server = int(zeile[7]); + mouseY_server = int(zeile[8]); + player_name_server = zeile[9]; + heal_client = int(zeile[10]); + status_server = int(zeile[11]); + } + } + } +} + +void datenSchreibenClient() +{ + String text = "Spieler "+client_x+" "+client_y+" "+player_character_client+" "+playerRichtung_client+" "+mousepressed_client+" "+nummer_client+" "+mouseX_client+" "+mouseY_client+" "+player_name_client+" "+heal_server+"\n"; + c.write(text); +} diff --git a/Client_new/anderer_stuff.pde b/Client_new/anderer_stuff.pde new file mode 100644 index 0000000..1661d2e --- /dev/null +++ b/Client_new/anderer_stuff.pde @@ -0,0 +1,86 @@ +float richtungMaus_client(float x, float y) + +{ + + float winkel; + + float difx = mouseX-x; + + float dify = mouseY-y; + + winkel = degrees(atan(dify/difx)); + + if (difx<0) { + winkel = winkel+180; + } + + winkel = (winkel+360)%360; + + return(winkel); +} + +float richtungMaus_server(float x, float y) + +{ + + float winkel; + + float difx = mouseX_server-x; + + float dify = mouseY_server-y; + + winkel = degrees(atan(dify/difx)); + + if (difx<0) { + winkel = winkel+180; + } + + winkel = (winkel+360)%360; + + return(winkel); +} + + +void spielerZeichnen_server(float x, float y) + +{ + + translate(x, y); + + rotate(radians(richtungMaus_server(server_x, server_y)-90)); + if (status_server == 1) + { + image(gun, -15, -15, 30, 30); + } + rotate(-radians(richtungMaus_server(server_x, server_y)-90)); + + translate(-x, -y); +} + +void spielerZeichnen_client(float x, float y) + +{ + if (status == 1) + { + translate(x, y); + + rotate(radians(richtungMaus_client(client_x, client_y)-90)); + + image(gun, -15, -15, 30, 30); + + rotate(-radians(richtungMaus_client(client_x, client_y)-90)); + + translate(-x, -y); + } +} + +float abstand(float x1, float y1, float x2, float y2) + +{ + + float wert; + + wert = sqrt(sq(x1-x2)+sq(y1-y2)); + + return(wert); +} diff --git a/Client_new/data/LoadingScreenMusic.mp3 b/Client_new/data/LoadingScreenMusic.mp3 new file mode 100644 index 0000000..fcdb446 Binary files /dev/null and b/Client_new/data/LoadingScreenMusic.mp3 differ diff --git a/Client_new/data/Luigi.png b/Client_new/data/Luigi.png new file mode 100644 index 0000000..70fd053 Binary files /dev/null and b/Client_new/data/Luigi.png differ diff --git a/Client_new/data/Mario.png b/Client_new/data/Mario.png new file mode 100644 index 0000000..462ec80 Binary files /dev/null and b/Client_new/data/Mario.png differ diff --git a/Client_new/data/Menubutton.png b/Client_new/data/Menubutton.png new file mode 100644 index 0000000..344a1b5 Binary files /dev/null and b/Client_new/data/Menubutton.png differ diff --git a/Client_new/data/Status0.png b/Client_new/data/Status0.png new file mode 100644 index 0000000..1922cbd Binary files /dev/null and b/Client_new/data/Status0.png differ diff --git a/Client_new/data/Thumbs.db b/Client_new/data/Thumbs.db new file mode 100644 index 0000000..df1fa56 Binary files /dev/null and b/Client_new/data/Thumbs.db differ diff --git a/Client_new/data/backgroundgame.png b/Client_new/data/backgroundgame.png new file mode 100644 index 0000000..7897e8e Binary files /dev/null and b/Client_new/data/backgroundgame.png differ diff --git a/Client_new/data/backgroundminimap.png b/Client_new/data/backgroundminimap.png new file mode 100644 index 0000000..e070af9 Binary files /dev/null and b/Client_new/data/backgroundminimap.png differ diff --git a/Client_new/data/gun.png b/Client_new/data/gun.png new file mode 100644 index 0000000..7a0e767 Binary files /dev/null and b/Client_new/data/gun.png differ diff --git a/Client_new/data/x.png b/Client_new/data/x.png new file mode 100644 index 0000000..8db1122 Binary files /dev/null and b/Client_new/data/x.png differ diff --git a/Client_new/data/y.png b/Client_new/data/y.png new file mode 100644 index 0000000..b2341c1 Binary files /dev/null and b/Client_new/data/y.png differ diff --git a/Server_new/Draw.pde b/Server_new/Draw.pde new file mode 100644 index 0000000..9d88aae --- /dev/null +++ b/Server_new/Draw.pde @@ -0,0 +1,520 @@ +void draw() +{ + + status_server = status; + //STARTSCREEN + if (status==0) + { + if (mousePressed && mouseX>100 && mouseX<300 && mouseY>10 && mouseY<60 && player_character_server !=0) + { + status = 1; + background(255); + heal_server = 100000; + if (!serverRunning) + { + s = new Server(this, 4444); // starte den Server + serverRunning = true; + } + } + //Background + image(Background_Start, 0, 0); + + //character abfrage für vorschau + if (mousePressed && mouseX>175 && mouseX<225 && mouseY>400 && mouseY<450) + { + player_character_server = 1; + } + if (mousePressed && mouseX>100 && mouseX<150 && mouseY>400 && mouseY<450) + { + player_character_server = 2; + } + + if (mousePressed && mouseX>250 && mouseX<300 && mouseY>400 && mouseY<450) + { + player_character_server= 3; + } + + //Menu button + if (mousePressed && mouseX>1800 && mouseX<1900 && mouseY>100 && mouseY<200 ) + { + status=2; + } + + //character vorschau mainscreen + fill(255); + textSize(22); + text("Character auswahl", 110, 150); + textSize(12); + + //Defaultcharacter IMAGE + if (player_character_server == 1) + { + fill(#FAAB00); + ellipse(200, 230, 64, 64); + fill(255); + fill(0); + } + //Mario + if (player_character_server == 2) + { + image(Mario_character, 175, 200); + } + //Luigi + if (player_character_server == 3) + { + image(Luigi_character, 175, 200); + } + + + //Namen Text Feld + switch (state) { + case 0: + fill(0); + textSize(32); + text("Gib deinem charakter einen namen \n" + ": "+player_name_server, 600, 100); + textSize(12); + noFill(); + break; + case 1: + fill(255, 2, 2); + textSize(32); + text ("Dein name ist \n"+":"+player_name_server, 600, 100); + textSize(12); + fill(0); + noFill(); + break; + } + + textSize(22); + text("!!Du darfst nur 8 Buchstaben / Zahlen verwenden!!", 620, 200); + textSize(12); + + //Server Start button + fill(#00E7FA); + rect(100, 10, 200, 40); + fill(0); + text("Starte Multiplayer Server", 120, 35); + noFill(); + + //Mario select button + fill(#F50A0A); + rect(100, 400, 50, 50); + fill(0); + text("Mario", 110, 430); + noFill(); + + //Luigi select button + fill(#08FA4E); + rect(250, 400, 50, 50); + fill(0); + text("Luigi", 260, 430); + noFill(); + + //Default select button + fill(#FFB108); + rect(175, 400, 50, 50); + fill(0); + text("Balli", 185, 430); + noFill(); + + //Menu + fill(#FF1F1F); + image(menu, 1800, 100); + fill(0); + textSize(32); + fill(#05C7FF); + text("Menü", 1805, 100); + fill(0); + textSize(12); + + + if (!Startmusik.isPlaying() && soundon == true) + { + Startmusik.play(); + } + if (soundon == false) + { + Startmusik.stop(); + } + + //IP Show + textSize(20); + + text("IP : " + Server.ip(), 100, 800); + textSize(12); + + fill(#00F4FF); + ellipse(mouseX, mouseY, 10, 10); + } + //MAIN GAME---------------------------MAINGAME------------------------------------------------------------------------------------------------------ + + if (status==1) + { + image(backgroundgame, 0, 0); + Startmusik.stop(); + //BOARDER + noFill(); + strokeWeight(4); + rect(110, 100, 1540, 900); + strokeWeight(1); + //Player SHOW INGAME--SERVER------------ + if (player_character_server == 1) + { + fill(#FAAB00); + ellipse(server_x, server_y, 64, 64); + fill(255); + noFill(); + } + if (player_character_server == 2) + { + image(Mario_character, server_x-20, server_y-20); + } + if (player_character_server == 3) + { + image(Luigi_character, server_x-20, server_y-20); + } + //Player SHOW INGAME--CLIENT------------ + if (player_character_client == 1) + { + fill(#FAAB00); + ellipse(client_x, client_y, 64, 64); + fill(255); + noFill(); + } + if (player_character_client== 2) + { + image(Mario_character, client_x-20, client_y-20); + } + if (player_character_client == 3) + { + image(Luigi_character, client_x-20, client_y-20); + } + //debug + if (debug == true) + { + rect(server_x-5, server_y-5, 10, 10); + rect(client_x-5, client_y-5, 10, 10); + } + // TEXT ZEICHNEN SERVER + if (player_character_server !=0) + { + fill(0, 0, 0); + textSize(22); + text(player_name_server, server_x-10, server_y-20); + textSize(12); + } + // TEXT ZEICHNEN CLIENT + if (player_character_client !=0) + { + fill(0, 0, 0); + textSize(22); + text(player_name_client, client_x-10, client_y-20); + textSize(12); + } + //MINIMAP + fill(#766D6D); + rect(1699, 19, 201, 201); + fill(#870CF5); + image(backgroundminimap, 1700, 20); + ellipse(server_x/9.6+1700, server_y/5.4+20, 16, 16); + if (player_character_client != 0) + { + fill(#FF0303); + ellipse(client_x/9.6+1700, client_y/5.4+20, 16, 16); + } + noFill(); + + //Heal Bar + fill(#1BF078); + //player_heal + rect(100, 30, heal_server/500, 10); + noFill(); + if (player_character_client !=0) + { + fill(#FF1A12); + rect(client_x -30, client_y -50, heal_client/1000, 10); + noFill(); + } + if (heal_server <= 100) + { + status = 4; + player_character_server = 0; + heal_server = 100000; + } + if (heal_client <= 100) + { + player_character_client = 0; + heal_client = 100000; + points++; + } + + // Punktesystem + textSize(20); + text(points, 400, 50); + textSize(12); + + //Menu + fill(#FF1F1F); + image(menu, 10, 980); + menu.resize(0, 50); + fill(0); + textSize(22); + fill(255); + text("Menü", 10, 980); + fill(0); + textSize(12); + //button trigger menu ingame + if (mousePressed && mouseX>10 && mouseX<60 && mouseY>980 && mouseY<1030) + { + menu_ingame = true; + } + + //ENABLE SHOOTINGS SERVER SIDE + + mouseX_server = mouseX; + mouseY_server = mouseY; + + for (int n=0; n<50; n++) + { + fill(50); + ellipse(KugelX_server[n], KugelY_server[n], 10, 10); + KugelX_server[n] += cos(radians(KugelRichtung_server[n]))*5; + KugelY_server[n] += sin(radians(KugelRichtung_server[n]))*5; + } + if (mousepressed_server == 1 && player_character_server !=0) + { + KugelX_server[nummer_server] = server_x+25; + KugelY_server[nummer_server] = server_y+25; + KugelRichtung_server[nummer_server] = richtungMaus_server(server_x, server_y); + nummer_server = (nummer_server+1)%50; + } + + // ENABLE SHOOTINGS CLIENT + + for (int n=0; n<50; n++) + { + fill(50); + ellipse(KugelX_client[n], KugelY_client[n], 10, 10); + KugelX_client[n] += cos(radians(KugelRichtung_client[n]))*5; + KugelY_client[n] += sin(radians(KugelRichtung_client[n]))*5; + //abstand von kugel berechnen und leben abziehen + for (int i=0; i<50; i++) + { + if (abstand(x_server[i], y_server[i], KugelX_server[n], KugelY_server[n]) < 60&& player_character_client !=0) + { + heal_client = heal_client -1; + } + } + } + for (int n=0; n<50; n++) + + { + x_server[n] = client_x; + y_server[n] = client_y; + } + if (mousepressed_client == 1 && player_character_client !=0) + { + KugelX_client[nummer_client] = client_x+25; + KugelY_client[nummer_client] = client_y+25; + KugelRichtung_client[nummer_client] = richtungMaus_client(client_x, client_y); + nummer_client = (nummer_client+1)%50; + } + //Gun + spielerZeichnen_server(server_x+25, server_y+25); + if (player_character_client !=0) + { + spielerZeichnen_client(client_x+25, client_y+25); + } + fill(#00F4FF); + ellipse(mouseX, mouseY, 10, 10); + } + //Menu-------------------------------STARTSCREEN--------MENUUUUUUU---------------------------- + if (status==2) + { + image(Background_Start, 0, 0); + fill(255); + rect(810, 390, 300, 300); + fill(0); + + textSize(22); + text("MENÜ", 920, 430); + fill(0); + textSize(12); + + + //SOUNDBUTTON true or false + + rect(840, 450, 49, 49); + if (buttonCooldown > 0) buttonCooldown --; + if ( mousePressed && mouseX>840 && mouseX<890 && mouseY>450 && mouseY<500 && buttonCooldown == 0) + { + buttonCooldown = 30; + if (soundon == true) + { + soundon=false; + } else if (soundon == false) + { + soundon=true; + } + } + if (soundon==true) + { + image(y, 840, 450); + fill(0); + textSize(18); + text("Musik ist AN!", 910, 480); + textSize(12); + if (!Startmusik.isPlaying()) + { + Startmusik.play(); + } + } + if (soundon==false) + { + image(x, 840, 450); + fill(0); + textSize(18); + text("Musik ist AUS!", 910, 480); + textSize(12); + Startmusik.stop(); + } + //buton exit + fill(#0FDBCC); + rect(1040, 630, 50, 50); + fill(0); + textSize(14); + text("Zurück", 1040, 660); + textSize(12); + //button trigger + if (mousePressed && mouseX>1040 && mouseX<1090 && mouseY>630 && mouseY<680) + { + status = 0; + } + } + //Menu ingame----------------------------------------------------------------------------------------------------- + + if (menu_ingame) + { + fill(255); + rect(810, 390, 300, 300); + fill(0); + + textSize(22); + text("MENÜ", 920, 430); + fill(0); + textSize(12); + + //buton exit + fill(#0FDBCC); + rect(1040, 630, 50, 50); + fill(0); + textSize(14); + text("Zurück", 1040, 660); + textSize(12); + + if (mousePressed && mouseX>1040 && mouseX<1090 && mouseY>630 && mouseY<680) + { + menu_ingame = false; + status = 1; + } + + //Server Close + fill(255); + rect(840, 450, 49, 49); + fill(0); + //server on or off + + if (serverRunning == true) + { + image(y, 840, 450); + fill(0); + textSize(18); + text("Server ist ON!", 910, 480); + textSize(12); + } + if (serverRunning == false) + { + image(x, 840, 450); + fill(0); + textSize(18); + text("Server ist OFF!", 910, 480); + textSize(12); + } + if (debug == true) + { + if (buttonCooldown > 0) buttonCooldown --; + if (mousePressed && mouseX>840 && mouseX<890 && mouseY>450 && mouseY<500 && buttonCooldown == 0) + { + buttonCooldown = 30; + if (serverRunning == true) + { + serverRunning = false; + } else if (serverRunning == false) + { + serverRunning=true; + } + } + } + } + //---------------------------Loosing screen------------------------------------------------------- + if (status == 4) + { + points = 0; + image(Background_Start, 0, 0); + fill(#391A7C); + rect(300, 300, 200, 50); + textSize(15); + fill(0); + text("Click here to Respawn", 300, 350); + textSize(12); + state = 0; + noFill(); + if (mousePressed && mouseX>300 && mouseX<500 && mouseY>300 && mouseY<350) + { + status = 0; + player_character_server = 0; + heal_server = 100000; + heal_client = 100000; + } + } + //---------------------------------------------------------------------------------- + if (serverRunning) + { + datenLesenServer(); + if (taste[0] && server_y>100) { + server_y= server_y-5*(60/frameRate); + } + if (taste[1] && server_x>110) { + server_x= server_x-5*(60/frameRate); + } + if (taste[2] && server_y<1000) { + server_y= server_y+5*(60/frameRate); + } + if (taste[3] && server_x<1650) { + server_x= server_x+5*(60/frameRate); + } + datenSchreibenServer(); + } + //DEBUG MODE + if (debug == true && status == 1) + { + fill(#FF0000); + text(frameRate, 1600, 20); + text(frameCount, 1600, 40); + text(server_x, 1300, 20); + text(server_y, 1400, 20); + text(mouseX_server, 1200, 20); + text(mouseY_server, 1100, 20); + text(heal_server, 1000, 20); + text(status, 900, 20); + + text(client_x, 1300, 40); + text(client_y, 1400, 40); + text(mouseX_client, 1200, 40); + text(mouseY_client, 1100, 40); + text(heal_client, 1000, 40); + fill(0); + } + fill(#00F4FF); + ellipse(mouseX, mouseY, 10, 10); +} diff --git a/Server_new/Server_new.pde b/Server_new/Server_new.pde new file mode 100644 index 0000000..5a4223b --- /dev/null +++ b/Server_new/Server_new.pde @@ -0,0 +1,20 @@ +void setup() +{ + size(1920, 1080); + serverRunning = false; + + backgroundgame = loadImage("backgroundgame.png"); + + Mario_character = loadImage("Mario.png"); + Luigi_character = loadImage("Luigi.png"); + gun = loadImage("gun.png"); + Background_Start =loadImage("Status0.png"); + menu =loadImage("Menubutton.png"); + x = loadImage("x.png"); + y = loadImage("y.png"); + backgroundminimap = loadImage("backgroundminimap.png"); + Startmusik = new SoundFile(this, "LoadingScreenMusic.mp3"); + + soundon = true; + noCursor(); +} diff --git a/Server_new/Variable.pde b/Server_new/Variable.pde new file mode 100644 index 0000000..d676849 --- /dev/null +++ b/Server_new/Variable.pde @@ -0,0 +1,80 @@ +//OtherLibrarys +import processing.sound.*; +import processing.video.*; + +//Network Library +import processing.net.*; +Server s; +Client c; +boolean serverRunning; +int playernummer = 0; + +Client[] server_c = new Client[16]; + +//PlayerVariable/Eigenmschaften + +float server_x= 100; // x-Koordinate +float server_y= 100; // y-Koordinate +float client_x= 1550; // x-Koordinate +float client_y= 900; // y-Koordinate +//mousevariable +float mouseX_server=70; +float mouseY_server= 80; +float mouseX_client= 1650; +float mouseY_client= 1000; +//playercharacter variable +float player_character_server = 0; +float player_character_client = 0; +//playername +String player_name_server=""; +String player_name_client=""; +//statusfrom server +int status_server; +//Heal +int heal_server = 100000; +int heal_client = 100000; +//ImageDeklarieren +PImage Mario_character, Luigi_character; +PImage gun; +PImage Background_Start; +PImage backgroundgame; +PImage backgroundminimap; +//DEBUG +boolean debug; +//TastenSteuerung +boolean[] taste = new boolean[4]; +int state; +//punktesystem +int points; +//MENU +PImage menu; +PImage x; +PImage y; +//berechnung von abstand player kugeln +float[] x_server = new float[100]; +float[] y_server = new float[100]; +//INGAME MENU + +//STATUS Anzeige +int status; +boolean menu_ingame = false; + +//Musik +SoundFile Startmusik; +boolean soundon; +int buttonCooldown; +//SHOOTINGS + +float playerRichtung_server; +float[] KugelX_server = new float[50]; +float[] KugelY_server = new float[50]; +float[] KugelRichtung_server = new float[50]; +int nummer_server=0; +float mousepressed_server; + +float playerRichtung_client; +float[] KugelX_client = new float[50]; +float[] KugelY_client = new float[50]; +float[] KugelRichtung_client = new float[50]; +int nummer_client=0; +float mousepressed_client; diff --git a/Server_new/Void_KeyPressedReleased.pde b/Server_new/Void_KeyPressedReleased.pde new file mode 100644 index 0000000..62ba1b0 --- /dev/null +++ b/Server_new/Void_KeyPressedReleased.pde @@ -0,0 +1,163 @@ +// VOID KEY PRESSED +void keyPressed() +{ + if (key == 49) + { + debug = true; + } + + if (key == 50) + { + debug = false; + } + if (status==1) + { + switch(key) + { + case 'w': + taste[0] = true; + break; + case 'W': + taste[0] = true; + break; + + case 'a': + taste[1] = true; + break; + case 'A': + + taste[1] = true; + break; + case 's': + taste[2] = true; + break; + case 'S': + taste[2] = true; + break; + + case 'd': + taste[3] = true; + break; + case 'D': + taste[3] = true; + break; + } + } + + if (status==0) + { + if (key==ENTER || key==RETURN) + { + if (player_name_server.length()!=0) + { + state=1; + return; + } + } + + if (keyCode == 32) + { + return; + } + + if (state==0) + { + if (player_name_server.length()<8) + { + player_name_server = player_name_server + key; + } + + if (keyCode == 8 && player_name_server.length()>1) + { + player_name_server = player_name_server.substring(0, player_name_server.length() - 2); + } + } + } + //SOUND TOGGLE + if (status == 2) + { + if (keyCode == 32) + { + if (soundon == true) + { + soundon=false; + } else + { + if (soundon == false) + { + soundon=true; + } + } + } + } + //OPTIONS SERVER INGAME + if (menu_ingame) + { + if ( keyCode == 32 && debug == true) + { + if (serverRunning == true) + { + serverRunning=false; + } else + { + if (serverRunning == false) + { + serverRunning=true; + } + } + } + } +} +// VOID KEY RELEASED +void keyReleased() +{ + if (status==1) + { + switch(key) + { + case 'w': + taste[0] = false; + break; + case 'W': + taste[0] = false; + break; + + case 'a': + taste[1] = false; + break; + case 'A': + taste[1] = false; + break; + + case 's': + taste[2] = false; + break; + case 'S': + taste[2] = false; + break; + + case 'd': + taste[3] = false; + break; + case 'D': + taste[3] = false; + break; + } + } +} + +void mousePressed() +{ + if (status == 1&& menu_ingame == false) + { + mousepressed_server = 1; + } +} + +void mouseReleased() +{ + if (status == 1) + { + mousepressed_server = 0; + } +} diff --git a/Server_new/WriteReadDataServer.pde b/Server_new/WriteReadDataServer.pde new file mode 100644 index 0000000..332ea81 --- /dev/null +++ b/Server_new/WriteReadDataServer.pde @@ -0,0 +1,36 @@ +void datenLesenServer() +{ + String input; + String data[]; + String zeile[]; + c = s.available(); // erster Client aktivieren + while (c != null) + { + input = c.readString(); + data = split(input, '\n'); // Split values into an array + for (String n : data) + { + zeile = split(n, ' '); + if (zeile[0].equals("Spieler")) + { + client_x = float(zeile[1]); + client_y = float(zeile[2]); + player_character_client = float(zeile[3]); + playerRichtung_client = float(zeile[4]); + mousepressed_client = float(zeile[5]); + nummer_client = int(zeile[6]); + mouseX_client = int(zeile[7]); + mouseY_client = int(zeile[8]); + player_name_client = zeile[9]; + heal_server = int(zeile[10]); + } + } + c = s.available(); // zweiter, dritter,... Client aktivieren + } +} + +void datenSchreibenServer() +{ + String text = "Spieler "+server_x+" "+server_y+" "+player_character_server+" "+playerRichtung_server+" "+mousepressed_server+" "+nummer_server+" "+mouseX_server+" "+mouseY_server+" "+player_name_server+" "+heal_client+" "+status_server+"\n"; + s.write(text); +} diff --git a/Server_new/andere_stuff.pde b/Server_new/andere_stuff.pde new file mode 100644 index 0000000..136c5e9 --- /dev/null +++ b/Server_new/andere_stuff.pde @@ -0,0 +1,83 @@ +float richtungMaus_server(float x, float y) + +{ + + float winkel; + + float difx = mouseX-x; + + float dify = mouseY-y; + + winkel = degrees(atan(dify/difx)); + + if (difx<0) { + winkel = winkel+180; + } + + winkel = (winkel+360)%360; + + return(winkel); +} + +float richtungMaus_client(float x, float y) + +{ + + float winkel; + + float difx = mouseX_client-x; + + float dify = mouseY_client-y; + + winkel = degrees(atan(dify/difx)); + + if (difx<0) { + winkel = winkel+180; + } + + winkel = (winkel+360)%360; + + return(winkel); +} + +void spielerZeichnen_server(float x, float y) + +{ + + translate(x, y); + + rotate(radians(richtungMaus_server(server_x, server_y)-90)); + + image(gun, -15, -15, 30, 30); + + rotate(-radians(richtungMaus_server(server_x, server_y)-90)); + + translate(-x, -y); +} +void spielerZeichnen_client(float x, float y) + +{ + if (status == 1) + { + translate(x, y); + + rotate(radians(richtungMaus_client(client_x, client_y)-90)); + + image(gun, -15, -15, 30, 30); + + rotate(-radians(richtungMaus_client(client_x, client_y)-90)); + + translate(-x, -y); + } +} + +float abstand(float x1, float y1, float x2, float y2) + +{ + + float wert; + + wert = sqrt(sq(x1-x2)+sq(y1-y2)); + + return(wert); +} diff --git a/Server_new/data/LoadingScreenMusic.mp3 b/Server_new/data/LoadingScreenMusic.mp3 new file mode 100644 index 0000000..fcdb446 Binary files /dev/null and b/Server_new/data/LoadingScreenMusic.mp3 differ diff --git a/Server_new/data/Luigi.png b/Server_new/data/Luigi.png new file mode 100644 index 0000000..70fd053 Binary files /dev/null and b/Server_new/data/Luigi.png differ diff --git a/Server_new/data/Mario.png b/Server_new/data/Mario.png new file mode 100644 index 0000000..462ec80 Binary files /dev/null and b/Server_new/data/Mario.png differ diff --git a/Server_new/data/Menubutton.png b/Server_new/data/Menubutton.png new file mode 100644 index 0000000..344a1b5 Binary files /dev/null and b/Server_new/data/Menubutton.png differ diff --git a/Server_new/data/Status0.png b/Server_new/data/Status0.png new file mode 100644 index 0000000..1922cbd Binary files /dev/null and b/Server_new/data/Status0.png differ diff --git a/Server_new/data/Thumbs.db b/Server_new/data/Thumbs.db new file mode 100644 index 0000000..c90fd00 Binary files /dev/null and b/Server_new/data/Thumbs.db differ diff --git a/Server_new/data/backgroundgame.png b/Server_new/data/backgroundgame.png new file mode 100644 index 0000000..7897e8e Binary files /dev/null and b/Server_new/data/backgroundgame.png differ diff --git a/Server_new/data/backgroundminimap.png b/Server_new/data/backgroundminimap.png new file mode 100644 index 0000000..723f6b2 Binary files /dev/null and b/Server_new/data/backgroundminimap.png differ diff --git a/Server_new/data/gun.png b/Server_new/data/gun.png new file mode 100644 index 0000000..7a0e767 Binary files /dev/null and b/Server_new/data/gun.png differ diff --git a/Server_new/data/x.png b/Server_new/data/x.png new file mode 100644 index 0000000..8db1122 Binary files /dev/null and b/Server_new/data/x.png differ diff --git a/Server_new/data/y.png b/Server_new/data/y.png new file mode 100644 index 0000000..b2341c1 Binary files /dev/null and b/Server_new/data/y.png differ