BlueJ Wie programmiere ich das?
Hallo zusammen, ich habe mir vorgenommen ein Cardgame, ähnlich wie dieses TGC von Genshin Impact zu erstellen. (Natürlich in einer kleineren simpleren Variante).
ich verwende in BlueJ eine von der Schule gestellt Basis Bibliothek.
Nun möchte ich dass man in einem extra Menü (Klasse: Kartensammlung) seine Karten die man nutzen möchte auswählen kann und die dann in der Klasse: Arena (Der Ort wo das Spiel stattfindet) erscheinen.
Ich habe aber keinen Schimmer wie es geht :/ Ich habe bereits versucht jede Karte mit der Variable: Auswahl einen Wert zuzuteilen und diesen dann mit If(…){} abzufragen, ohne Erfolg.
Könnte mir jemand dabei Helfen? Ich kann den Code leider nicht hochladen, da ich diesen Text hier am Handy schreibe. Aber wenn jemand sich da auskennt, würde ich mich sehr freuen. LG
(Dass ist das erste mal das ich Gute Frage.de verwende, also seid nicht zu streng mit mir, wenn ich was falsch gemacht haben sollte.)
I guess it’s the basicUTF8151026.jar.
You need a class that can describe/represent a card. For the selection menu, you can create an array that will then display all the cards that are available.
Visually, the cards could be displayed by means of buttons (Buttons) are shown. So you use a loop over the array and place a single entry Button and add it to the graphical surface. Each button will also be equipped with a Buttons in which the card associated with the button is inserted into a new array (or a list).
This is indicated as follows:
The setzebutton-Method is passed an anonymous function. This can remember the values from the current context. At the push of a button, it is executed and can insert the card object that it has noticed in its definition into the array that stores the selected cards.
If the player decides to start the game (e.g. by clicking on a start button), you can start a new game Arena- Create object and pass the selected cards. Either directly via the constructor or via a setter method.
Example: