Java 2D Spiel Programmieren (Vollständiges Tutorial)
4.8 هزار بار بازدید -
2 سال پیش
-
In diesem Tutorial zeige ich
In diesem Tutorial zeige ich dir, wie du in Java ein Pac-Man ähnliches Spiel mit GUI programmieren kannst. Viel Spaß!
Link zur IntelliJ IDE (Community Edition ist kostenlos):
https://www.jetbrains.com/idea/download/
Erklärvideo zur Installation von IntelliJ (Aus meinem Java Kurs):
Java IntelliJ IDE installieren (Windo...
Code für die GameMap:
private static final int[][] DEFAULT_MAP = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1},
{1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1},
{1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 0, 2, 2, 2, 0, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1},
{1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1},
{1, 2, 2, 2, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 1, 2, 2, 2, 1},
{1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1},
{1, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 1},
{1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1},
{1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1},
{1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1},
{1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1},
{1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1},
{1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1},
{1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1},
{1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1},
{1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
};
Code auf GitHub:
https://github.com/timofriedl/javaABC...
Link zum interaktiven Java Kurs (Kostenlos & Ohne Anmeldung):
💻 https://www.javaABC.de/
Unterstütze mich:
💚 https://ko-fi.com/javaABC
0:00 Einleitung
0:37 Projekt Erstellen
1:37 Fenster (Game Klasse)
5:32 Elemente Zeichnen (Display Klasse)
17:07 Spielfeld (GameMap Klasse)
20:40 Felder im Spielfeld
24:34 Felder: Block
28:27 Felder: Air
29:30 Felder: Dot
38:32 Spielfeld (GameMap Klasse)
52:00 Kreaturen (Creature Klasse)
57:58 Spieler (Player Klasse)
1:04:21 Spielfigur Bewegen
1:08:27 Game Loop: Naiver Ansatz
1:17:18 Game Loop: Besserer Ansatz
1:22:24 Wandkollisionen
1:33:25 Erweiterte Bewegungslogik
1:49:28 Kollision mit Dots
1:58:02 Spielende
2:06:33 Gegner (Enemy Klasse)
2:21:11 Pfad-Suche: A* Algorithmus
2:26:43 Pfad-Suche: Node Klasse
2:35:19 Pfad-Suche: A* Implementierung
2:54:11 Gegner 1 (ChasingEnemy Klasse)
2:59:27 Gegner 2 (CuttingEnemy Klasse)
3:05:16 Gegner 3 (RandomEnemy Klasse)
3:09:45 Fertig
3:10:17 Augen
3:11:28 Ende
│ ᵂᴱᴿᴮᵁᴺᴳ
│ *Meine Tastatur: https://amzn.to/3Gz5FrR
│ *Mein Mikrofon: https://amzn.to/3Myw5xL
│ *Meine Softbox: https://amzn.to/3zMnlwn
│ *Meine Ukulele: https://amzn.to/3Gym0NM
│ *Inspiration der DIY LED-Kette: https://amzn.to/3ZYQ0c8
│
│ *Die markierten Links sind Affiliate-Links.
│ Wenn du darüber etwas kaufst, erhalte ich eine Provision.
Link zur IntelliJ IDE (Community Edition ist kostenlos):
https://www.jetbrains.com/idea/download/
Erklärvideo zur Installation von IntelliJ (Aus meinem Java Kurs):
Java IntelliJ IDE installieren (Windo...
Code für die GameMap:
private static final int[][] DEFAULT_MAP = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1},
{1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1},
{1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 0, 2, 2, 2, 0, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1},
{1, 2, 1, 2, 1, 2,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2, 1, 2, 2, 2, 2, 2, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
};
Code auf GitHub:
https://github.com/timofriedl/javaABC...
Link zum interaktiven Java Kurs (Kostenlos & Ohne Anmeldung):
💻 https://www.javaABC.de/
Unterstütze mich:
💚 https://ko-fi.com/javaABC
0:00 Einleitung
0:37 Projekt Erstellen
1:37 Fenster (Game Klasse)
5:32 Elemente Zeichnen (Display Klasse)
17:07 Spielfeld (GameMap Klasse)
20:40 Felder im Spielfeld
24:34 Felder: Block
28:27 Felder: Air
29:30 Felder: Dot
38:32 Spielfeld (GameMap Klasse)
52:00 Kreaturen (Creature Klasse)
57:58 Spieler (Player Klasse)
1:04:21 Spielfigur Bewegen
1:08:27 Game Loop: Naiver Ansatz
1:17:18 Game Loop: Besserer Ansatz
1:22:24 Wandkollisionen
1:33:25 Erweiterte Bewegungslogik
1:49:28 Kollision mit Dots
1:58:02 Spielende
2:06:33 Gegner (Enemy Klasse)
2:21:11 Pfad-Suche: A* Algorithmus
2:26:43 Pfad-Suche: Node Klasse
2:35:19 Pfad-Suche: A* Implementierung
2:54:11 Gegner 1 (ChasingEnemy Klasse)
2:59:27 Gegner 2 (CuttingEnemy Klasse)
3:05:16 Gegner 3 (RandomEnemy Klasse)
3:09:45 Fertig
3:10:17 Augen
3:11:28 Ende
│ ᵂᴱᴿᴮᵁᴺᴳ
│ *Meine Tastatur: https://amzn.to/3Gz5FrR
│ *Mein Mikrofon: https://amzn.to/3Myw5xL
│ *Meine Softbox: https://amzn.to/3zMnlwn
│ *Meine Ukulele: https://amzn.to/3Gym0NM
│ *Inspiration der DIY LED-Kette: https://amzn.to/3ZYQ0c8
│
│ *Die markierten Links sind Affiliate-Links.
│ Wenn du darüber etwas kaufst, erhalte ich eine Provision.
2 سال پیش
در تاریخ 1401/10/27 منتشر شده
است.
4,808
بـار بازدید شده