-
Notifications
You must be signed in to change notification settings - Fork 0
@ksiek127/rpg 84 display objects on screen #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f909673
97168b4
eb85cb5
b5a0c8a
b69f869
8eb9b59
25a08a5
de086eb
a958a33
f1219eb
211f928
7fe4bd6
e774cfb
04292a5
77279ff
2223fa0
4a27c40
41f013f
a9d9c92
f85525c
58ed78f
1af5380
8f82497
8af785a
9f65d92
c900f2d
52cc4f6
448ab7e
38c3f25
662d640
d60e29d
ef4db38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| { | ||
| "tag": "object-1", | ||
| "assetPath": "/path/to/the/asset", | ||
| "type": "" | ||
| "assetPath": "assets/stone.png", | ||
| "type": "", | ||
| "x": 150, | ||
| "y": 200 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "tag": "object-2", | ||
| "assetPath": "assets/stone.png", | ||
| "type": "", | ||
| "x": 50, | ||
| "y": 100 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,12 @@ | ||
| package io.rpg.view; | ||
|
|
||
| import io.rpg.Game; | ||
| import io.rpg.Initializer; | ||
| import io.rpg.config.model.GameObjectConfig; | ||
| import io.rpg.model.data.KeyboardEvent; | ||
| import io.rpg.model.data.LocationModelStateChange; | ||
| import io.rpg.model.location.LocationModel; | ||
| import io.rpg.model.object.GameObject; | ||
| import io.rpg.viewmodel.LocationViewModel; | ||
| import io.rpg.config.model.LocationConfig; | ||
| import javafx.fxml.FXMLLoader; | ||
|
|
@@ -16,7 +21,10 @@ | |
| import java.io.IOException; | ||
| import java.net.URL; | ||
| import java.nio.file.Path; | ||
| import java.util.ArrayList; | ||
|
|
||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| public class LocationView extends Scene | ||
|
|
@@ -28,7 +36,7 @@ public class LocationView extends Scene | |
|
|
||
| private final Set<KeyboardEvent.Observer> onKeyPressedObservers; | ||
|
|
||
| private final LocationViewModel viewModel; | ||
| private static LocationViewModel viewModel; | ||
|
|
||
| public LocationView(HBox root, LocationViewModel viewModel) { | ||
| super(root); | ||
|
|
@@ -63,6 +71,11 @@ public static LocationView fromConfig(LocationConfig config) throws IOException | |
| System.out.println(config.getBackgroundPath()); | ||
| view.getViewModel().setBackground(new Image(resolvePathToJFXFormat(config.getBackgroundPath()))); | ||
| // todo: na podstawie configu ustawić pola korzystając z view modelu | ||
| List<GameObjectConfig> objectConfigs = config.getObjects(); | ||
| for(GameObjectConfig objectConfig : objectConfigs) { | ||
| GameObjectView goview = new GameObjectView(Path.of(objectConfig.getAssetPath()), objectConfig.getPosition()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pozycję w postaci numeru wiersza i kolumny trzeba jeszcze przeskalować przez rozmiar kwadratu siatki. raczej nie w tym miejscu, ale gdzieś trzeba |
||
| viewModel.addChild(goview); | ||
| } | ||
| return view; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||
| package io.rpg.viewmodel; | ||||||
|
|
||||||
| import io.rpg.model.object.GameObject; | ||||||
| import javafx.fxml.FXML; | ||||||
| import javafx.fxml.Initializable; | ||||||
| import javafx.scene.image.Image; | ||||||
|
|
@@ -8,6 +9,7 @@ | |||||
| import javafx.scene.layout.Pane; | ||||||
|
|
||||||
| import java.net.URL; | ||||||
| import java.util.List; | ||||||
| import java.util.ResourceBundle; | ||||||
|
|
||||||
| public class LocationViewModel implements Initializable { | ||||||
|
|
@@ -45,4 +47,8 @@ public void initialize(URL location, ResourceBundle resources) { | |||||
| mapImageView.setFitHeight(newImg.getHeight()); | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| public void addChild(ImageView child) { | ||||||
| parent.getChildren().add(child); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tak jak jest obecnie obrazki są rysowane obok tła, zamiast na nim. zmiana parent na contentPane chyba załatwia sprawę
Suggested change
|
||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dlaczego
static? Wydaje mi się, że niepotrzebnie.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wlasnie tez nad tym myslalem
dalem static, bo uzywam tego w fromConfig(), ktore jest statyczne
ale nie jestem pewny czy lepiej zrobic to pole statyczne czy np je przekazac do tej metody jako parametr