Skip to content
Snippets Groups Projects
Commit 3bc6e05f authored by Torbjørn Antonsen's avatar Torbjørn Antonsen
Browse files

Added beginnings of GUI and pictures for cards

parent 2a8f9a82
No related branches found
No related tags found
1 merge request!3Feat/gui
Showing
with 59 additions and 6 deletions
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="CheckStyle-IDEA-Module" serialisationVersion="2">
<option name="activeLocationsIds" />
</component>
</module>
\ No newline at end of file
package edu.ntnu.idatt2001; package edu.ntnu.idatt2001;
public class Main { import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Hello world!"); launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Stage stage = new Stage();
Group root = new Group();
Color DARKGRAY = Color.rgb(54, 69, 79).deriveColor(0.0, 1.0, 0.4, 1.0);
Scene scene = new Scene(root, DARKGRAY);
Image card = new Image("01c.png");
ImageView imageView = new ImageView(card);
imageView.setY(400.0);
imageView.setX(400.0);
String icon1 = "card_icon.png";
Image icon = new Image(icon1);
root.getChildren().add(imageView);
stage.setScene(scene);
stage.setTitle("Card Game");
stage.getIcons().add(icon);
stage.show();
}
@Override
public void init() throws Exception {
super.init();
}
@Override
public void stop() throws Exception{
super.stop();
} }
} }
\ No newline at end of file
...@@ -12,6 +12,7 @@ public class PlayingCard { ...@@ -12,6 +12,7 @@ public class PlayingCard {
private final char suit; // 'S'=spade, 'H'=heart, 'D'=diamonds, 'C'=clubs private final char suit; // 'S'=spade, 'H'=heart, 'D'=diamonds, 'C'=clubs
private final int face; // a number between 1 and 13 private final int face; // a number between 1 and 13
private final String imagePath;
/** /**
* Creates an instance of a PlayingCard with a given suit and face. * Creates an instance of a PlayingCard with a given suit and face.
...@@ -23,6 +24,7 @@ public class PlayingCard { ...@@ -23,6 +24,7 @@ public class PlayingCard {
public PlayingCard(char suit, int face) { public PlayingCard(char suit, int face) {
this.suit = suit; this.suit = suit;
this.face = face; this.face = face;
this.imagePath = face + suit + ".png";
} }
/** /**
...@@ -32,7 +34,7 @@ public class PlayingCard { ...@@ -32,7 +34,7 @@ public class PlayingCard {
* @return the suit and face of the card as a string * @return the suit and face of the card as a string
*/ */
public String getAsString() { public String getAsString() {
return String.format("%s%s", suit, face); return String.format("%s%s", this.suit, this.face);
} }
/** /**
...@@ -42,7 +44,7 @@ public class PlayingCard { ...@@ -42,7 +44,7 @@ public class PlayingCard {
* @return the suit of the card * @return the suit of the card
*/ */
public char getSuit() { public char getSuit() {
return suit; return this.suit;
} }
/** /**
...@@ -51,6 +53,10 @@ public class PlayingCard { ...@@ -51,6 +53,10 @@ public class PlayingCard {
* @return the face of the card * @return the face of the card
*/ */
public int getFace() { public int getFace() {
return face; return this.face;
}
public String getImagePath() {
return this.imagePath;
} }
} }
\ No newline at end of file
src/main/resources/01c.png

41.5 KiB

src/main/resources/01d.png

35.9 KiB

src/main/resources/01h.png

43.1 KiB

src/main/resources/01s.png

59.6 KiB

src/main/resources/02c.png

23 KiB

src/main/resources/02d.png

19.4 KiB

src/main/resources/02h.png

19.7 KiB

src/main/resources/02s.png

21.4 KiB

src/main/resources/03c.png

28.5 KiB

src/main/resources/03d.png

23.7 KiB

src/main/resources/03h.png

24.2 KiB

src/main/resources/03s.png

26.3 KiB

src/main/resources/04c.png

28 KiB

src/main/resources/04d.png

23.6 KiB

src/main/resources/04h.png

24.1 KiB

src/main/resources/04s.png

25.8 KiB

src/main/resources/05c.png

34 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment