SDLPoP Built-in level editor

Open-source port of PoP that runs natively on Windows, Linux, etc.

Moderator: English Moderator Team

User avatar
poirot
Princed Developer
Princed Developer
Posts: 382
Joined: March 24th, 2003, 8:52 pm
Location: Ushuaia, Argentina
Contact:

SDLPoP Built-in level editor

Postby poirot » January 23rd, 2016, 4:39 pm

As you may have been noticed, I've pull requested a new level editor built inside SDLPoP. Coding inside the game is completely easy as I don't have to think in the interface and all stuff and you can see exactly how the game will look like because you are editing the game itself. Most features are done except for the customizable tile palette I'm planning to add in special palette rooms.

When I was a child and found the megahit command, I always suspected there was another command to access a level editor... unfortunately there wasn't. Now, typing "prince edit" the editor mode starts allowing new key shortcuts and the use of the mouse.

For the moment shortcuts are:

Shift-U: insert screen up
Shift-H: insert screen left
Shift-J: insert screen right
Shift-N: insert screen down
Del or Backspace: delete guard
Ctrl-C: Copy room
Ctrl-V: Paste room (the version legend is dropped in edition mode)
Alt-S: Save level
Q: Increment guard color
W: Decrement guard color
]: Increment guard skill
[: Decrement guard skill
Ctrl-Z: Undo
Ctrl-Alt-Z: Redo
Tab: Toggle guard direction
Mouse left click: Put copied tile
Mouse right click: Copy tile
Shift-Mouse left click: Put/move the kid there
Shift-Mouse right click: Put/move a guard there
Y: Set starting position to the place the kid is
Ctrl-Alt-Mouse left click: Toggle door activation by selected button
Ctrl-Alt-Mouse right click: Select rise and drop buttons for door linking
Alt-R: Revert level to latest saved version
Ctrl-Shift-Mouse left click: Put random tile
Ctrl-Shift-R: Randomize the whole screen
M: Show map (keep the key pressed)

Screen Shot 2016-01-23 at 11.16.00 a.m..png
Screen Shot 2016-01-23 at 11.17.32 a.m..png
Screen Shot 2016-01-23 at 11.15.45 a.m..png
Screen Shot 2016-01-23 at 11.24.46 a.m..png
Screen Shot 2016-01-23 at 11.23.24 a.m..png

DarkPrince
Efendi
Efendi
Posts: 8
Joined: January 23rd, 2016, 11:08 pm

Re: SDLPoP Built-in level editor

Postby DarkPrince » January 25th, 2016, 9:55 am

Wow.

Guess it's my lucky weekend. Just discovered SDLPoP two days ago and now this ... :-)

I was able to compile and test it a bit. There's a lot to learn in terms of keyboard handling and some of the handling feels strange, but after a few minutes it looks like it's just a matter of training.

It's quite impressive and that it combines playing and building into one step (a'la Super Mario Maker).

Small feedback only for now:
- on "Mouse right click: Copy tile" maybe also print a message at the bottom to signal the copy has been done. Sometimes on my trackpad I'm unsure whether the right-click gesture was accepted and this would help. Also it's one of the operations with no visual indication at all.
- on the "Map" maybe you can make an indicator, which room the user is in?
- is there a way to select a block from a palette instead of copying?
- sometimes I couldn't create a new room. But it wasn't clear to me why? Is it the total number of rooms? The layout?
- I guess saving is only possible to ... overwrite existing levels? Or can I create new ones, in new files? I mean I guess it's just the way how the engine and modding works in general, by modifying existing resources?

I was surprised that I actually can copy blocks across levels (only tested with the same tile-set however) :-)

Maybe some feedback is strange as I'm not a seasoned user/player of the old PoP.

Anyway, thank you (as well as David in the first place for this awesome project).

edit: I guess I'm really really lucky, because I'm on OSX and hours before I found your post I was certain there's no PoP level editor for OSX available, as the only ones I found are for Windows/Linux ....

User avatar
poirot
Princed Developer
Princed Developer
Posts: 382
Joined: March 24th, 2003, 8:52 pm
Location: Ushuaia, Argentina
Contact:

Re: SDLPoP Built-in level editor

Postby poirot » January 25th, 2016, 3:57 pm

Great feedback! I'll the features in my TODO list

DarkPrince wrote:- sometimes I couldn't create a new room. But it wasn't clear to me why? Is it the total number of rooms? The layout?

The LEVELS.DAT format only supports 24 rooms. One advantage of having the editor and the game integrated is that changing a constant in the source and recompiling may raise this number changing the level format but keeping the editor working.

DarkPrince wrote:- I guess saving is only possible to ... overwrite existing levels? Or can I create new ones, in new files? I mean I guess it's just the way


That would be interesting. For the moment you can copy the LEVELS.DAT/resXXXX.bin to have the level file you want. XXXX is 2000+level number. You can Alt-S to save the file, copy it and re save to re-create the level. You can also Alt-R Alt-S to save the reverted level even if the file was moved or deleted.

David
The Prince of Persia
The Prince of Persia
Posts: 1344
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP Built-in level editor

Postby David » January 25th, 2016, 8:38 pm

Some more feedback:

* Guard HPs appear in palette rooms.
* Possibly related: The editor crashes if I press P on level 14.
(Guards on level 14 should not crash the game anyway. I.e. this should be fixed on the master branch.)
* Is there any reason that some tiles appear more than once in the palette rooms? (For example, spikes, chompers, torches.)
* It would be good if ambiguous tiles were marked somehow in the editor. (For example, loose floors, some potions.)
* If I want to insert a room in palette mode, the editor may crash.
(Editing of the palette rooms should be limited anyway.)

User avatar
poirot
Princed Developer
Princed Developer
Posts: 382
Joined: March 24th, 2003, 8:52 pm
Location: Ushuaia, Argentina
Contact:

Re: SDLPoP Built-in level editor

Postby poirot » January 27th, 2016, 2:08 am

david wrote:Guard HPs appear in palette rooms.

I was filling the guard sectors of the palette rooms with zeros, I don't remember the standard format for "no guard", what whas it? tilepos==30 ? I've pushed a commit using 30 and I think it's fixed

david wrote:Is there any reason that some tiles appear more than once in the palette rooms? (For example, spikes, chompers, torches.)

nope, current committed palette was just to test. May be someone would like to make a better one.

david wrote:It would be good if ambiguous tiles were marked somehow in the editor. (For example, loose floors, some potions.)

great idea, I've commited the "ambiguous mode", activated with "A" key.

david wrote:If I want to insert a room in palette mode, the editor may crash.

OMG, didn't think of that! Fixed.

DarkPrince
Efendi
Efendi
Posts: 8
Joined: January 23rd, 2016, 11:08 pm

Re: SDLPoP Built-in level editor

Postby DarkPrince » January 27th, 2016, 9:40 am

I guess I missed an essential part: what's with that "palette room"? :)

David
The Prince of Persia
The Prince of Persia
Posts: 1344
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP Built-in level editor

Postby David » January 27th, 2016, 10:40 pm

DarkPrince wrote:I guess I missed an essential part: what's with that "palette room"? :)

If you press P, the editor switches to a set of rooms that contain tiles for you to copy them.
These are the palette rooms.
This was needed because to put a tile you need to copy it from elsewhere.
(Or use "Ctrl-Shift-Mouse left click: Put random tile", and hope that the desired tile appears. :) )

But, Poirot recently made it possible to change the current tile with the mouse wheel.
It seems that Ctrl+wheel will change the modifier, but that is not documented yet.

By the way, it seems that the numbers after FG and BG are swapped in the message that appears when using the wheel.

Where you create a struct value on the fly:
Instead of this:

Code: Select all

(tile_packed_type)(word)(edited.fg[location]<<8|edited.bg[location])

This would be better: (C99 feature)

Code: Select all

(tile_packed_type){{edited.fg[location],edited.bg[location]}}

Or even:

Code: Select all

(tile_packed_type){.concept={.fg=edited.fg[location],.bg=edited.bg[location]}}


poirot wrote:I don't remember the standard format for "no guard", what whas it? tilepos==30 ?

Exactly. (But anything >= 30 should work.)

poirot wrote:nope, current committed palette was just to test. May be someone would like to make a better one.

This reminds me of the test level I made for showing custom dungeon/palace graphics.
You can see it here: dungeon and palace
Maybe it could be used with some changes?
Or maybe not, and instead just group similar/related tiles together?

User avatar
poirot
Princed Developer
Princed Developer
Posts: 382
Joined: March 24th, 2003, 8:52 pm
Location: Ushuaia, Argentina
Contact:

Re: SDLPoP Built-in level editor

Postby poirot » January 28th, 2016, 3:13 pm

David wrote:By the way, it seems that the numbers after FG and BG are swapped in the message that appears when using the wheel.


Yes, I've fixed it independently in https://github.com/ecalot/SDLPoP/commit ... 8e8d4af39d, but I like your solution better. I'm not so familiar with C99 (in fact it shocked me when I've seen on the fly variables and comments with //... now I'm using them a lot).

David wrote:This reminds me of the test level I made for showing custom dungeon/palace graphics.


When I created the idea for those palette rooms I've duplicated anything because the 3d box mouse cursor wasn't done and selecting could be more difficult, so duplicating the tiles was the fastest way to guaranty that the user (or myself testing the editor) had picked the right tile. Now, with 3d box mouse cursor there is no need for that. I'm going to download all-graphics.zip so I can extract the level resources with PR, insert them to the game, copy the right rooms to the palettes with the editor and then git reset the original resources.

David
The Prince of Persia
The Prince of Persia
Posts: 1344
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP Built-in level editor

Postby David » January 28th, 2016, 9:17 pm

I see you updated the palette rooms.

But the sword is missing. (I didn't include it in the test level because it's in prince.dat instead of vdungeon/vpalace.dat.)
Also missing are the open potion, and the special loose floor. (These could also have disambiguation icons.)
And, the two types of doortops (with and without floor) should be added with all three patterns.
And the open gate, and the torch without broken floor.
(But some of these can already be "reached" by changing the modifier with ctrl+wheel. And all of them can be, using the wheel.)

User avatar
poirot
Princed Developer
Princed Developer
Posts: 382
Joined: March 24th, 2003, 8:52 pm
Location: Ushuaia, Argentina
Contact:

Re: SDLPoP Built-in level editor

Postby poirot » January 29th, 2016, 4:48 am

David wrote:Also missing are the open potion, and the special loose floor. (These could also have disambiguation icons.)


What are the codes for those?

disambiguation icons now can be added directly in editor.ini

Edit: Btw, are the first 3 bits of fg tiles useful?

David
The Prince of Persia
The Prince of Persia
Posts: 1344
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP Built-in level editor

Postby David » January 30th, 2016, 12:49 pm

poirot wrote:What are the codes for those?

The open potion is FG=10, BG=6. (This also appears in FormatSpecifications.pdf.)
And then there is the empty potion with FG=10, BG=0. (It is good for anything?)

The special loose floor is same as the regular, except bit 5 of FG is set. That is FG=11+32=43.
Roomshaker calls this "Selective Drop", Apoplexy displays it with a "no" sign.
FormatSpecifications.pdf writes this:
FormatSpecifications.pdf wrote:A tile in the pop1 foretable part has 8 bits in this format rrmccccc, where rr are random bits and can be ignored. m is a modifier of the tile. For example modified loose floors do not fall down.

These are used in the Potion Puzzles and Potions of Delusion mods for example.

poirot wrote:Edit: Btw, are the first 3 bits of fg tiles useful?

Currently, only for the special loose floor mentioned above.
However, it was proposed that they could be used for adding new tile types.

User avatar
poirot
Princed Developer
Princed Developer
Posts: 382
Joined: March 24th, 2003, 8:52 pm
Location: Ushuaia, Argentina
Contact:

Re: SDLPoP Built-in level editor

Postby poirot » January 31st, 2016, 5:34 pm

What about walls? the m bit is used randomly, may be in the apple II it had some meaning...

should I display the tile code in a more user friendly format such as

Code: Select all

("%d%c-%d",fg&0x1f,fg%0x20?'m':' ',bg)
?

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 2955
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: SDLPoP Built-in level editor

Postby Norbert » February 4th, 2016, 8:10 pm

Hey poirot, it's great to see you back in action.
Interesting project too.

User avatar
poirot
Princed Developer
Princed Developer
Posts: 382
Joined: March 24th, 2003, 8:52 pm
Location: Ushuaia, Argentina
Contact:

Re: SDLPoP Built-in level editor

Postby poirot » February 5th, 2016, 11:31 pm

Thanks!

David
The Prince of Persia
The Prince of Persia
Posts: 1344
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP Built-in level editor

Postby David » February 6th, 2016, 11:31 am

poirot wrote:What about walls? the m bit is used randomly, may be in the apple II it had some meaning...

The m bit is 1 iff the tile below needs to have floor above it.
This was added for the convenience of Mechner's own editor.
In the Apple II source it's called "reqmask".
And the array that tells which tiles need floor above them is called "linklist".


Return to “SDLPoP”

Who is online

Users browsing this forum: No registered users and 1 guest