Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 12:54 am

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Doing A Map Maker
PostPosted: Mon Jun 25, 2012 11:47 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Since I always have tons of questions, It though I just make a topic xD

So currently trying to implement a map maker in full TWL. So far it works really great. TWL is damn flexible, I actually does everything :) But I have a few questions and I assume there are more to come.

1. The Map Maper will be tiled based, so how to a make a tile sheet for this? Loading a texture via the renderer and getting subImages from it via getImage?

2. I want to add a play mode where you play a user defiend rectangle colling with the map or not. Of course I can't do that in Slick2D since I do all in TWL but is there a way to let a widget run in 60 FPS per second? Or do I have to use the Timer?

3. How could I add a menu bar like in the Theme Maker?

4. Any Tips from the Theme Maker?

And at the end a screencap of the current maker, where you can see the self-implemented dragging.
Image

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Tue Jun 26, 2012 6:08 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1172
Hi :)

1) there is TWLTiled which renders a multi layered Tiled map which supports scrolling and animation - you can use this as a base.
2) paintWidget() is called every frame :)
3) This is handled through the Menu class - best to look up that class and compare the use with the theme editor.
4) Implementing Undo is always tricky - best to store all data in a single location (eg a Map object - could also be a tree like the DOM in the theme editor) and use models with change listeners to keep everything in sync.

Looks already nice :)

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Tue Jun 26, 2012 10:50 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Thanks for the answers :)

1.) Ah, I thought this is for Tiled alone xD
2.) Okay, so I have to implement some timer then because it sould run with 60 FPS do make collision better (I rely on a FPS <= 60 to make it work just perfect)
3.) Thanks will do that
4.) Ah yes, I remember doing it in the old maker... I just put the whole map in a stack und poped it when undoing somehting xD

Something to mention, this will not be a maker where you just make maps and save them but create a map tree. So you can makes branches for certain areas in game. Also teleporting is easiert to handle for me xD

I assume A tree is displayed by the table with ine column?

I think I keep the Thread updated over the changes I made :D

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Wed Jun 27, 2012 7:46 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Hey there,

how can I make my widget center in a scrollpane? I want to display the map on a widget and try to center the map in a scrollpan. If the map (so the widget) gets larger I would like to move around the map by using the scrollpane.

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Wed Jun 27, 2012 8:11 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1172
Yes and no :)

You can use
Code:
scrollpane.setExpandContentSize(true);
to expand your widget to cover the ScrollPane size when it's smaller - then you can center the map rendering in that widget.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Wed Jun 27, 2012 10:03 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
I just thought of a way :D
I make a widget which will be added to the scrollpane and that widget alsways has the size of the map (if smaller then the pane). I just add another widget and override the layout method to position the Widget in the center. That should work :D

Thing is I might want mouse movement too (much like the Theme Editor, my great inspiration :D). Thanks for the info :)

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Sun Jul 08, 2012 2:28 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Hi There :)

Is it possible to center a widget in a scrollpane? like it centers itself as long as it fits in the pane and if the widget gets to large (e.g. the map size or via zooming) int width of height you can scroll.

I know you wrap the content in a widget so I dunno how to make this possible... (Maybe this would be a nice feature or it is possible and I'm stupid).

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Sun Jul 08, 2012 3:10 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1172
Currently you can't center - but you can expand the widget to fill the inner area of the ScrollPane if it is too small. This allows you to render your map centered. A nice side effect of this is that clicks outside the map will still be send to your widget and not discarded.

If you really want to have it centered and not resized you could put it in a DialogLayout like this:
Code:
DialogLayout l = new DialogLayout();
l.setHorizontalGroup(l.createSequentialGroup().addGap().addWidget(mapWidget).addGap());
l.setVerticalGroup(l.createSequentialGroup().addGap().addWidget(mapWidget).addGap());

ScrollPane sp = new ScrollPane(l);
sp.setExpandContentSize(true);

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Sun Jul 08, 2012 5:49 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Ah thanks :)

Will try both ideas (The first sounds like the thing I want since I want to enable right-clicks in the map panel).

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Thu Jul 12, 2012 2:51 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Can I make a PopupWindow moveable? So I can drag it around? And can I make the TreeTable in the FileSelector extand to the Scrollpane? I had to set the width to a fix int in the theme file, else I would need to scroll left/right to see the headers.

Current Status:
Image

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Thu Jul 12, 2012 5:41 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1172
1) a PopupWindow can't be dragged but you don't need to. You can make it as large as you want, and put a DesktopArea with a ResizableFrame inside. The PopupWindow only affects the event routing behavior.

2) Not sure what exactly you mean.
I found a case in the TableBase column width computation which would not use all the available space for the initial width setting. Can you try the latest TWL build which includes this patch.


Your editor looks already really nice.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Thu Jul 12, 2012 6:29 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
1.) Ah, that makes sense :D Will do that!

2.) What I mean, that I want to drop the horizontal bar. So all Columns should be visible of course. Will try the latest build. It will take some time since I'm off for a week or something.

Thanks, The Source of the Theme Editor helps me a lot through some stuff.

btw. I think I found a bug. Well not a bug... but something which is bad for testing. If you set the JavaFileSystem as System for the FileSelector you can't test it in the Theme Editor because it tries to access the home folder. I guess this is some WebStart relate problem?

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Thu Jul 12, 2012 7:09 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1172
Hmm - no idea about that FileSelector issue - can you make an example which shows this issue?

I added a try/catch around the System.getProperty("user.home") - maybe that will help the webstart issue?

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Thu Jul 12, 2012 7:23 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Sure, I test most stuff in the example twl project anyway:
Code:
package test;

import de.matthiasmann.twl.FileSelector;
import de.matthiasmann.twl.model.JavaFileSystemModel;

public class FileSelectorBug extends FadeFrame {

    public FileSelectorBug() {
        setTheme(SimpleTest.WITH_TITLE);
        setTitle("FileSelector");
       
        FileSelector file = new FileSelector();
        file.setFileSystemModel(JavaFileSystemModel.getInstance());
       
        add(file);
    }
   
}


I will try the new build, but as said... will take a while before I can reply :D

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject: Re: Doing A Map Maker
PostPosted: Thu Jul 12, 2012 7:53 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1172
Ok, I fixed a bug caused by the previous commit :/

But the issue you see with this test is that the default column width (used for column 0) together with the fixed default width for columns 1-3.
You can specify "defaultColumnWidth" and "columnWidths" together with "minWidth" in the theme to ensure that the initial column width fits into the window.

Not sure that I can solve this somehow as there are use cases where you want to display more columns than can fit.
What you can do is to use setAllowHorizontalScrolling(false) on the FileSelector to disallow horizontal scroll bars.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group