help making a level editor
hi, I am primarily a Minecraft mod/modpack developer and when I found out how easy it is to make custom levels for the game tasty planet I wanted to make a level editor for it so turned to java as it's what I have the most experience with but I'm getting to the edge of my knowledge and AI isn't being very helpful.
basically what I need is help adding a few features I can't (even just placeholder stuff I can use to actually do what I want as I know it's hard to write code to interact with files you don't actually have) so the main thing is I want to add some images to the program but can't seem to figure that out.
https://github.com/RemagOfficial/Tasty-Planet-1-Level-Editor here's the GitHub and please don't roast my bad code too hard lol
GitHub
GitHub - RemagOfficial/Tasty-Planet-1-Level-Editor: a very basic le...
a very basic level editor for the original tasty planet - RemagOfficial/Tasty-Planet-1-Level-Editor
51 Replies
⌛
This post has been reserved for your question.
Hey @Remag! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
this is the current program and the grid represents the level tiles, I want to add an image to the center of the grid kinda as a scale and maybe with a different layout to make the grid bigger I want the grid squares to use the appropriate textures from the game files for the level that has been chosen in the drop-down
it's like 4am for me btw so if I don't respond immediately that's why lol
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
huh
it already was tho
maybe someone sent a message or clicked on open
and then it was marked as dormant again
so you want to insert images in the grid?
not quite, i want the image to be on top of the grid because the center isnt always one square and i also dont want to mess up the shape of the grid
you mean behind the grid?
or above it?
above
wait let me make a mockup lol
essentially this is what i want, the image cant be in one of the grid cells because that isnt always possible and i cant like add a new cell for the image because that would change the shape of the grid
its basically just a marker to show the center so you can at least guess the size of the level
Where are you plotting the grid?
I don't see that in your code
its in getButton, should probably rename that
I don't see that method here: https://github.com/RemagOfficial/Tasty-Planet-1-Level-Editor/blob/main/mapEdit.java
GitHub
Tasty-Planet-1-Level-Editor/mapEdit.java at main · RemagOfficial/Ta...
a very basic level editor for the original tasty planet - RemagOfficial/Tasty-Planet-1-Level-Editor
thats the wrong branch, master is the branch im using because i only recently started working on it again and my IDE hates me
GitHub
Tasty-Planet-1-Level-Editor/src/mapEdit.java at master · RemagOffic...
a very basic level editor for the original tasty planet - RemagOfficial/Tasty-Planet-1-Level-Editor
I think you can get the location of the grid in the
previewPanel
as well as its width and height
then you add the image to the previewPanel
as well but in the middle of the gridim pretty sure i tried that, honestly tho i think my issue was actually like getting the image lol
though you might need a
LayoutManager
for that
What you can try is:
- Create a new JPanel
for both the grid and the image
- These are added to that JPanel
, not previewPanel
- use a LayoutManager
on that JPanel
ensuring both are centered and on top of each other
- That JPanel
is added to previewPanel
i mean previewPanel is already just a blank panel
yeah but you probably want to continue putting stuff one after each other there so you probably don't want to change that, right?
Stack Overflow
How can I put 2 java swing elements on top of each other?
so I have this project that I'm doing, which draws a circle and a square, and resizes them through buttons. Everything works great, however what I must do is put the circle inside the square, so th...
and just as a sanity test, what path should i use for images
cause i couldnt even get an image to load like at all and idk why
You probably want to use it as a resource
so in the resource folder
and load it with
getClass().getResource()
or the src folder since you don't have a resource folderprogress, i just cant get it to center now
Can you show the relevant code?
can you try
centerGooIcon.setAlignmentX(Component.CENTER_ALIGNMENT);
and centerGooIcon.setAlignmentY(Component.CENTER_ALIGNMENT);
?that worked, thanks
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
ima keep this open just because im probably going to have more issues
If it's marked dormant, you can just send a new message to reopen it if necessary
yep
got the other images working
im trying to add some labels to the preview and ive got the labels working but they are being centred in the overlayPanel like the image i tried to add before but i dont want that this time i want them to be on the side
how its rendering
i also moved the preview to its own window but that didnt cause issues
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
just waking up this post since I have another issue :AWAKEN:
Can you do
yourLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
or similar?doesnt change it, i tried aligning the panel the labels are on too and that also didnt help
Where are you adding the label?
ah I see
Why are you using a
BoxLayout
for it?i dont know tbh lol
i was probably just testing things and didnt remove that
using no layout makes only the labels show, thats probably why lol
?
idk
wait maybe im just being dumb, i cant have things wider than the grid in the overlayPanel because the overlayPanel restrains the size of the grid
okay yeah adding them to previewPanel directly fixed it, ill probably have the same issue when i need to add more images to the overlay but for now its working
the text is just for debug so itll look better but they are in the right place now
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.