Doppelbufferung: Bilder überlagern!

Status
Nicht offen für weitere Antworten.

ToNyXXL

Mitglied
Hi, ich hab nen Problem mit meinem Java Frame.
Und zwar hab ich zwar die Standard Doppelbufferung eingefügt die man überall findet, allerding ist das Problem das wenn ich 2 Bilder hab und die übereinander liegen, das das dann trotzdem "ruckelt" sprich ganz ganz kurz is das eine Bild zu sehen, was eigentlich drunter liegen soll!
Komisch is auch, das es (soweit ich weiß) nur auf meinem PC (neues Modell und gute Grafik) so ist, aber auf dem Schulrechner (ältere Grafikkarte usw) funktioniert es perfekt!
???:L ???:L
 

ToNyXXL

Mitglied
hey,
also der komplette code is ziemlich lang, weil nen ganzes spiel dahinter hängt und doppelbufferung hab ich schon viele versucht! könnte es vielleicht dran liegen das ich stink normale images nehme, also
Code:
Image menue;
ImageIcon menue_tmp = new ImageIcon("menue.jpg");
menue = menue_tmp.getImage();
g.drawImage(menue, 5, 5, 55, 55, this);
??
 

m@nu

Bekanntes Mitglied
wie wärs, wenn du deine grafikdatei einmal zu beginn lädst?
so wie du das hier machst, wird bei jedem zeichnen eine neue ImageIcon instanz mit menue.jpg erstellt.

das kostet zeit und ressourcen. zusätzlich empfehle ich dir das verwenden von bufferedimages im compatible-modus, wenn du probleme mit der grafikperformance hast
dazu findest du hier einen thread:
:arrow: http://www.java-forum.org/de/viewtopic.php?p=288991#288991
(geht da zwar um spiele, trifft aber auf java2d allgemein zu)

ps. von doublebuffering kann man in deinem code nicht viel sehen ... hast du das wirklich richtig implementiert?
 

ToNyXXL

Mitglied
danke manu für den thread link, ich werd ihn mir glech angucken!
allerdings hab ich mich wohl falsch ausgedrückt, tschuldige, denn mein code daoben ist natürlich nur ein ausschnit aus allem, die erste zeile steht über der klasse, die 2 anderen im konstruktor und die letzte im paint! natürlich lad ich das bild nicht immer neu, und die doppelbufferung hab ich aus dem beispiel weggelassen, da ich ein standard beispiel gemacht hab, und dort wie folgt vorgegangen bin:
die 2 bild variablen deklariert - die vorgefertigte update methode eingebaut - repaint() hingeschrieben --> hab ich da etwas übersehen???
nnaja vll hab ich glück und dein thread hilft mir schon weiter!
 

Wildcard

Top Contributor
doppelbufferung - Denglisch at it's best :?
Ohne Code wird dir niemand helfen können.
Mein Tipp an dich, nimm das wesentlich bessere Swing, dort hast du eine Hardware-beschleunigte doppelte Pufferung/double buffering gleich eingebaut.
 

ToNyXXL

Mitglied
Wildcard hat gesagt.:
doppelbufferung - Denglisch at it's best :?
Ohne Code wird dir niemand helfen können.
Mein Tipp an dich, nimm das wesentlich bessere Swing, dort hast du eine Hardware-beschleunigte doppelte Pufferung/double buffering gleich eingebaut.

ok jetzt wird mir klar warum ich sowenig bei Google gefunden hab ???:L sollte vielleicht mal nach double buffering suchen ^^

werde dann hier mal meinen Code zugeschnitten post, wenn ich auch nicht glaube das sich das wer durchlesen möchte :gaen:


Code:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import java.io.*;
import javax.sound.sampled.*;
import java.util.Random;
import java.text.DecimalFormat;

public class Start extends JFrame implements Runnable 
{
        Feld[][][] feld;
        Texte text;
        Items[] item;
        int event;
        boolean[] event_finished;
        // SPIELFELD GRÖSSE
        int s_width = 100;
        int s_height = 100;
        // FELDGRÖSSE
        int feldgröße = 20;
        // POSITIONSBESTIMMUNGEN
        int pos_x, pos_y;
        // ARRAY HILFSVARIABLE
        int Rect_x = 0, Rect_y = 0;
        // Spielerposition
        int spieler_x = 3, spieler_y = 6;
        // ACTIONLISTENER ADDEN
        Tastatureingabe tasta = new Tastatureingabe();
        Mauseingabe maus = new Mauseingabe();
        int maus_x, maus_y;
        // BILDER HINZUFÜGEN
        Image menue, interface_panel, bg;
        BufferedImage interface_panel2;
        ImageIcon[] mapimg_tmp, mapimg_v_tmp;
        Image[] mapimg, mapimg_v;
        ImageIcon[] hero_v_tmp, hero_l_tmp, hero_r_tmp, hero_h_tmp;
        Image[] hero_v, hero_l, hero_r, hero_h;
        ImageIcon[] npc_tmp;
        Image[] npc;
        ImageIcon[] itemimg_tmp;
        Image[] itemimg;
        //MAP EINSTELLUNGEN
        int map = 0, oldmap = 1;
        //SITUATIONS EINSTELLUNGEN
        boolean infight = false, infight_temp = false;
        boolean indialog = false, indialog_temp = false;
        boolean weiter = false;
        int npc_x_tmp = 0, npc_y_tmp = 0, gegner_x_tmp = 0, gegner_y_tmp = 0;
        // CREDITS
        int credits_count;
        String[] credits_text;
        boolean credits = false;
        // HELD
        String blickrichtung = "rechts";
        boolean going = false;
        int schritt = 2, oldschritt = 2;
        int level = 1;
        int xp = 0, xptolevel = 500;
        int hpticker = 0;
        double hp = 100, maxhp = 100;
        int manaticker = 0;
        double mana = 100, maxmana = 100;
        boolean oom = false;
        int make_dmg, become_dmg, become_mana;
        double gold;
        int[] inventar, rucksack, r_anzahl;
        boolean inventar_offen, rucksack_offen;
        boolean tod = false, todrepainted = false;
        int animation;
        // DOPPELBUFFERUNG
        private Image dbImage = null;
        private Graphics dbGraphics;
        // ZAHLEN RUNDEN
        DecimalFormat df = new DecimalFormat("#.##"); 
        //SOUND
        Sound s = new Sound();
        // FONT
        Font fTest;
        
    public static void main(String[] args) 
    {
        // FRAME WIRD INITIALISIERT
        Start start = new Start();

        start.pack();
        start.setSize(1024,768); 
        start.setVisible(true);
    }
   
    Start() 
    {
        // TITEL WIRD GESETZT
        super("The Legends of Saria");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        Thread th = new Thread (this);
        th.start (); 
        
        feld = new Feld[10][250][250];
        FelderErstellen();
        
        // BILDER WERDEN GELADEN
        ImageIcon menue_tmp = new ImageIcon("menue.jpg");
        menue = menue_tmp.getImage();
        
        ImageIcon bg_tmp = new ImageIcon("bg.jpg");
        bg = bg_tmp.getImage();
        
        ImageIcon interface_panel_tmp = new ImageIcon("interface.png");
        interface_panel = interface_panel_tmp.getImage();
                
        mapimg = new Image[99];
        mapimg_tmp = new ImageIcon[99];
        mapimg_v = new Image[99];
        mapimg_v_tmp = new ImageIcon[99];
        for(int mapcount = 1; mapcount < 15; mapcount++)
        {
            mapimg_tmp[mapcount] = new ImageIcon("Maps/map_"+mapcount+".png");
            mapimg[mapcount] = mapimg_tmp[mapcount].getImage();
            mapimg_v_tmp[mapcount] = new ImageIcon("Maps/map_"+mapcount+"_v.png");
            mapimg_v[mapcount] = mapimg_v_tmp[mapcount].getImage();
        }
        
        hero_v = new Image[4];
        hero_v_tmp = new ImageIcon[4];
        hero_h = new Image[4];
        hero_h_tmp = new ImageIcon[4];
        hero_l = new Image[4];
        hero_l_tmp = new ImageIcon[4];
        hero_r = new Image[4];
        hero_r_tmp = new ImageIcon[4];
        
        hero_v_tmp[1] = new ImageIcon("Hero/hero_v_1.png");
        hero_v[1] = hero_v_tmp[1].getImage();
        hero_v_tmp[2] = new ImageIcon("Hero/hero_v_2.png");
        hero_v[2] = hero_v_tmp[2].getImage();
        hero_v_tmp[3] = new ImageIcon("Hero/hero_v_3.png");
        hero_v[3] = hero_v_tmp[3].getImage();
        hero_h_tmp[1] = new ImageIcon("Hero/hero_h_1.png");
        hero_h[1] = hero_h_tmp[1].getImage();
        hero_h_tmp[2] = new ImageIcon("Hero/hero_h_2.png");
        hero_h[2] = hero_h_tmp[2].getImage();
        hero_h_tmp[3] = new ImageIcon("Hero/hero_h_3.png");
        hero_h[3] = hero_h_tmp[3].getImage();
        hero_l_tmp[1] = new ImageIcon("Hero/hero_l_1.png");
        hero_l[1] = hero_l_tmp[1].getImage();
        hero_l_tmp[2] = new ImageIcon("Hero/hero_l_2.png");
        hero_l[2] = hero_l_tmp[2].getImage();
        hero_l_tmp[3] = new ImageIcon("Hero/hero_l_3.png");
        hero_l[3] = hero_l_tmp[3].getImage();
        hero_r_tmp[1] = new ImageIcon("Hero/hero_r_1.png");
        hero_r[1] = hero_r_tmp[1].getImage();
        hero_r_tmp[2] = new ImageIcon("Hero/hero_r_2.png");
        hero_r[2] = hero_r_tmp[2].getImage();
        hero_r_tmp[3] = new ImageIcon("Hero/hero_r_3.png");
        hero_r[3] = hero_r_tmp[3].getImage();
        
        npc = new Image[99];
        npc_tmp = new ImageIcon[99];
        for(int npccount = 1; npccount < 10; npccount ++)
        {
             npc_tmp[npccount] = new ImageIcon("NPCs/npc"+npccount+".png");
             npc[npccount] = npc_tmp[npccount].getImage();
        } 
        
        itemimg = new Image[200];
        itemimg_tmp = new ImageIcon[200];
        for(int itemimgcount = 1; itemimgcount < 200; itemimgcount ++)
        {
             itemimg_tmp[itemimgcount] = new ImageIcon("Items/item_"+itemimgcount+".jpg");
             itemimg[itemimgcount] = itemimg_tmp[itemimgcount].getImage();
        } 
        addKeyListener(tasta);
        addMouseListener(maus); 
    } 
    
    public void run ()
    {
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        while (true)
        {
            if(credits_count > 565) 
                credits_count--;
            hpticker++;
            manaticker++;
            
            if(map > 0)
            for(int z = 1; z < 10; z++)
                for(int y = 1; y < 50; y++)
                    for(int x = 1; x < 50; x++)
                       if((spieler_x == x) && (spieler_y == y));
                       else
                        if(feld[z][x][y].Spawntime() > 0)
                        {
                            if(feld[z][x][y].Spawntime() == 1)
                                repaint();
                            feld[z][x][y].Spawntimer();
                        }
                            
            try
            {
                Thread.sleep (40);
            }
            catch (InterruptedException ex)
            {
            }
            Thread.currentThread().setPriority(Thread.MAX_PRIORITY); 
            
            istTod();
            if((credits_count > 565) || (hpticker == 20) || (manaticker == 20)) 
                repaint();
        } 
    }
           
     public void update(Graphics g)
     {
         //Double-Buffer initialisieren
         if (dbImage == null)
         {
             dbImage = createImage(1024, 768);
             dbGraphics = dbImage.getGraphics();
         }
            //Hintergrund löschen
            dbGraphics.setColor(getBackground());
            dbGraphics.fillRect(0, 0, 1024, 768);
            //Vordergrund zeichnen
            dbGraphics.setColor(getForeground());
            paint(dbGraphics);
            //Offscreen anzeigen
            g.drawImage(dbImage,0,0,this);
     }
     
    public void paint(Graphics g)
    {   
        invalidate();
        g.setFont(fTest);
       
        if(map == 0)
        {
            MenüPaint(g);
        }
        else
        {
            istTod();
            
            if(tod)
            {
                TodPaint(g);
            }
            else
            {
                Kämpfen();
                LevelUp();
                HP_Berechnen(); 
                Mana_Berechnen(); 
                InventarÖffnen();
                RucksackÖffnen();
        
        if(!infight && !indialog && !inventar_offen && !rucksack_offen)
        {
                HeldAusrichtung();
                x_Berechnung();
                y_Berechnung();
                MapCheat();
                Mapwechsel();
                Pos_Berechnung();
                
            g.fillRect(200, 200, 824, 568);
            g.drawImage(mapimg[map], (220 - Rect_x * feldgröße), (220 - Rect_y * feldgröße), mapimg[map].getWidth(this), mapimg[map].getHeight(this), this);
        
            for(int y=0; y<50; y++)
            {
                for(int x=0; x<50; x++)
                {
                    if((Rect_y>=0) && (Rect_y<=100) && (Rect_x>=0) && (Rect_x<=100))
                    {
                        // NPC
                        if(feld[map][Rect_x][Rect_y].NpcaufFeld() != 0)
                        {
                            if((Rect_x == spieler_x) && (spieler_y == Rect_y))
                            {
                                if(feld[map][Rect_x][Rect_y].gibGesinnung() == 0)
                                {
                                    infight = true;
                                    gegner_x_tmp = Rect_x;
                                    gegner_y_tmp = Rect_y;
                                }
                                else
                                {
                                    if(feld[map][Rect_x][Rect_y].gibDialog() != 0)
                                    {
                                        if(!indialog_temp)
                                            indialog = true;
                                    }
                                    npc_x_tmp = Rect_x;
                                    npc_y_tmp = Rect_y;
                                }
                            }
                            int npc_width = npc[feld[map][Rect_x][Rect_y].NpcaufFeld()].getWidth(this);
                            int npc_height = npc[feld[map][Rect_x][Rect_y].NpcaufFeld()].getHeight(this);
                            g.drawImage(npc[feld[map][Rect_x][Rect_y].NpcaufFeld()], (197 +  x*feldgröße), (200 - (npc_height/3)  + y*feldgröße), npc_width, npc_height, this);
                        }
                        if((spieler_x == npc_x_tmp) && (spieler_y == npc_y_tmp));
                        else
                        {
                            indialog_temp = false;
                            event = 0;
                        }
                        if((Rect_x == spieler_x) && (spieler_y == Rect_y))
                        {
                        // SPIELER
                                if(blickrichtung == "vorne") 
                                    g.drawImage(hero_v[schritt], 600, 473, 20, 27, this);
                                if(blickrichtung == "hinten") 
                                    g.drawImage(hero_h[schritt], 600, 473, 20, 27, this);
                                if(blickrichtung == "links") 
                                    g.drawImage(hero_l[schritt], 600, 473, 20, 27, this);
                                if(blickrichtung == "rechts") 
                                    g.drawImage(hero_r[schritt], 600, 473, 20, 27, this);
                        }  
                    }
                    Rect_x++;
                }
            Rect_x = pos_x;
            Rect_y++;
            }
        Rect_y=pos_y;
        }
        // VORDERGRUND EBENE ZEICHNEN
        g.drawImage(mapimg_v[map], (220 - Rect_x * feldgröße), (220 - Rect_y * feldgröße), mapimg[map].getWidth(this), mapimg[map].getHeight(this), this);
        
        if(inventar_offen)
        {
            if(tasta.Weiter())
            {
                inventar_offen = false;
                tasta.RemoveMoving();
            }
            g.setColor(Color.blue);
            g.fillRect(200,200,1024,1000); 
            g.setColor(Color.red);
            for(int c = 0; c < 8; c++)
            {
                g.drawImage(itemimg[item[inventar[c]].SymbolID()], 300, 210 + 70*c, 64, 64, this);
                g.drawString(item[inventar[c]].Name(), 370, 250 + 70*c);
            }
        }
        
        if(rucksack_offen)
        {
            if(tasta.Weiter())
            {
                rucksack_offen = false;
                tasta.RemoveMoving();
            }
            g.setColor(Color.blue);
            g.fillRect(200,200,1024,1000); 
            g.setColor(Color.red);
            for(int c = 0; c < 24; c++)
            {
                g.drawImage(itemimg[item[rucksack[c]].SymbolID()], 300, 210 + 70*c, 64, 64, this);
                g.drawString(item[rucksack[c]].Name(), 370, 250 + 70*c);
                if(rucksack[c] != 0 && r_anzahl[c] > 1)
                    g.drawString(""+r_anzahl[c], 305, 268 + 70*c);
            }
        }
        
        if(indialog)
        {
            if(feld[map][npc_x_tmp][npc_y_tmp].NpcaufFeld() != 1)
                blickrichtung = "hinten";
            if(tasta.Weiter())
            {
                indialog_temp = true;
                indialog = false;
                tasta.RemoveMoving();
                if(feld[map][npc_x_tmp][npc_y_tmp].Respawnable() == false)
                   feld[map][npc_x_tmp][npc_y_tmp].NPC_Entfernen(); 
            }
            g.setColor(Color.blue);
            g.fillRect(+200,+200,1024,1000); 
            g.setColor(Color.red);
            boolean stringende = false;
            int index = 0;
            int anfangsindex = 1;
            int text_height = 300;
            int text_width = 0;
            int text_rows = 0;
            String der_text;
            
            while(!stringende)
            {
                anfangsindex = index + 1;
                index = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).indexOf("#", anfangsindex);
                der_text = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).substring(anfangsindex, index);
                if(der_text.endsWith("+"))
                {
                    stringende = true;
                    break;
                }
                text_rows++;
            }
            
            stringende = false;
            index = 0;
            text_height = 770 - (text_rows *20);
            
            g.setColor(Color.green);
            g.fillRect(250, (750 - (text_rows *20)), 724, (text_rows * 20 + 30));
            g.setColor(Color.red);
            
            while(!stringende)
            {
                anfangsindex = index + 1;
                index = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).indexOf("#", anfangsindex);
                der_text = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).substring(anfangsindex, index);
                if(der_text.endsWith("+"))
                {
                    stringende = true;
                    break;
                }
                text_width = (g.getFontMetrics().stringWidth(der_text) / 2);
                g.drawString(der_text, (610 - text_width), text_height);   
                text_height = text_height + 20;
            }
            
            // EVENTABFRAGE
            if(feld[map][npc_x_tmp][npc_y_tmp].gibEvent() != 0)
            {
                event = feld[map][npc_x_tmp][npc_y_tmp].gibEvent();
                Events();
            }
        }
        
        if((infight) && (!infight_temp))
        {
            g.setColor(Color.blue);
            g.fillRect(+200,+200,1024,1000); 
            g.setColor(Color.red);
            g.drawString("Ungläubiger! Meine geschärfte Klinge wird deinen Leib in tausend Stücke zerteilen!!", 400,400);
            g.drawString("Du hast "+make_dmg+" Schaden gemacht und "+become_dmg+" verloren",250, 300);
            if(oom == true)
                g.drawString("Für den aktuellen Zauber hast du leider nicht genug Mana!",250, 330);
            g.drawString("Gegner Level: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibLevel()+" ||| Gegner HP: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibHP()+"/"+feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxHP()+" ||| Gegner Mana: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibMana()+"/"+feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxMana()+"", 300,450);
            double tmp_hp2 = feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() / feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxHP() * 200;
            double tmp_m2 = feld[map][gegner_x_tmp][gegner_y_tmp].gibMana() / feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxMana() * 200;
            g.fillRect(300, 500, ((int)tmp_hp2), 15);
            g.fillRect(300, 600, ((int)tmp_m2), 15);
            g.setColor(Color.black);
            g.drawRect(300, 500, 200, 15);
            g.drawRect(300, 600, 200, 15);
            g.setColor(Color.red);
        }
        else
            infight_temp = false;
            
        InterfacePaint(g);
        tasta.RemoveMoving();
       } 
       }
    } 
    
    public void MenüPaint(Graphics g)
    {
        MenuBerechnen();
        g.drawImage(menue, 0, 0, 1024, 768, this);
        if(credits) 
        {
            g.drawString(credits_text[0], 490, credits_count);
            g.drawString(credits_text[1], 490, credits_count + 20);
            g.drawString(credits_text[2], 490, credits_count + 40);
            g.drawString(credits_text[3], 490, credits_count + 60);
            g.drawString(credits_text[4], 490, credits_count + 90);
            g.drawString(credits_text[5], 490, credits_count + 110);
            g.drawString(credits_text[6], 490, credits_count + 130);
            
            g.drawRect(480, credits_count - 15, 150, 160);
        }
    }
    
    public void TodPaint(Graphics g)
    {
       g.setColor(Color.blue);
       g.fillRect(0,0,1024,1000); 
       g.setColor(Color.red);
       g.drawString("Du scheinst dem Tod geweiht, Soldat!!", 400,400);
    }
    
    public void InterfacePaint(Graphics g)
    {    
        g.drawImage(interface_panel, 0, 0, 1024, 768, this);
        g.setColor(Color.red); 
        double tmp_hp = hp / maxhp * 200;
        double tmp_m = mana / maxmana * 200;
        g.fillRect(300, 50, ((int)tmp_hp), 15);
        g.fillRect(300, 100, ((int)tmp_m), 15);
        g.setColor(Color.black); 
        g.drawRect(300, 50, 200, 15);
        g.drawRect(300, 100, 200, 15);
    }
}
 

Wildcard

Top Contributor
Das ist Swing. Lass es einfach sein. Der JFrame hat automatisch double buffering.
Davon abgesehen kommst du so nirgends an. Überleg dir eine sinnvolle Aufgabenteilung für einzelne Objekte und versuch nicht alles in eine einzige Klasse zu quetschen :?
 

ToNyXXL

Mitglied
hmm darf ich deiner antwort entnehmen, das ich es keine lösung gibt, bzw ich zu dumm bin und mir gleich den goldenen schuss geben kann??

naja und das mit den klassen, ich hab ja noch weitere nur die hab ich hier rausgelassen ^^ is halt schon nen richtiges kleines rollenspiel, mein problem is echt nur dieses blööde flackern auf meinem pc, kann ich nur noch hoffen das der lehrer pc genauso schlecht is wie die schüler pcs, damits dann da shigg aussieht ;)
 

Wildcard

Top Contributor
ToNyXXL hat gesagt.:
hmm darf ich deiner antwort entnehmen, das ich es keine lösung gibt, bzw ich zu dumm bin und mir gleich den goldenen schuss geben kann??
???
Du willst etwas implementieren das SUN schon gemacht hat und zwar deutlich besser. Was bitte ist daran schlecht?
Lass die paint des Frames wie sie ist, setz ein JPanel auf den Frame und zeichne dort (ohne irgendwelche Offscreen Images), dann flackert auch nichts.
 

André Uhres

Top Contributor
ToNyXXL hat gesagt.:
..werde dann hier mal meinen Code zugeschnitten post, wenn ich auch nicht glaube das sich das wer durchlesen möchte..
Nimm mal "paint" und "update" wieder raus und was in paint war, das
machste in paintComponent von einer neuen Klasse, die JPanel erweitert:
Code:
package paint;
/*
 * SpielDemo.java
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SpielDemo extends JFrame {
    private JButton btShow2;
    private JToolBar toolbar;
    private Spiel spiel;
//    // DOPPELBUFFERUNG
//    private Image dbImage = null;
//    private Graphics dbGraphics;
    public SpielDemo() {
        super("Spiel Demo");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        toolbar = new JToolBar();
        btShow2 = new JButton();
        btShow2.setText("Show picture 2");
        btShow2.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent evt) {
                btShow2ActionPerformed(evt);
            }
        });
        toolbar.add(btShow2);
        getContentPane().add(toolbar, BorderLayout.NORTH);
        spiel = new Spiel();
        getContentPane().add(spiel);
    }
    private void btShow2ActionPerformed(final ActionEvent evt) {
        spiel.second = true;
        repaint();
    }
//    public void paint(Graphics g) {
//        super.paint(g);
//        g.drawImage(pic1,0,0,null);
//        if(second)
//            g.drawImage(pic3,200,200,null);
//    }
//    public void update(Graphics g) {
//        //Double-Buffer initialisieren
//        if (dbImage == null) {
//            dbImage = createImage(1024, 768);
//            dbGraphics = dbImage.getGraphics();
//        }
//        //Hintergrund löschen
//        dbGraphics.setColor(getBackground());
//        dbGraphics.fillRect(0, 0, 1024, 768);
//        //Vordergrund zeichnen
//        dbGraphics.setColor(getForeground());
//        paint(dbGraphics);
//        //Offscreen anzeigen
//        g.drawImage(dbImage,0,0,this);
//    }
    public static void main(final String args[]) {new SpielDemo().setVisible(true);}
    class Spiel extends JPanel{
        private Image pic1, pic3;
        protected boolean second;
        public Spiel(){
            pic1= new ImageIcon("c:\\Picture1.jpg").getImage();
            pic3= new ImageIcon("c:\\Picture3.jpg").getImage();
        }
        protected void paintComponent(final Graphics g) {
            super.paintComponent(g);
            g.drawImage(pic1,0,0,null);
            if(second)
                g.drawImage(pic3,200,200,null);
        }
    }
}
 

ToNyXXL

Mitglied
sorry aba irgendwie kapier ich das nicht, hab mich vorher noch nie mit nem Panel beschäftigt und hab auch keine Ahnung wie das funktioniert! hatte mir hier zu testzwecken mal ne neues klasse angelegt als panel und meine paint darein verschoben, aba dann gingen ja meinen ganzen methoden und so nicht mehr richtig
 
S

stev.glasow

Gast
oohm
glaskugel_150.jpg
 

ToNyXXL

Mitglied
ja also mein problem is, da mein programm ja schon ziemlich lang ist, weiß ich nicht wie ich das jetz alles umschreiben muss, damit das ne JPanel klasse ist! also welche methoden in die neue klasse gehören, nur die paint oda noch andere? und welche ich "runable" machen soll, und welche die keylisterner braucht und all son zeug xD
 

Marco13

Top Contributor
Vielleicht ist DAS der Grund, weswegen manche kranken Hirne auf die absurde Idee kommen, ERST nachzudenekn, und DANN Code zu schreiben ???:L
 

André Uhres

Top Contributor
ToNyXXL hat gesagt.:
ja also mein problem is, da mein programm ja schon ziemlich lang ist,
weiß ich nicht wie ich das jetz alles umschreiben muss,
damit das ne JPanel klasse ist! also welche methoden in die neue klasse gehören,
nur die paint oda noch andere? und welche ich "runable" machen soll, u
nd welche die keylisterner braucht und all son zeug xD
Naja, in die JPanel Klasse muss alles rein, was dazu gehört, damit sie funktionieren kann.
Mehr kann man schwer dazu sagen, es sei denn, wir können deinen Code einsehen.
Leider ist meine Kristallkugel momentan in Reparatur :cool:
 

ToNyXXL

Mitglied
also am code posten solls nich scheitern, ich dacht mir nur das wär nen bissel argh viel.....

Code:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import java.io.*;
import javax.sound.sampled.*;
import java.util.Random;
import java.text.DecimalFormat;

public class Start extends JFrame implements Runnable 
{
        Feld[][][] feld;
        Texte text;
        Items[] item;
        int event;
        String[] questname, questtext;
        int questid;
        boolean[] event_finished;
        // SPIELFELD GRÖSSE
        int s_width = 100;
        int s_height = 100;
        // FELDGRÖSSE
        int feldgröße = 20;
        // POSITIONSBESTIMMUNGEN
        int pos_x, pos_y;
        // ARRAY HILFSVARIABLE
        int Rect_x = 0, Rect_y = 0;
        // Spielerposition
        int spieler_x = 3, spieler_y = 6;
        // ACTIONLISTENER ADDEN
        Tastatureingabe tasta = new Tastatureingabe();
        Mauseingabe maus = new Mauseingabe();
        int maus_x, maus_y;
        // BILDER HINZUFÜGEN
        Image menue, interface_panel, bg;
        ImageIcon[] mapimg_tmp, mapimg_v_tmp;
        Image[] mapimg, mapimg_v;
        ImageIcon[] hero_v_tmp, hero_l_tmp, hero_r_tmp, hero_h_tmp;
        Image[] hero_v, hero_l, hero_r, hero_h;
        ImageIcon[] npc_tmp;
        Image[] npc;
        ImageIcon[] itemimg_tmp;
        Image[] itemimg;
        //MAP EINSTELLUNGEN
        int map = 0, oldmap = 1;
        //SITUATIONS EINSTELLUNGEN
        boolean infight = false, infight_temp = false;
        boolean indialog = false, indialog_temp = false;
        boolean weiter = false;
        int npc_x_tmp = 0, npc_y_tmp = 0, gegner_x_tmp = 0, gegner_y_tmp = 0;
        // CREDITS
        int credits_count;
        String[] credits_text;
        boolean credits = false;
        // HELD
        String blickrichtung = "rechts";
        boolean going = false;
        int schritt = 2, oldschritt = 2;
        int level = 1;
        int xp = 0, xptolevel = 500;
        int hpticker = 0;
        double hp = 100, maxhp = 100;
        int manaticker = 0;
        double mana = 100, maxmana = 100;
        boolean oom = false;
        int make_dmg, become_dmg, become_mana;
        double gold;
        int[] inventar, rucksack, r_anzahl;
        boolean inventar_offen, rucksack_offen, questlog_offen;
        boolean tod = false, todrepainted = false;
        int animation;
        //SOUND
        Sound s = new Sound();
        
    public static void main(String[] args) 
    {
        // FRAME WIRD INITIALISIERT
        Start start = new Start();

        start.pack();
        start.setSize(1024,768); 
        start.setVisible(true);
    }
   
    Start() 
    {
        // TITEL WIRD GESETZT
        super("The Legends of Saria");
        // DESIGN WIRD AUF METALL LOOK GESTELLT
        try 
        {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        }
        catch(Exception ex) 
        {
            System.err.println("Fehler bei LookandFeel\n"); 
        }
        Cursor c = getToolkit().createCustomCursor(
        new ImageIcon( "cursor.png" ).getImage(),
        new Point(1,1), "Cursor" );
        setCursor( c );
        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        Thread th = new Thread (this);
        th.start (); 
                
        credits_text = new String[7];        
        credits_text[0] = new String("Schnittchen: Eike");
        credits_text[1] = new String("Story: Tobi");
        credits_text[2] = new String("Design: Edi");
        credits_text[3] = new String("Code: Torben");
        credits_text[4] = new String("And special Thankz to:");
        credits_text[5] = new String("...");
        credits_text[6] = new String("nobody!");
        
        feld = new Feld[10][250][250];
        FelderErstellen();
        
        text = new Texte();
        
        questname = new String[900];
        questtext = new String[900];
        
        item = new Items[300];
        ItemsLaden();
        
        event_finished = new boolean[999];
        
        inventar = new int[55];
        InventarLaden();
        // 0: füße, 1: beine, 2: brust, 3: hände, 4: kopf, 5: finger, 6: rechte hand, 7: linke hand
        rucksack = new int[66];
        r_anzahl = new int[66];
        RucksackLaden();
        
        // BILDER WERDEN GELADEN
        ImageIcon menue_tmp = new ImageIcon("menue.jpg");
        menue = menue_tmp.getImage();
        
        ImageIcon bg_tmp = new ImageIcon("bg.jpg");
        bg = bg_tmp.getImage();
        
        ImageIcon interface_panel_tmp = new ImageIcon("interface.png");
        interface_panel = interface_panel_tmp.getImage();
                
        mapimg = new Image[99];
        mapimg_tmp = new ImageIcon[99];
        mapimg_v = new Image[99];
        mapimg_v_tmp = new ImageIcon[99];
        for(int mapcount = 1; mapcount < 15; mapcount++)
        {
            mapimg_tmp[mapcount] = new ImageIcon("Maps/map_"+mapcount+".png");
            mapimg[mapcount] = mapimg_tmp[mapcount].getImage();
            mapimg_v_tmp[mapcount] = new ImageIcon("Maps/map_"+mapcount+"_v.png");
            mapimg_v[mapcount] = mapimg_v_tmp[mapcount].getImage();
        }
        
        hero_v = new Image[4];
        hero_v_tmp = new ImageIcon[4];
        hero_h = new Image[4];
        hero_h_tmp = new ImageIcon[4];
        hero_l = new Image[4];
        hero_l_tmp = new ImageIcon[4];
        hero_r = new Image[4];
        hero_r_tmp = new ImageIcon[4];
        
        hero_v_tmp[1] = new ImageIcon("Hero/hero_v_1.png");
        hero_v[1] = hero_v_tmp[1].getImage();
        hero_v_tmp[2] = new ImageIcon("Hero/hero_v_2.png");
        hero_v[2] = hero_v_tmp[2].getImage();
        hero_v_tmp[3] = new ImageIcon("Hero/hero_v_3.png");
        hero_v[3] = hero_v_tmp[3].getImage();
        hero_h_tmp[1] = new ImageIcon("Hero/hero_h_1.png");
        hero_h[1] = hero_h_tmp[1].getImage();
        hero_h_tmp[2] = new ImageIcon("Hero/hero_h_2.png");
        hero_h[2] = hero_h_tmp[2].getImage();
        hero_h_tmp[3] = new ImageIcon("Hero/hero_h_3.png");
        hero_h[3] = hero_h_tmp[3].getImage();
        hero_l_tmp[1] = new ImageIcon("Hero/hero_l_1.png");
        hero_l[1] = hero_l_tmp[1].getImage();
        hero_l_tmp[2] = new ImageIcon("Hero/hero_l_2.png");
        hero_l[2] = hero_l_tmp[2].getImage();
        hero_l_tmp[3] = new ImageIcon("Hero/hero_l_3.png");
        hero_l[3] = hero_l_tmp[3].getImage();
        hero_r_tmp[1] = new ImageIcon("Hero/hero_r_1.png");
        hero_r[1] = hero_r_tmp[1].getImage();
        hero_r_tmp[2] = new ImageIcon("Hero/hero_r_2.png");
        hero_r[2] = hero_r_tmp[2].getImage();
        hero_r_tmp[3] = new ImageIcon("Hero/hero_r_3.png");
        hero_r[3] = hero_r_tmp[3].getImage();
        
        npc = new Image[99];
        npc_tmp = new ImageIcon[99];
        for(int npccount = 1; npccount < 10; npccount ++)
        {
             npc_tmp[npccount] = new ImageIcon("NPCs/npc"+npccount+".png");
             npc[npccount] = npc_tmp[npccount].getImage();
        } 
        
        itemimg = new Image[200];
        itemimg_tmp = new ImageIcon[200];
        for(int itemimgcount = 1; itemimgcount < 200; itemimgcount ++)
        {
             itemimg_tmp[itemimgcount] = new ImageIcon("Items/item_"+itemimgcount+".jpg");
             itemimg[itemimgcount] = itemimg_tmp[itemimgcount].getImage();
        } 
            
        setBackground(Color.black);
        
        addKeyListener(tasta);
        addMouseListener(maus); 
    } 
    
    public void run ()
    {
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        while (true)
        {
            if(credits_count > 565) 
                credits_count--;
            hpticker++;
            manaticker++;
            
            if(map > 0)
            for(int z = 1; z < 10; z++)
                for(int y = 1; y < 50; y++)
                    for(int x = 1; x < 50; x++)
                       if((spieler_x == x) && (spieler_y == y));
                       else
                        if(feld[z][x][y].Spawntime() > 0)
                        {
                            if(feld[z][x][y].Spawntime() == 1)
                                repaint();
                            feld[z][x][y].Spawntimer();
                        }
                            
            try
            {
                Thread.sleep (40);
            }
            catch (InterruptedException ex)
            {
            }
            Thread.currentThread().setPriority(Thread.MAX_PRIORITY); 
            
            istTod();
            if((credits_count > 565) || (hpticker == 20) || (manaticker == 20)) 
                repaint();
        } 
    }
     
    public void paint(Graphics g)
    {          
        if(map == 0)
        {
            MenüPaint(g);
        }
        else
        {
            istTod();
            
            if(tod)
            {
                TodPaint(g);
            }
            else
            {
                Kämpfen();
                LevelUp();
                HP_Berechnen(); 
                Mana_Berechnen(); 
                QuestlogÖffnen();
                InventarÖffnen();
                RucksackÖffnen();
        
        if(!infight && !indialog && !inventar_offen && !rucksack_offen)
        {
                HeldAusrichtung();
                x_Berechnung();
                y_Berechnung();
                MapCheat();
                Mapwechsel();
                Pos_Berechnung();
                
            g.fillRect(200, 200, 824, 568);
            g.drawImage(mapimg[map], (220 - Rect_x * feldgröße), (220 - Rect_y * feldgröße), mapimg[map].getWidth(this), mapimg[map].getHeight(this), this);
        
            for(int y=0; y<50; y++)
            {
                for(int x=0; x<50; x++)
                {
                    if((Rect_y>=0) && (Rect_y<=100) && (Rect_x>=0) && (Rect_x<=100))
                    {
                        // NPC
                        if(feld[map][Rect_x][Rect_y].NpcaufFeld() != 0)
                        {
                            if((Rect_x == spieler_x) && (spieler_y == Rect_y))
                            {
                                if(feld[map][Rect_x][Rect_y].gibGesinnung() == 0)
                                {
                                    infight = true;
                                    gegner_x_tmp = Rect_x;
                                    gegner_y_tmp = Rect_y;
                                }
                                else
                                {
                                    if(feld[map][Rect_x][Rect_y].gibDialog() != 0)
                                    {
                                        if(!indialog_temp)
                                            indialog = true;
                                    }
                                    npc_x_tmp = Rect_x;
                                    npc_y_tmp = Rect_y;
                                }
                            }
                            int npc_width = npc[feld[map][Rect_x][Rect_y].NpcaufFeld()].getWidth(this);
                            int npc_height = npc[feld[map][Rect_x][Rect_y].NpcaufFeld()].getHeight(this);
                            g.drawImage(npc[feld[map][Rect_x][Rect_y].NpcaufFeld()], (197 +  x*feldgröße), (200 - (npc_height/3)  + y*feldgröße), npc_width, npc_height, this);
                        }
                        if((spieler_x == npc_x_tmp) && (spieler_y == npc_y_tmp));
                        else
                        {
                            indialog_temp = false;
                            event = 0;
                        }
                        if((Rect_x == spieler_x) && (spieler_y == Rect_y))
                        {
                        // SPIELER
                                if(blickrichtung == "vorne") 
                                    g.drawImage(hero_v[schritt], 600, 473, 20, 27, this);
                                if(blickrichtung == "hinten") 
                                    g.drawImage(hero_h[schritt], 600, 473, 20, 27, this);
                                if(blickrichtung == "links") 
                                    g.drawImage(hero_l[schritt], 600, 473, 20, 27, this);
                                if(blickrichtung == "rechts") 
                                    g.drawImage(hero_r[schritt], 600, 473, 20, 27, this);
                        }  
                    }
                    Rect_x++;
                }
            Rect_x = pos_x;
            Rect_y++;
            }
        Rect_y=pos_y;
        }
        // VORDERGRUND EBENE ZEICHNEN
        g.drawImage(mapimg_v[map], (220 - Rect_x * feldgröße), (220 - Rect_y * feldgröße), mapimg[map].getWidth(this), mapimg[map].getHeight(this), this);
        
        if(questlog_offen)
        {
            if(tasta.Weiter())
            {
                questlog_offen = false;
                tasta.RemoveMoving();
            }
            g.setColor(Color.blue);
            g.fillRect(200,200,1024,1000); 
            g.setColor(Color.red);
            int text_height2 = 0;
            for(int d = 1; d < (questid + 1); d++)
            {
                g.drawString(questname[d], 370, 200 + 30*d + text_height2);
                
                boolean stringende = false;
                int index = 0;
                int anfangsindex = 1;
                int text_height = 0;
                String der_text;
                while(!stringende)
                {
                    anfangsindex = index + 1;
                    index = questtext[d].indexOf("#", anfangsindex);
                    der_text = questtext[d].substring(anfangsindex, index);
                    if(der_text.endsWith("+"))
                    {
                        stringende = true;
                        text_height2 = text_height;
                        break;
                    }
                    g.drawString(der_text, 370, 215 + 30*d + text_height); 
                    text_height = text_height + 15;
                }
            }
        }
        
        if(inventar_offen)
        {
            if(tasta.Weiter())
            {
                inventar_offen = false;
                tasta.RemoveMoving();
            }
            g.setColor(Color.blue);
            g.fillRect(200,200,1024,1000); 
            g.setColor(Color.red);
            for(int c = 0; c < 8; c++)
            {
                g.drawImage(itemimg[item[inventar[c]].SymbolID()], 300, 210 + 70*c, 64, 64, this);
                g.drawString(item[inventar[c]].Name(), 370, 250 + 70*c);
            }
        }
        
        if(rucksack_offen)
        {
            if(tasta.Weiter())
            {
                rucksack_offen = false;
                tasta.RemoveMoving();
            }
            g.setColor(Color.blue);
            g.fillRect(200,200,1024,1000); 
            g.setColor(Color.red);
            for(int c = 0; c < 24; c++)
            {
                g.drawImage(itemimg[item[rucksack[c]].SymbolID()], 300, 210 + 70*c, 64, 64, this);
                g.drawString(item[rucksack[c]].Name(), 370, 250 + 70*c);
                if(rucksack[c] != 0 && r_anzahl[c] > 1)
                    g.drawString(""+r_anzahl[c], 305, 268 + 70*c);
            }
        }
        
        if(indialog)
        {
            if(feld[map][npc_x_tmp][npc_y_tmp].NpcaufFeld() != 1)
                blickrichtung = "hinten";
            if(tasta.Weiter())
            {
                indialog_temp = true;
                indialog = false;
                if(feld[map][npc_x_tmp][npc_y_tmp].Respawnable() == false)
                   feld[map][npc_x_tmp][npc_y_tmp].NPC_Entfernen(); 
            }
            g.setColor(Color.blue);
            g.fillRect(+200,+200,1024,1000); 
            g.setColor(Color.red);
            boolean stringende = false;
            int index = 0;
            int anfangsindex = 1;
            int text_height = 300;
            int text_width = 0;
            int text_rows = 0;
            String der_text;
            
            while(!stringende)
            {
                anfangsindex = index + 1;
                index = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).indexOf("#", anfangsindex);
                der_text = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).substring(anfangsindex, index);
                if(der_text.endsWith("+"))
                {
                    stringende = true;
                    break;
                }
                text_rows++;
            }
            
            stringende = false;
            index = 0;
            text_height = 770 - (text_rows *20);
            
            g.setColor(Color.green);
            g.fillRect(250, (750 - (text_rows *20)), 724, (text_rows * 20 + 30));
            g.setColor(Color.red);
            
            while(!stringende)
            {
                anfangsindex = index + 1;
                index = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).indexOf("#", anfangsindex);
                der_text = text.gibText(feld[map][npc_x_tmp][npc_y_tmp].gibDialog()).substring(anfangsindex, index);
                if(der_text.endsWith("+"))
                {
                    stringende = true;
                    break;
                }
                text_width = (g.getFontMetrics().stringWidth(der_text) / 2);
                g.drawString(der_text, (610 - text_width), text_height);   
                text_height = text_height + 20;
            }
            
            // EVENTABFRAGE
            if(feld[map][npc_x_tmp][npc_y_tmp].gibEvent() != 0 && feld[map][npc_x_tmp][npc_y_tmp].gibGesinnung() == 1)
            {
                event = feld[map][npc_x_tmp][npc_y_tmp].gibEvent();
                Events();
            }
        }
        
        if((infight) && (!infight_temp))
        {
            g.setColor(Color.blue);
            g.fillRect(+200,+200,1024,1000); 
            g.setColor(Color.red);
            g.drawString("Ungläubiger! Meine geschärfte Klinge wird deinen Leib in tausend Stücke zerteilen!!", 400,400);
            g.drawString("Du hast "+make_dmg+" Schaden gemacht und "+become_dmg+" verloren",250, 300);
            if(oom == true)
                g.drawString("Für den aktuellen Zauber hast du leider nicht genug Mana!",250, 330);
            g.drawString("Gegner Level: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibLevel()+" ||| Gegner HP: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibHP()+"/"+feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxHP()+" ||| Gegner Mana: "+feld[map][gegner_x_tmp][gegner_y_tmp].gibMana()+"/"+feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxMana()+"", 300,450);
            double tmp_hp2 = feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() / feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxHP() * 200;
            double tmp_m2 = feld[map][gegner_x_tmp][gegner_y_tmp].gibMana() / feld[map][gegner_x_tmp][gegner_y_tmp].gibMaxMana() * 200;
            g.fillRect(300, 500, ((int)tmp_hp2), 15);
            g.fillRect(300, 600, ((int)tmp_m2), 15);
            g.setColor(Color.black);
            g.drawRect(300, 500, 200, 15);
            g.drawRect(300, 600, 200, 15);
            g.setColor(Color.red);
        }
        else
            infight_temp = false;
            
        InterfacePaint(g);
        tasta.RemoveMoving();
       } 
       }
    } 
    
    public void MenüPaint(Graphics g)
    {
        MenuBerechnen();
        g.drawImage(menue, 0, 0, 1024, 768, this);
        if(credits) 
        {
            g.drawString(credits_text[0], 490, credits_count);
            g.drawString(credits_text[1], 490, credits_count + 20);
            g.drawString(credits_text[2], 490, credits_count + 40);
            g.drawString(credits_text[3], 490, credits_count + 60);
            g.drawString(credits_text[4], 490, credits_count + 90);
            g.drawString(credits_text[5], 490, credits_count + 110);
            g.drawString(credits_text[6], 490, credits_count + 130);
            
            g.drawRect(480, credits_count - 15, 150, 160);
        }
    }
    
    public void TodPaint(Graphics g)
    {
       g.setColor(Color.blue);
       g.fillRect(0,0,1024,1000); 
       g.setColor(Color.red);
       g.drawString("Du scheinst dem Tod geweiht, Soldat!!", 400,400);
    }
    
    public void InterfacePaint(Graphics g)
    {    
        g.drawImage(interface_panel, 0, 0, 1024, 768, this);
        g.setColor(Color.red); 
        double tmp_hp = hp / maxhp * 200;
        double tmp_m = mana / maxmana * 200;
        g.fillRect(300, 50, ((int)tmp_hp), 15);
        g.fillRect(300, 100, ((int)tmp_m), 15);
        g.setColor(Color.black); 
        g.drawRect(300, 50, 200, 15);
        g.drawRect(300, 100, 200, 15);
    }
    
    // ATTACKEN
        public void Kämpfen()
        {
            if(infight)
            {
                oom = false;
                
                if(tasta.Attacke() == 1)
                {
                    make_dmg = (5*level + Zufallszahl(1, 10));
                    feld[map][gegner_x_tmp][gegner_y_tmp].setHP(feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() - make_dmg);
                    Become_DMG();
                }
                if(tasta.Attacke() == 2)
                {
                    become_mana = 60;
                    if(mana - become_mana >= 0)
                    {
                        make_dmg = (15*level + Zufallszahl(10, 20));
                        feld[map][gegner_x_tmp][gegner_y_tmp].setHP(feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() - make_dmg);
                        mana = mana - become_mana;
                        Become_DMG();
                    }
                    else
                        oom = true;
                }
                if(feld[map][gegner_x_tmp][gegner_y_tmp].gibHP() <= 0)
                {
                    make_dmg = 0;
                    become_dmg = 0;
                    become_mana = 0;
                    infight = false;
                    infight_temp = true;
                    event = feld[map][gegner_x_tmp][gegner_y_tmp].gibEvent();
                    Events();
                    feld[map][spieler_x][spieler_y].NpcLöschen();
                    XP_Berechnen();
                    Gold_Berechnen();
                }
            }
        }
        
        public void Become_DMG()
        {
            become_dmg = Zufallszahl(5, 15);
            hp = hp - become_dmg;
        }
        
        public void XP_Berechnen()
        {
            xp = xp + Zufallszahl(90, 110);
        }
        
        public void Gold_Berechnen()
        {
            gold = gold + Zufallszahl(1, 10)*0.1;
        }
    
        public void LevelUp()
        {
            if((xp >= xptolevel)  && (!infight))
            {
                xp = xp - xptolevel;
                xptolevel = xptolevel + (xptolevel*30/100);
                maxhp = maxhp + level * 10;
                maxmana = maxmana + level * 10;
                hp = maxhp;
                mana = maxmana;
                level++;
            }
        }
        
        public void HP_Berechnen()
        {
            if((hpticker >= 20)  && (!infight))
            {
                if(hp + 2 * level > maxhp)
                    hp = maxhp;
                else
                    hp = hp + 2 * level;
                    
                hpticker = 0;
            }
        }
        
        public void Mana_Berechnen()
        {
            if((manaticker >= 20)  && (!infight))
            {
                if(mana + 2 * level > maxmana)
                    mana = maxmana;
                else
                    mana = mana + 2 * level;
                    
                manaticker = 0;
            }
        }
        
        public void istTod()
        {
            if(hp <=0)
            {
                tod = true;
                if(!todrepainted)
                    repaint();
                todrepainted = true;
            }
        } 
        
        public void Pos_Berechnung()
        {
            // ERSTES FELD WIRD BERECHNET
            pos_x = spieler_x - 20;
            pos_y = spieler_y - 14;
            
            // DATEN WERDEN FÜR FOR SCHLEIFE KOPIERT
            Rect_x = pos_x;
            Rect_y = pos_y;
        }
          
        public void HeldAusrichtung()
        {
            // BLICKRICHTUNG
            if(tasta.Movex() == -1) 
                blickrichtung = "links";
            else if(tasta.Movex() == 1) 
                blickrichtung = "rechts";
            if(tasta.Movey() == -1) 
                blickrichtung = "hinten";
            else if(tasta.Movey() == 1) 
                blickrichtung = "vorne";
            
            // IN BEWEGUNG
            if(tasta.Movex() != 0 || tasta.Movey() != 0)
                going = true;
            else
                going = false;
                
            // WELCHER FUSS?
            if(going == true)
            {
                if(schritt == 1)
                {
                    schritt = oldschritt;
                }
                else if(schritt == 2)
                {
                    schritt = 3;
                    oldschritt = 2;
                }
                else if(schritt == 3)
                {
                    schritt = 2;
                    oldschritt = 3;
                }
            }
            else
            {
                schritt = 1;
            }
        }
        
        public void x_Berechnung()
        {
            if(feld[map][spieler_x + tasta.Movex()][spieler_y].begehbar())
            {
                spieler_x = spieler_x + tasta.Movex();
            }
        }
        
        public void y_Berechnung()
        {
            if(feld[map][spieler_x][spieler_y + tasta.Movey()].begehbar())
            {
                spieler_y = spieler_y + tasta.Movey();
            }
        }
        
        public void QuestlogÖffnen()
        {
            if(tasta.QuestlogOffen())
            {
                if(inventar_offen || rucksack_offen || questlog_offen)
                    questlog_offen = false;
                else
                    questlog_offen = true;
            }
        }
        
        public void InventarÖffnen()
        {
            if(tasta.InventarOffen())
            {
                if(inventar_offen || rucksack_offen || questlog_offen)
                    inventar_offen = false;
                else
                    inventar_offen = true;
            }
        }
        
        public void RucksackÖffnen()
        {
            if(tasta.RucksackOffen())
            {
                if(rucksack_offen || inventar_offen || questlog_offen)
                    rucksack_offen = false;
                else
                    rucksack_offen = true;
            }
        }
        
        public void Sleep(int milisec)
        {
            try { Thread.sleep(milisec); } 
            catch (InterruptedException e) {}
        }
        
        public int Zufallszahl(int min, int max)
        {
            int differenz = (max + 1) - min;
            Random zufall = new Random();
            return (min + (zufall.nextInt(differenz) - 1));
        } 
        
        public void Mapwechsel()
        {
            if(feld[map][spieler_x][spieler_y].istMapsprung() != 0)
            {
                map = feld[map][spieler_x][spieler_y].istMapsprung();
                Einstiegskoordinaten();
            }
        }
        
        public void MapCheat()
        {
            if(tasta.MapCheat() != 0)
            {
                map = map + tasta.MapCheat();
                Einstiegskoordinaten();
            }
        } 
        
        public void Einstiegskoordinaten()
        {
            if(map == 1)
            {
                if(oldmap == 1)
                {
                spieler_x = 5;
                spieler_y = 6;
                }
                else if(oldmap == 2)
                {
                spieler_x = 2;
                spieler_y = 9;
                }
                oldmap = 1;   
            }
            else if(map == 2)
            {
                if(oldmap == 1)
                {
                spieler_x = 13;
                spieler_y = 3;
                }
                else if(oldmap == 3)
                {
                spieler_x = 8;
                spieler_y = 9;
                }
                oldmap = 2;
            }
            else if(map == 3)
            {
                if(oldmap == 2)
                {
                spieler_x = 11;
                spieler_y = 5;
                }
                else if(oldmap == 4)
                {
                spieler_x = 6;
                spieler_y = 1;
                }
                oldmap = 3;
            }
            else if(map == 4)
            {
                if(oldmap == 3)
                {
                spieler_x = 6;
                spieler_y = 10;
                }
                else if(oldmap == 5)
                {
                spieler_x = 1;
                spieler_y = 8;
                }
                else if(oldmap == 6)
                {
                spieler_x = 3;
                spieler_y = 6;
                }
                else if(oldmap == 8)
                {
                spieler_x = 15;
                spieler_y = 9;
                }
                oldmap = 4;
            }
            else if(map == 5)
            {
                if(oldmap == 4)
                {
                spieler_x = 15;
                spieler_y = 8;
                }
                oldmap = 5;
            }
            else if(map == 6)
            {
                if(oldmap == 4)
                {
                spieler_x = 5;
                spieler_y = 14;
                }
                oldmap = 6;
            }
            else if(map == 7)
            {
                if(oldmap == 4)
                {
                spieler_x = 5;
                spieler_y = 14;
                }
                oldmap = 7;
            }
            else if(map == 8)
            {
                if(oldmap == 4)
                {
                spieler_x = 1;
                spieler_y = 21;
                }
                oldmap = 8;
            }
        }
        
        public void MenuBerechnen()
        {
            MausPosition();
            
            if((maus_x > 480 && maus_x < 605) && (maus_y > 375 && maus_y < 405))
            {
                map = 1;
                Maperzeugen();
                s.playSound(2);
                repaint();
            }
            else if((maus_x > 495 && maus_x < 590) && (maus_y > 507 && maus_y < 537))
            {
                credits = true;
                credits_count = 780;
                repaint();
            }
        }
        
        public void MausPosition()
        {
            maus_x = maus.Maus_X();
            maus_y = maus.Maus_Y();
            
            maus.RemoveMouse();
        }
        
        public void Maperzeugen()
        {
            for(int mapid = 1; mapid < 10; mapid++)
            if(mapid == 1)
            {
                for(int y=0; y<15; y++)
                {
                    for(int x=0; x<15; x++)
                    {
                        if((y<=1) || (y>=11) || (x<=0) || (x>=11))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=2) && (y<=3) && (x>=1) && (x<=7))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=5) && (y<=6) && (x>=1) && (x<=2))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=5) && (y<=6) && (x>=1) && (x<=2))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=6) && (y<=7) && (x>=5) && (x<=7))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=6) && (y<=8) && (x>=10))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else
                            feld[mapid][x][y].FeldAnlegen(true);                        
                    }
                }
                // SPRUNG FELDER ANLEGEN
                feld[mapid][2][10].Feldmarkieren(2);
                
                // NPC FELDER ANLEGEN
                    feld[mapid][3][6].NpcFreund(1, 1, false, 0);
            }
            else if(mapid == 2)
            {  
                for(int y=0; y<12; y++)
                {
                    for(int x=0; x<17; x++)
                    {
                        if((y<=1) || (y>=11) || (x<=0) || (x>=16))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y==2) && (x<=12))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y==2) && (x>=14))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=7) && (y<=9) && (x>=1) && (x<=4))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=5) && (y<=7) && (x>=7) && (x<=10))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else
                            feld[mapid][x][y].FeldAnlegen(true);                        
                    }
                }
                // SPRUNG FELDER ANLEGEN
                feld[mapid][13][2].Feldmarkieren(1);
                feld[mapid][8][10].Feldmarkieren(3);
                
                // NPC FELDER ANLEGEN
            }
            else if(mapid == 3)
            {  
                for(int y=0; y<10; y++)
                {
                    for(int x=0; x<17; x++)
                    {
                        if((y<=-1) || (y>=9) || (x<=0) || (x>=16))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y==0) && (x>=0) && (x<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y==0) && (x>=7) && (x<=16))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=3) && (y<=4) && (x>=2) && (x<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=3) && (y<=3) && (x>=9) && (x<=13))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=3) && (y<=4) && (x>=9) && (x<=10))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=3) && (y<=4) && (x>=12) && (x<=13))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=8) && (x>=10))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else
                            feld[mapid][x][y].FeldAnlegen(true);                        
                    }
                }
                // SPRUNG FELDER ANLEGEN
                feld[mapid][11][4].Feldmarkieren(2);
                feld[mapid][6][0].Feldmarkieren(4);
                
                // NPC FELDER ANLEGEN
                feld[mapid][11][5].NpcFreund(1, 2, false, 0);
                feld[mapid][12][5].NpcFreund(3, 3, true, 0);
                feld[mapid][3][5].NpcFreund(1, 4, true, 0);
            }
            else if(mapid == 4)
            {  
                for(int y=0; y<13; y++)
                {
                    for(int x=0; x<17; x++)
                    {
                        if((y<=3) || (y>=12) || (x<=-1) || (x>=17))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y==11) && (x>=0) && (x<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y==11) && (x>=7) && (x<=16))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x==0) && (y>=0) && (y<=7))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x==0) && (y>=9) && (y<=11))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=4) && (y>=1) && (y<=4))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=7) && (x<=8) && (y>=4) && (y<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=10) && (x<=10) && (y>=4) && (y<=4))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=11) && (x<=11) && (y>=4) && (y<=6))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=12) && (x<=15) && (y>=4) && (y<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=12) && (x<=12) && (y>=5) && (y<=6))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=14) && (x<=15) && (y>=5) && (y<=6))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=2) && (y>=5) && (y<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=4) && (x<=4) && (y>=5) && (y<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=16) && (x<=16) && (y>=1) && (y<=8))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=16) && (x<=16) && (y>=10) && (y<=12))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else
                            feld[mapid][x][y].FeldAnlegen(true);                        
                    }
                }
                // SPRUNG FELDER ANLEGEN
                feld[mapid][6][11].Feldmarkieren(3);
                feld[mapid][0][8].Feldmarkieren(5);
                feld[mapid][3][5].Feldmarkieren(6);
                feld[mapid][16][9].Feldmarkieren(8);
                
                // NPC FELDER ANLEGEN
                feld[mapid][6][10].NpcFreund(1, 5, false, 0);
                feld[mapid][5][10].NpcFreund(5, 6, true, 0);
                feld[mapid][9][7].NpcGegner(2, 100, true, 30, 40, 1, 0);
                feld[mapid][11][10].NpcGegner(2, 100, true, 200, 600, 3, 0);
                feld[mapid][14][10].NpcGegner(4, 100, true, 60, 20, 1, 0);
                feld[mapid][15][8].NpcGegner(4, 100, true, 35, 10, 1, 0);
                
            }
            else if(mapid == 5)
            {  
                for(int y=0; y<12; y++)
                {
                    for(int x=0; x<18; x++)
                    {
                        if((y<=1) || (y>=11) || (x<=0) || (x>=17))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x==16) && (y>=0) && (y<=7))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x==16) && (y>=9) && (y<=11))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=13) && (y==2))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=8) && (y==3))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=6) && (y==4))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=2) && (y==5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=4) && (x<=7) && (y>=6) && (y<=7))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else
                            feld[mapid][x][y].FeldAnlegen(true);                        
                    }
                }
                // SPRUNG FELDER ANLEGEN
                feld[mapid][16][8].Feldmarkieren(4);
                
                // NPC FELDER ANLEGEN
                feld[mapid][2][6].NpcFreund(6, 15, true, 0);
                
            }
            else if(mapid == 6)
            {  
                for(int y=0; y<22; y++)
                {
                    for(int x=0; x<12; x++)
                    {
                        if((y<=2) || (y>=21) || (x<=0) || (x>=11))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=5) && (y>=3) && (y<=3))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=1) && (y>=4) && (y<=4))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=9) && (x<=10) && (y>=3) && (y<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=6) && (y>=5) && (y<=5))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=3) && (y>=9) && (y<=10))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=6) && (x<=10) && (y>=11) && (y<=12))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=2) && (y>=14) && (y<=15))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=2) && (x<=2) && (y>=13) && (y<=13))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=9) && (x<=10) && (y>=14) && (y<=15))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else
                            feld[mapid][x][y].FeldAnlegen(true);                        
                    }
                }
                // SPRUNG FELDER ANLEGEN
                feld[mapid][5][15].Feldmarkieren(4);
                feld[mapid][6][15].Feldmarkieren(4);
                
                // NPC FELDER ANLEGEN
                feld[mapid][3][4].NpcFreund(7, 18, true, 0);
                feld[mapid][8][10].NpcFreund(8, 17, true, 0);
                feld[mapid][10][6].NpcFreund(1, 54, false, 0);
                
            }
            else if(mapid == 8)
            {  
                for(int y=0; y<30; y++)
                {
                    for(int x=0; x<30; x++)
                    {
                        if((y<=11) || (y>=26) || (x<=-1) || (x>=27))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=0) && (x<=0) && (y>=11) && (y<=19))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=0) && (x<=0) && (y>=22) && (y<=26))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=26) && (x<=26) && (y>=11) && (y<=23))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=26) && (x<=26) && (y>=26) && (y<=26))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=1) && (x<=5) && (y>=11) && (y<=17))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=4) && (x<=7) && (y>=22) && (y<=24))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=6) && (x<=13) && (y>=11) && (y<=15))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=14) && (x<=14) && (y>=11) && (y<=14))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=15) && (x<=15) && (y>=11) && (y<=13))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=16) && (x<=17) && (y>=11) && (y<=12))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=19) && (x<=26) && (y>=11) && (y<=22))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=14) && (x<=18) && (y>=18) && (y<=22))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=9) && (x<=9) && (y>=17) && (y<=18))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((x>=18) && (x<=18) && (y>=17) && (y<=17))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else
                            feld[mapid][x][y].FeldAnlegen(true);                        
                    }
                }
                // SPRUNG FELDER ANLEGEN
                feld[mapid][0][20].Feldmarkieren(4);
                feld[mapid][0][21].Feldmarkieren(4);
                feld[mapid][26][24].Feldmarkieren(9);
                feld[mapid][26][25].Feldmarkieren(9);
                
                // NPC FELDER ANLEGEN
                feld[mapid][18][12].NpcFreund(9, 7, true, 1);
                
            }
        }
        
        public void FelderErstellen()
        {
            for(int z=1; z<10; z++)
                {
                     for(int y=0; y<150; y++)
                     {
                         for(int x=0; x<150; x++)
                         {
                            feld[z][x][y] = new Feld(z, x, y);                            
                         }
                     }
                }
        }
        
        public void ItemsLaden()
        {
             /* int typ, int symbol, String name, int schadenmin, int schadenmax, int rüstung, int sellvalue, String qualität, int str, int agi, int sta, int intl)
             * typ Deklarierung:
             * 1: Schwert
             * 2: Zweihandschwert
             * 3: Axt
             * 4: Zweihandaxt
             * 5: Schild
             * 6: Brust
             * 7: Hose
             * 8: Schuhe
             * 9: Handschuhe
             * 10: Helm
             * 11: Ring
             * 12: Trank
             * 13: Questgegenstand
             * 14: Crap
             * 15: Dolch
             */
             item[0] = new Items(0, 0, "", 0, 0, 0, 0, "", 0, 0, 0, 0);
             item[1] = new Items(6, 1, "Bauernhemd", 0, 0, 2, 1, "Weiß", 0, 0, 0, 0);
             item[2] = new Items(7, 4, "Leinenhose", 0, 0, 3, 1, "Weiß", 0, 0, 0, 0);
             item[3] = new Items(8, 6, "Bauernstiefel", 0, 0, 3, 2, "Weiß", 0, 0, 0, 0);
 

ToNyXXL

Mitglied
Code:
}
        
        public void InventarLaden()
        {
            // 0: füße, 1: beine, 2: brust, 3: hände, 4: kopf, 5: finger, 6: rechte hand, 7: linke hand
            inventar[0] = 3;
            inventar[1] = 2;
            inventar[2] = 1;
            inventar[3] = 0;
            inventar[4] = 0;
            inventar[5] = 0;
            inventar[6] = 36;
            inventar[7] = 36;
        }
        
        public void RucksackLaden()
        {
            rucksack[0] = 0;
        }
        
        public void ItemHinzufügen(int itemid)
        {
            boolean item_hinzugefügt = false;
            
            for(int y=0; y<24; y++)
                if(rucksack[y] == itemid)
                {
                    r_anzahl[y]++;
                    item_hinzugefügt = true;
                }
          
            if(!item_hinzugefügt)
                for(int c=0; c<24; c++)
                    if(rucksack[c] == 0)
                    {
                        rucksack[c] = itemid;
                        r_anzahl[c]++;
                        item_hinzugefügt = true;
                        break;
                    }
        }
        
        public void Events()
        {
            if(event == 1)
            {
                if(!event_finished[event])
                {
                    if(tasta.Weiter())
                    {
                        indialog_temp = false;
                        indialog = true;
                        feld[8][18][12].NpcFreund(9, 8, true, 2);
                        tasta.RemoveMoving();
                    }
                }
            }
            if(event == 2)
            {
                if(!event_finished[event])
                {
                    feld[8][18][12].NPC_Entfernen();
                    feld[8][18][12].NpcGegner(9, 5, true, 30, 90, 2, 3);
                }
            }
            if(event == 3)
            {
                if(!event_finished[event])
                {
                        indialog_temp = false;
                        indialog = true;
                        feld[8][18][12].NPC_Entfernen();
                        feld[8][18][12].NpcFreund(9, 9, true, 4);
                }
            }
            if(event == 4)
            {
                if(!event_finished[event])
                {
                    if(tasta.Weiter())
                    {
                        indialog_temp = false;
                        indialog = true;
                        feld[8][18][12].NPC_Entfernen();
                        feld[8][18][12].NpcFreund(9, 10, true, 5);
                        questid++;
                        questname[questid] = "Das verlorene Schild";
                        questtext[questid] = text.gibText(11);
                    }
                }
            }
            if(event == 5)
            {
                if(!event_finished[event])
                {
                    if(tasta.Weiter())
                    {
                        feld[8][18][12].NPC_Entfernen();
                        feld[8][18][12].NpcFreund(9, 12, true, 0);
                    }
                }
            }
            if(event == 6)
            {
                if(true)
                {
                }
            }
        }      
}
 

Marco13

Top Contributor
Achtung, Achtung! Ganz wichtig:
rucksack = new int[66];
muss unbedingt geändert werden in
rucksack = new int[64];
Die Anzahl der Rucksack-ints muss eine Zweierpotenz sein!

Naja - Spaß beiseite. Das ist schon richtiger Quäl-Kot. Überleg' mal, ob es nicht sinnvoll wäre, Klassen zu machen, wie zum Beispiel:
Rucksack
Inventar
Dialog
Kartenfenster
Kampffenster
Quest
Usw.

Im Moment wird bei dir sehr viel in der paint-Methode gemacht. Die KÖNNTE dann ZUM BEISPIEL in Zukunft so aussehen:
Code:
paint
{
    if(questlog_offen) quest.paint(g);
    if(inventar_offen) inventar.paint(g);
    ...
}

Das auseinanderklamüsern der Variablen (was gehört zum Questlog, was gehört zum Rucksack, und die brennende Frage: Wo hin gehört "tasta") wird aber vmtl. dir überlassen bleiben...
 

ToNyXXL

Mitglied
Code:
paint
{
    if(questlog_offen) quest.paint(g);
    if(inventar_offen) inventar.paint(g);
    ...
}

danke dir, diese antwort bringt mich schon weiter!
also versteh ich das so, das in deinem Beispiel inventar zur Klasse Inventar gehört, die ein extends JPanel hat und dann dort die paint aufgerufen wird, die das entsprechende zeichnet?
 

Marco13

Top Contributor
Nicht unbedingt (ich habe deine Programm nicht komplett nachvollzogen, weil es (wie ich durch den einleitenden Scherz andeuten wollte) nicht besonders nachvollziehbar IST.

Die Klassen würden nicht von JPanel erben, sondern nur eine Methode anbieten, die sie zeichnet. Die Muss dann auch nicht unbedingt "paint" heißen, sondern könnte auch "zeichneMich" heißen.

Also:

Du könntest dir überlegen, wie du die "Dinge", die in deinem Programm auftauchen, sinnvoll in Klassen aufteilen könntest. (Eine Einteilung, die beim ersten Überfliegen sinnvoll erschien, hatte ich ja gepostet). Zum Beispiel könnte es eine Klasse "Inventar" geben.
Code:
class Inventar
{
    ...
}


Dann überlegst du dir, welche Eigenschaften diese "Dinge" haben. Du überlegst also, welche Variablen in den Klassen vorkommen müssen. Das "Inventar" hat irgendwelche Inhalte. ("Messer", "Zaubertrank"...). Diese Inhalten könnten z.B. alle von einer abstraken Klasse "Item" erben. Dann hätte das Inventar z.B. eine ArrayList von Items
Code:
class Inventar
{
    private ArrayList<Item> items = new ArrayList<Item>();
}


Dann überlegst du dir, was man mit dem Inventar alles machen kann. Naja - erstmal kann man Items hinzufügen, entfernen, vielleicht einen Gesamtwert berechnen usw.
Code:
class Inventar
{
    ...
    public void addItem(Item item) { items.add(item; }

    public Item getItem(int index) { return items.get(index); }

    public float getGesamtwert()
    {  
        float gesamtwert = 0;
        for (int i=0; i<items.size(); i++) 
        { 
             gesamtwert += items.get(i).getWert();
        }
        return gesamtwert;
    }
}


Dann kannst du überlegen, was passieren soll, wenn das Inventar gezeichnet wird:
Code:
class Inventar
{
    ....
    public void zeichnenAuf(Graphics g)
    {
        // Zeichne z.B. ein Rechtecks-Raster in den Hintergrund
        g.drawLine(...);
        ...
        g.drawLine(...);

        // Zeichne alle Items
        for (int i=0; i<items.size(); i++) 
        { 
             items.get(i).zeichne(g);
        }
    }
        
}


Dann kannst du überlegen, die du ein Inventar in der paint-Methode auf dein Haupt-Panel zeichnen kannst.
Code:
class HauptPanel extends JPanel
{
    private Inventar inventar = new Inventar();

    public void paintComponent(Graphics g)
    {
        if (inventarAnzeigen) inventar.zeichnenAuf(g);
        ...
    }

Aber vielleicht ist dir aufgefallen, dass dort überall das Wort "überlegen" vorkommt. Also tipp' das nicht einfach alles ab, und sag dann, dass es nicht funktioniert, sondern überlege, wie es sein muss, damit es gut funktioniert.

Und überlege, ganz nebenbei, und wenn dir dann noch langweilig ist, wie du es erreichen kannst, dass es in Zukunft einfacher wird, neue Maps hinzuzufügen. Diese Blöcke mit
Code:
           else if(map == 5)
            {
                if(oldmap == 4)
                {
                spieler_x = 15;
                spieler_y = 8;
und
Code:
         if(mapid == 1)
            {
                for(int y=0; y<15; y++)
                {
                    for(int x=0; x<15; x++)
                    {
                        if((y<=1) || (y>=11) || (x<=0) || (x>=11))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=2) && (y<=3) && (x>=1) && (x<=7))
                            feld[mapid][x][y].FeldAnlegen(false);
                        else if((y>=5) && (y<=6) && (x>=1) && (x<=2))
                            feld
sind HÄSSLICH, fast nicht wartbar, und schrecklich schlecht erweiterbar. Vielleicht wäre es nicht verkehrt, wenn das ganze von einer Klasse "MapFactory" gemacht wird, die Objekte der Klasse "GameMap" erstellt... aber das mußt du dir überlegen.
 

ToNyXXL

Mitglied
Danke für deine sehr tolle Hilfe, das is echt klasse!
Ich werde mein Programm nochmal überdenken, und sicher einiges so vereinfachen so wie du es vorgeschlagen hast. Objektorientierte Programmierung ist am Anfang gar nicht so einfach, wenn man vorher nur mit PHP etc programmiert hat =)

Allerdings hab ich jetzt alles in ein JPanel gepackt und ne Überklasse erstellt, nur das ruckeln bleibt!
 

André Uhres

Top Contributor
Code:
/*
 * GamePanel.java
 */
import java.awt.*;
import javax.swing.*;
class GamePanel extends JPanel{
    private final Start start;
    public GamePanel(Start start) {
        this.start = start;
    }
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (this.start.map == 0) {
            this.start.MenüPaint(g);
        }  else {
            this.start.istTod();
            if (this.start.tod) {
                this.start.TodPaint(g);
            }  else {
                this.start.Kämpfen();
                this.start.LevelUp();
                this.start.HP_Berechnen();
                this.start.Mana_Berechnen();
                this.start.QuestlogÖffnen();
                this.start.InventarÖffnen();
                this.start.RucksackÖffnen();
                if (!this.start.infight && !this.start.indialog && !this.start.inventar_offen && !this.start.rucksack_offen) {
                    this.start.HeldAusrichtung();
                    this.start.x_Berechnung();
                    this.start.y_Berechnung();
                    this.start.MapCheat();
                    this.start.Mapwechsel();
                    this.start.Pos_Berechnung();
                    g.fillRect(200, 200, 824, 568);
                    g.drawImage(this.start.mapimg[this.start.map], (220 - this.start.Rect_x * this.start.feldgröße), (220 - this.start.Rect_y * this.start.feldgröße), this.start.mapimg[this.start.map].getWidth(this), this.start.mapimg[this.start.map].getHeight(this), this);
                    for (int y = 0; y<50; y++) {
                        for (int x = 0; x<50; x++) {
                            if ((this.start.Rect_y >= 0) && (this.start.Rect_y <= 100) && (this.start.Rect_x >= 0) && (this.start.Rect_x <= 100)) {
                                // NPC
                                if (this.start.feld[this.start.map][this.start.Rect_x][this.start.Rect_y].NpcaufFeld()  != 0) {
                                    if ((this.start.Rect_x == this.start.spieler_x) && (this.start.spieler_y == this.start.Rect_y)) {
                                        if (this.start.feld[this.start.map][this.start.Rect_x][this.start.Rect_y].gibGesinnung()  == 0) {
                                            this.start.infight = true;
                                            this.start.gegner_x_tmp = this.start.Rect_x;
                                            this.start.gegner_y_tmp = this.start.Rect_y;
                                        }  else {
                                            if (this.start.feld[this.start.map][this.start.Rect_x][this.start.Rect_y].gibDialog()  != 0) {
                                                if (!this.start.indialog_temp)
                                                    this.start.indialog = true;
                                            }
                                            this.start.npc_x_tmp = this.start.Rect_x;
                                            this.start.npc_y_tmp = this.start.Rect_y;
                                        }
                                    }
                                    int npc_width = this.start.npc[this.start.feld[this.start.map][this.start.Rect_x][this.start.Rect_y].NpcaufFeld()].getWidth(this);
                                    int npc_height = this.start.npc[this.start.feld[this.start.map][this.start.Rect_x][this.start.Rect_y].NpcaufFeld()].getHeight(this);
                                    g.drawImage(this.start.npc[this.start.feld[this.start.map][this.start.Rect_x][this.start.Rect_y].NpcaufFeld()], (197 + x * this.start.feldgröße), (200 - (npc_height/3) + y * this.start.feldgröße), npc_width, npc_height, this);
                                }
                                if ((this.start.spieler_x == this.start.npc_x_tmp) && (this.start.spieler_y == this.start.npc_y_tmp));
                                else {
                                    this.start.indialog_temp = false;
                                    this.start.event = 0;
                                }
                                if ((this.start.Rect_x == this.start.spieler_x) && (this.start.spieler_y == this.start.Rect_y)) {
                                    // SPIELER
                                    if (this.start.blickrichtung == "vorne")
                                        g.drawImage(this.start.hero_v[this.start.schritt], 600, 473, 20, 27, this);
                                    if (this.start.blickrichtung == "hinten")
                                        g.drawImage(this.start.hero_h[this.start.schritt], 600, 473, 20, 27, this);
                                    if (this.start.blickrichtung == "links")
                                        g.drawImage(this.start.hero_l[this.start.schritt], 600, 473, 20, 27, this);
                                    if (this.start.blickrichtung == "rechts")
                                        g.drawImage(this.start.hero_r[this.start.schritt], 600, 473, 20, 27, this);
                                }
                            }
                            this.start.Rect_x++;
                        }
                        this.start.Rect_x = this.start.pos_x;
                        this.start.Rect_y++;
                    }
                    this.start.Rect_y = this.start.pos_y;
                }
                // VORDERGRUND EBENE ZEICHNEN
                g.drawImage(this.start.mapimg_v[this.start.map], (220 - this.start.Rect_x * this.start.feldgröße), (220 - this.start.Rect_y * this.start.feldgröße), this.start.mapimg[this.start.map].getWidth(this), this.start.mapimg[this.start.map].getHeight(this), this);
                if (this.start.questlog_offen) {
                    if (this.start.tasta.Weiter()) {
                        this.start.questlog_offen = false;
                        this.start.tasta.RemoveMoving();
                    }
                    g.setColor(Color.blue);
                    g.fillRect(200,200,1024,1000);
                    g.setColor(Color.red);
                    int text_height2 = 0;
                    for (int d = 1; d < (this.start.questid + 1); d++) {
                        g.drawString(this.start.questname[d], 370, 200 + 30*d + text_height2);
                        boolean stringende = false;
                        int index = 0;
                        int anfangsindex = 1;
                        int text_height = 0;
                        String der_text;
                        while (!stringende) {
                            anfangsindex = index + 1;
                            index = this.start.questtext[d].indexOf("#", anfangsindex);
                            der_text = this.start.questtext[d].substring(anfangsindex, index);
                            if(der_text.endsWith("+")) {
                                stringende = true;
                                text_height2 = text_height;
                                break;
                            }
                            g.drawString(der_text, 370, 215 + 30*d + text_height);
                            text_height = text_height + 15;
                        }
                    }
                }
                if (this.start.inventar_offen) {
                    if (this.start.tasta.Weiter()) {
                        this.start.inventar_offen = false;
                        this.start.tasta.RemoveMoving();
                    }
                    g.setColor(Color.blue);
                    g.fillRect(200,200,1024,1000);
                    g.setColor(Color.red);
                    for (int c = 0; c < 8; c++) {
                        g.drawImage(this.start.itemimg[this.start.item[this.start.inventar[c]].SymbolID()], 300, 210 + 70*c, 64, 64, this);
                        g.drawString(this.start.item[this.start.inventar[c]].Name(), 370, 250 + 70*c);
                    }
                }
                if (this.start.rucksack_offen) {
                    if (this.start.tasta.Weiter()) {
                        this.start.rucksack_offen = false;
                        this.start.tasta.RemoveMoving();
                    }
                    g.setColor(Color.blue);
                    g.fillRect(200,200,1024,1000);
                    g.setColor(Color.red);
                    for (int c = 0; c < 24; c++) {
                        g.drawImage(this.start.itemimg[this.start.item[this.start.rucksack[c]].SymbolID()], 300, 210 + 70*c, 64, 64, this);
                        g.drawString(this.start.item[this.start.rucksack[c]].Name(), 370, 250 + 70*c);
                        if (this.start.rucksack[c] != 0 && this.start.r_anzahl[c] > 1)
                            g.drawString("" + this.start.r_anzahl[c], 305, 268 + 70*c);
                    }
                }
                
                if (this.start.indialog) {
                    if (this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].NpcaufFeld()  != 1)
                        this.start.blickrichtung = "hinten";
                    if (this.start.tasta.Weiter()) {
                        this.start.indialog_temp = true;
                        this.start.indialog = false;
                        if (this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].Respawnable()  == false)
                            this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].NPC_Entfernen();
                    }
                    g.setColor(Color.blue);
                    g.fillRect(+200,+200,1024,1000);
                    g.setColor(Color.red);
                    boolean stringende = false;
                    int index = 0;
                    int anfangsindex = 1;
                    int text_height = 300;
                    int text_width = 0;
                    int text_rows = 0;
                    String der_text;
                    while (!stringende) {
                        anfangsindex = index + 1;
                        index = this.start.text.gibText(this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].gibDialog()).indexOf("#", anfangsindex);
                        der_text = this.start.text.gibText(this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].gibDialog()).substring(anfangsindex, index);
                        if(der_text.endsWith("+")) {
                            stringende = true;
                            break;
                        }
                        text_rows++;
                    }
                    stringende = false;
                    index = 0;
                    text_height = 770 - (text_rows *20);
                    g.setColor(Color.green);
                    g.fillRect(250, (750 - (text_rows *20)), 724, (text_rows * 20 + 30));
                    g.setColor(Color.red);
                    while (!stringende) {
                        anfangsindex = index + 1;
                        index = this.start.text.gibText(this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].gibDialog()).indexOf("#", anfangsindex);
                        der_text = this.start.text.gibText(this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].gibDialog()).substring(anfangsindex, index);
                        if(der_text.endsWith("+")) {
                            stringende = true;
                            break;
                        }
                        text_width = (g.getFontMetrics().stringWidth(der_text) / 2);
                        g.drawString(der_text, (610 - text_width), text_height);
                        text_height = text_height + 20;
                    }
                    // EVENTABFRAGE
                    if (this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].gibEvent()  != 0 && this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].gibGesinnung()  == 1) {
                        this.start.event = this.start.feld[this.start.map][this.start.npc_x_tmp][this.start.npc_y_tmp].gibEvent();
                        this.start.Events();
                    }
                }
                if ((this.start.infight) && (!this.start.infight_temp)) {
                    g.setColor(Color.blue);
                    g.fillRect(+200,+200,1024,1000);
                    g.setColor(Color.red);
                    g.drawString("Ungläubiger! Meine geschärfte Klinge wird deinen Leib in tausend Stücke zerteilen!!", 400,400);
                    g.drawString("Du hast " + this.start.make_dmg + " Schaden gemacht und " + this.start.become_dmg + " verloren",250, 300);
                    if (this.start.oom == true)
                        g.drawString("Für den aktuellen Zauber hast du leider nicht genug Mana!",250, 330);
                    g.drawString("Gegner Level: " + this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibLevel() + " ||| Gegner HP: " + this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibHP() + "/" + this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibMaxHP() + " ||| Gegner Mana: " + this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibMana() + "/" + this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibMaxMana() + "", 300,450);
                    double tmp_hp2 = this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibHP() / this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibMaxHP() * 200;
                    double tmp_m2 = this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibMana() / this.start.feld[this.start.map][this.start.gegner_x_tmp][this.start.gegner_y_tmp].gibMaxMana() * 200;
                    g.fillRect(300, 500, ((int) tmp_hp2), 15);
                    g.fillRect(300, 600, ((int) tmp_m2), 15);
                    g.setColor(Color.black);
                    g.drawRect(300, 500, 200, 15);
                    g.drawRect(300, 600, 200, 15);
                    g.setColor(Color.red);
                }  else
                    this.start.infight_temp = false;
                this.start.InterfacePaint(g);
                this.start.tasta.RemoveMoving();
            }
        }
    }
}
 

ToNyXXL

Mitglied
Boah danke für die Arbeit das is echt klasse wie geil einem hier geholfen wird, das is nicht normal!

ich hab jetzt deinen code (jetzt weiß ich endlich wie ein objekt auf die überklassen methoden zugreift *freu*) übernommen und in die klasse start folgendes geschrieben:
Code:
    //KONSTRUKTOR
    GamePanel panel = new GamePanel(this);

    // PAINT
    public void paint(Graphics g)
    {          
        panel.paint(g);
    }
jetz wirft er mir allerdings beim starten der anwendung folgende exception:
Code:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
 

Wildcard

Top Contributor
Poste bitte den Rest der Fehlermeldung, sowie die verursachende Codezeile (steht in der Exception).
 

ToNyXXL

Mitglied
Ok alles klar:
Code:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at Start.paint(Start.java:276)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:738)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:683)
	at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:663)
	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

und wenn ich das richtig verstehe ist die betroffende zeile folgende:
Code:
    public void paint(Graphics g)
    {          
        panel.paint(g);
    }

übrigens, die anwendung bleibt transparent, also ohne hintergrund und nichts geht.
 

Wildcard

Top Contributor
Wenn das Zeile 276 ist
Code:
panel.paint(g);
dann ist panel bei dir null.
 

ToNyXXL

Mitglied
Ahhh ich danke dir!
ich hatte das
Code:
add(panel);
vergessen!!

nun wird das bild angezeigt, mouseListener geht zwar noch net aba das problem krich ich jetz auch selber hin! danke euch vielmals für die nachhilfe stunde =)
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
N Doppelbufferung löst 3 errors aus! AWT, Swing, JavaFX & SWT 3
MiMa Fonts, Icons, Bilder in JavaFX Anwendung AWT, Swing, JavaFX & SWT 5
F Bilder zu ausführbarer Jar-Datei hinzufügen AWT, Swing, JavaFX & SWT 5
G JPanel per Drag and Drop JButtons und Bilder ablegen AWT, Swing, JavaFX & SWT 1
G JPanel mit JButtons und Bilder AWT, Swing, JavaFX & SWT 5
Linjutsu Den Inhalten aus einer ArrayList Bilder zuweisen (Kartenspiel) AWT, Swing, JavaFX & SWT 8
M Swing Bilder in Swing anzeigen AWT, Swing, JavaFX & SWT 9
S AffineTranformation Bilder verschwinden von Anzeige bei Pan, Zoom AWT, Swing, JavaFX & SWT 6
G Bilder in javafx Project AWT, Swing, JavaFX & SWT 11
N Bilder auf Button einfügen und mehrmals ändern (ein Button, mehrere ActionListener) AWT, Swing, JavaFX & SWT 2
N eclipse Java, bilder benutzten Funktioniert nicht AWT, Swing, JavaFX & SWT 6
Kirby.exe Bilder in GUI einfügen AWT, Swing, JavaFX & SWT 8
T Bilder bei einem JFrame einfügen AWT, Swing, JavaFX & SWT 4
K JLabel mit Bilder im nicht initialisierten JPanel hinzufügen AWT, Swing, JavaFX & SWT 5
L Bilder werden in exportierter Datei nicht geladen AWT, Swing, JavaFX & SWT 6
C Bilder so einbinden, dass sie sich ändern AWT, Swing, JavaFX & SWT 6
J Bilder aus dem SceneBuilder werden in der Jar nicht dargestellt AWT, Swing, JavaFX & SWT 4
TheWhiteShadow JavaFX Bilder werden ungewollt Skaliert AWT, Swing, JavaFX & SWT 1
B JavaFX Bilder in einem Gewissen bereich halten AWT, Swing, JavaFX & SWT 1
J Bilder proportional verkleiner AWT, Swing, JavaFX & SWT 12
E Bilder skalieren AWT, Swing, JavaFX & SWT 4
DaCrazyJavaExpert Swing Bilder überlagern AWT, Swing, JavaFX & SWT 19
A Bilder als Hintergrund AWT, Swing, JavaFX & SWT 2
@SupressWarnings() JavaFX Bilder in executable jar laden AWT, Swing, JavaFX & SWT 5
Sugan JavaFX Bilder drucken AWT, Swing, JavaFX & SWT 0
K JPanel Bilder bei Windows nicht darstellbar AWT, Swing, JavaFX & SWT 6
Sugan Java FX Verzeichnisüberwachung -> Bilder auf GUI anzeigen AWT, Swing, JavaFX & SWT 4
E AWT Bilder als "Array" abspeichern. AWT, Swing, JavaFX & SWT 4
MrSnake Bilder aus Unterordner einfügen AWT, Swing, JavaFX & SWT 2
I 2D-Grafik Bilder Eingefügt, button jetzt im Hintergrund AWT, Swing, JavaFX & SWT 2
C SWT Treeview mit Bilder im Label verändert Expanded Icon AWT, Swing, JavaFX & SWT 1
M Swing JTextPane, Bilder und Text-flow AWT, Swing, JavaFX & SWT 2
A Mit dem Scene Builder eine Collage erstellen (Bilder beziehen aus Flickr) AWT, Swing, JavaFX & SWT 1
thet1983 JTable Bilder AWT, Swing, JavaFX & SWT 6
GenerationLost Bilder an bestimmten Platz einfügen/Objekte visualisieren AWT, Swing, JavaFX & SWT 1
F Bilder in jFrame einfügen AWT, Swing, JavaFX & SWT 3
J Bilder als Variable an einem Objekt speichern AWT, Swing, JavaFX & SWT 3
I Swing Bilder werden nach Export nicht angezeigt AWT, Swing, JavaFX & SWT 1
D 2D-Grafik Bilder anzeigen AWT, Swing, JavaFX & SWT 4
J Bilder auf JPanel (im JScrollPane) nacheinander laden AWT, Swing, JavaFX & SWT 0
vodkaz JFrame,Bilder und Zeitverzögerung AWT, Swing, JavaFX & SWT 2
A Swing Bilder werden nicht angezeigt AWT, Swing, JavaFX & SWT 3
I SWT Bilder, bzw. ein einzelnes Bild AWT, Swing, JavaFX & SWT 6
M Bilder zeichnen, NullPointer Exception AWT, Swing, JavaFX & SWT 3
Xbody 2D-Grafik JavaFX Bilder transformieren AWT, Swing, JavaFX & SWT 2
C 2D-Grafik Steganographie - Verschlüsselung von Dateien in Bildern - Bilder zeigen schwarze Rechtecke AWT, Swing, JavaFX & SWT 13
P Durch Bilder Scrollen AWT, Swing, JavaFX & SWT 2
F Bilder werden nicht in's Array geladen AWT, Swing, JavaFX & SWT 4
K Bilder übereinanderlegen AWT, Swing, JavaFX & SWT 11
windl Querstreifen beim Bilder malen und anpassen an neue CPU AWT, Swing, JavaFX & SWT 12
V Fertige Komponente zum Anzeigen mehrerer Bilder AWT, Swing, JavaFX & SWT 5
Karuka 2D-Grafik Bilder in GridLayout einfügen AWT, Swing, JavaFX & SWT 7
J Bilder in ausführbare jar einbinden AWT, Swing, JavaFX & SWT 7
J Swing Bilder anzeigen in Gridlayout AWT, Swing, JavaFX & SWT 11
H 2D-Grafik Bilder laden ist nicht zuverlässig AWT, Swing, JavaFX & SWT 3
F Bilder ineinander kopieren AWT, Swing, JavaFX & SWT 3
P Bilder verkleinern AWT, Swing, JavaFX & SWT 2
C SWT Mehrere Bilder in GUI laden AWT, Swing, JavaFX & SWT 5
Furtano AWT Skalierung mehrerer Bilder / Histogramme im Fenster AWT, Swing, JavaFX & SWT 4
Furtano AWT mehrere Bilder in einen Frame zeichnen + Layout Manager AWT, Swing, JavaFX & SWT 10
T 2D-Grafik Statisches Hintergrundbild, dynamische Bilder drüber AWT, Swing, JavaFX & SWT 2
C Zwei Bilder übereinander legen AWT, Swing, JavaFX & SWT 1
L [SWT] Daten und Bilder drucken AWT, Swing, JavaFX & SWT 2
S Flickr Bilder in Gui Oberfläche AWT, Swing, JavaFX & SWT 21
L Bilder im JPanel als Hintergrund - Swing AWT, Swing, JavaFX & SWT 2
K Bilder nacheinander einfügen AWT, Swing, JavaFX & SWT 3
H Bilder auf Buttons per Klick tauschen ( Puzzle ) AWT, Swing, JavaFX & SWT 8
H Bilder in Array zufällig anordnen AWT, Swing, JavaFX & SWT 4
P 2D-Grafik Viele Bilder zu einem Video AWT, Swing, JavaFX & SWT 3
J Vergleicher zweier Bilder AWT, Swing, JavaFX & SWT 2
C zwei Bilder nacheinander anzeigen AWT, Swing, JavaFX & SWT 2
L Swing Bilder über andere Bilder laden AWT, Swing, JavaFX & SWT 3
J Bilder überlappen AWT, Swing, JavaFX & SWT 18
P Bilder werden nach Änderung nicht angezeigt AWT, Swing, JavaFX & SWT 15
3 2D-Grafik Rechtecke auf Bilder legen und auslesen AWT, Swing, JavaFX & SWT 4
M Mehrere Bilder auf einmal anzeigen AWT, Swing, JavaFX & SWT 9
P Swing html mit bilder drin AWT, Swing, JavaFX & SWT 12
F Nicht alle Bilder werden angezeigt AWT, Swing, JavaFX & SWT 2
E Bilder auf JFrame AWT, Swing, JavaFX & SWT 7
R Bilder über URL einfügen AWT, Swing, JavaFX & SWT 4
F Applet zeigt Bilder nicht an AWT, Swing, JavaFX & SWT 5
M FileChooser Bilder auswählen AWT, Swing, JavaFX & SWT 8
G Swing Bilder zeichnen AWT, Swing, JavaFX & SWT 28
L Swing Bilder im Icons-Ordner AWT, Swing, JavaFX & SWT 4
U Bilder in Jar werden nicht gefunden AWT, Swing, JavaFX & SWT 5
S SWT Canvas: Flackernde Bilder AWT, Swing, JavaFX & SWT 3
A Bilder vergleichen AWT, Swing, JavaFX & SWT 4
E Swing JTextPane Inhalt(Text und Bilder) als HTML text bekommen AWT, Swing, JavaFX & SWT 3
E AWT Bilder und Java AWT, Swing, JavaFX & SWT 11
P Bilder einfügen AWT, Swing, JavaFX & SWT 4
D Swing JEditorPane mit HTML aber ohne Bilder AWT, Swing, JavaFX & SWT 3
S Swing Kleine Bilder in Panel einfügen AWT, Swing, JavaFX & SWT 13
A AWT Bilder als Link verwenden? AWT, Swing, JavaFX & SWT 11
T SWT Wie Bilder aus JAR-Dateien einbinden? AWT, Swing, JavaFX & SWT 12
S Bilder aus der Google Book Search API auslesen AWT, Swing, JavaFX & SWT 3
J Bilder in JScrollPane zentrieren AWT, Swing, JavaFX & SWT 5
M Bilder in einem Textfeld darstellen AWT, Swing, JavaFX & SWT 2
N Bilder aus Infos generieren lassen. Welches Framework? AWT, Swing, JavaFX & SWT 8
A SWT Bilder resizen AWT, Swing, JavaFX & SWT 9
A Swing Bilder in JFrame einfügen AWT, Swing, JavaFX & SWT 2

Ähnliche Java Themen

Neue Themen


Oben