|
Post by Tom on Jan 15, 2017 2:53:03 GMT
I'm creating a basic 2D platformer tutorial: hereI'm trying to keep it brief, so that it doesn't get overwhelming with detail and explanations. If anything needs clarification or explanation in a bit more detail, feel free to ask here and I'll do my best.
|
|
|
Post by Tom on Jan 15, 2017 5:23:59 GMT
Firstly I've been asked about a good tilemap editor.
I've used Pyxel and Tile Studio before, and they both seem pretty good. Pyxel is interesting in the way it allows you to draw directly into your tiles while they're laid out in a tilemap. Keep in mind that I'm not an artist, so I'm probably not the best person to answer this question.
In either case you want to output a tilemap file with tile indices in text format, ideally comma separated. Basic4GL doesn't really support XML, JSON or other formats.
It's possible to write BASIC code to open a text file and read in the indices. But I find it easier just to use a text editor and convert it into BASIC "data" statements. Then you can "include" it in your program and read the data in with the BASIC "read" command (like the tutorial does).
|
|
|
Post by Tom on Jan 15, 2017 5:39:44 GMT
I've been asked to explain these commands in more detail:
ResizeSpriteArea((480 * WindowWidth()) / WindowHeight(), 480) ResizeText(SpriteAreaWidth() / 16, SpriteAreaHeight() / 16)
The Basic4GL "sprite area" maps coordinates to the screen when positioning and sizing sprites. This means that if your sprite area is set to 640x480 (the default), then any sprite at coordinate (0,0) will appear at the top left of the screen, and any sprite at coordinate (640,480) will appear at the bottom right. Basic4GL stretches and scales all sprites to make thi s happen.
The advantage of this is you can setup your sprite area to the coordinates you want, and then your game will fit on screen regardless of the screen size.
The disadvantage is that not all screens are the same proportion. Some screens are only about 30% wider than they are high, others are almost twice as wide as high. So a game that looks okay on a 4:3 screen will look stretched and distorted on a 16:10 screen. To avoid this, we use the ResizeSpriteArea command to size the sprite area based on the window dimensions. We still set it to 480 units high, but calculate the width based on the width of the screen relative to the height. I.e. if the screen is twice as wide as high, we want to have twice as many sprite units across. The ratio of width to height is calculated as: WindowWidth()/WindowHeight() So because we are 480 units high, we want to set it to 480 * WindowWidth()/WindowHeight() units across.
(The brackets are to work around an integer division issue. If you divide 2 integers in Basic4GL, it will round the result down to the nearest integer, which means 1920/1080 evaluates to 1 rather than 1.6. Using the brackets forces multiplication first, then division, which prevents this).
The ResizeText() command sets the text size. It's parameters are the number of columns and rows of text to display on screen. Choosing SpriteAreaWidth() / 16 and SpriteAreaHeight() / 16 essentially makes each character 16x16 sprite units.
|
|
|
Post by uqegquuvi on Jul 16, 2019 13:36:30 GMT
|
|
|
Post by oyixujatojo on Jul 16, 2019 15:30:35 GMT
|
|
|
Post by matthew on Jul 17, 2019 3:14:09 GMT
Thanks for the info regarding resizing the sprite area, I'll probably find that useful in the future. I think you may need to turn off "guest posting" on the forum as there appears to be a spammer online. 😉
Sent from my Alba 7" using proboards
|
|