Phsc's image import to map source

Warning: level editor is not prepared for this. Expect for the death lag spikes.

Prologue

This article is made by phsc and I decided to moved it as a part of the manual instead giving external link to forum since who knows if forum will die anytime soon enough.

Below passages are created by phsc, and minor adjustment by me.

Newest Ver. Download: https://phscdev.com/files/PB2IMG2.exe V2.0 Download: https://phscdev.com/files/PB2IMG2.0.exe

At first the program can be somewhat confusing, so this is a tutorial on what everything does:

Interface Explanation

  • SELECT IMAGE allows you to select a image, and create them, using generic windows libraries, and adds their location to the text box on it's side, you can also put the direct file location on that text box. The same goes for SELECT PB2 XML, it allows you to select the XML or even any text file, and puts it's location there.

  • INSERT IMAGE inserts the image, however some fields must not be blank, such being the SELECT IMAGE and SELECT PB2 XML text boxes, the pixel x size, the pixel y size, the background (selected by default) and the X and Y position fields.

  • PIXEL X SIZE and PIXEL Y SIZE are the size of each individual pixel as a PB2 background, 10 is the average square you see in the level editor, and is the standard value.

  • X POSITION and Y POSITION are the starting positions for the image, starting always top left, think of the default PB2 coordinate system, positive values go down and to the right, it starts at 0 and just adds to it.

  • X OFFSET and Y OFFSET are the offsets for the backgrounds, if for some reason you want to do that. BACKGROUND is the background that will be used, White is the default one selected.

  • ATTACH TO is an object you can attach the backgrounds too, you have to take it's exact name and put it there.

  • DRAW IN FRONT sets the backgrounds that make up the image to draw in front. SPAWN SHADOWS by default does nothing, because shadows spawn by default, but if you disable it, it disables shadows.

  • CHECK FOR ALPHA LAYER checks for the alpha value in the individual pixel being checked for the image, this means the ones that are not a perfect pixel, so A != 255, are not inserted, unless you are adding an image that fits the whole file, keep this checked, it is also very inneficient at inserting images with values that are not 0 and 255 (because PB2 does not have an alpha value for backgrounds) and it instead of adding a black background at the back, will insert it at the sides, I made that like that for testing purposes and in the future it is likely to change.

  • PREVIEW XML previews the XML code of the file in that text box near the SAVE XML FILE button, for bigger files, reading the text file into that text box can take some time, so disable it, but for smaller ones that can be more useful, since you can directly insert it into latest save browser memory, or just manually add to a map, maybe at a specific point to set up the layers as you want.

  • PREVIEW IMAGE is pretty much the same but for the image file, for bigger images I'd keep it closed, but the performance impact is very small, and you should not be inserting extremely big images, because PB2 can barely handle them.

  • SAVE XML FILE saves the content of the XML text box into the file under the SELECT PB2 XML text box, this is very useful if you want to clear the file there, or if you want to check if the insertion went right if you know what you are doing.

  • The X and Y bars are the progress when inserting the image, the grey field on their right shows the X and Y dimensions of the image.

Information of Insert methods

Generally speaking, images always start from the left top part of your monitor, just like coordinates work in PB2, and generally checking the Y value (going from 0 to the max value) before, and then checking the X value, and repeats, two while/for/etc loops, while (x<xtotal) and inside of that while(y<ytotal).

Simply gets the pixel, checking all Y values, then the X values, and simply creates a background for them, this runs pretty damn fast, since all methods do check literally all pixels at least once (some are faster than others because pixels inserted are not checked), this does not have this, so for images that are extremely effective for other insert methods, this can be pretty slow when compared to, but the biggest issue is the file size.

Tips

  1. Do not insert images that are too big, mostly if you use BASIC as the insert method, every pixel might generate a background, that means gets added to the map file, this for every single pixel in BASIC, and a few less depending on the image you add, this means that PB2 has a lot of data to read, a 200 by 200 pixels image means 40000 objects if you use BASIC, a 500 by 500 one means 250000.

  2. Lag is not the problem! I mean, in the level editor it will lag, but ingame it might run fine, the issue is loading times, it is a lot of text, and that might make the map unable to load in time! keep that in mind.

  3. Posterizing the image, that is making similar colors one single color, greatly increases how effective inserting the image is with other methods, mostly the TWO DIMENSIONAL ones, remember that!

  4. Disble the XML preview for big images, or if your computer is slow, since loading the XML file there can take a while.

  5. Every added field means more text! which means longer load time! X offsets, attaching, not spawning shadows and drawing in front can add a lot of text, keep that in mind! it can even double a single pixel's size.

Runnable in Linux Atrix, Mac remains unknown.

Test Result tested by eaglePB2

Video

Last updated