Codesnippets > 2D-snippets
PlyTxt - Polygon Text TXT files
Kitty Hello:
Sometimes, I need vector graphics - polygons.
And designing them is always complicated. Most times, I just need 10 points.
So, I decided to make a vector format, that is editable with any text editor.
The file format is described in "Media/fileformat.plxtxt" and goes like:
#plytx - 5 byte header information. File encoding without BOM!
# --= PolyText ==-
# Polytext is a vector format, that is easy to edit
# with a text editor.
# *** SYNTAX ***
# Everything right of a '#' is considered a comment.
# lines starting with ':' are commands. Commands must be lowercase.
# whitespace between command arguments is ignored.
# arguments can be separated by whitespace. Comma ',' is treated as whitespace
# for better readability.
# *** NODES ***
# The point information is given in the 'map' command.
# Points are named:
# 0..9 A..Z a..z
# This results in max. 62 points per file.
# The above point names also are the default order of the point names.
# Point names can have gaps, so you can easily define a polygon
# by the points A C E and refer to the names range A-E.
#
# ^Y The name '0' is a special point and refers to the origin
# | of the local coordinate system.
# 0-->X X positive is to the right, Y positive is towards the top.
# *** SPECIAL NODES ***
# You can embrace nodes by (), [], {} or <>
# These points get a special tag when importing them.
# It does not matter if you only write one brace, like (X or X),
# or both (X) braces.
# Also, you can set multiple braces for one point:
# {(X]> # this would set all 4 brace flags for the point 'X'.
# ASCII-art characters can be used to indicate connected lines.
# The following characters are valid:
# - + . _ / \ ^ : , ´ ` '
# The following characters are reserved for the future:
# " * ! ? & % $ §
################## COMMANDS #########################################
# *** FONT ***
# :font w h
# specify the font width and height ratio, because most text editors
# do not use quare fonts. For 'Consolas' this is like 7 18
# *** ORIGIN ***
# :origin orgx orgy
# A corrdinate that represents the position of node name '0'.
# Defaults to 0 0
# *** SCALE ***
# :scale factorx [factory]
# A factor that is applied to the X and Y coordinate of each point.
# factory equals factorx if ommited. The default scaling is 1.0.
# *** POLY ***
# :poly point_names...
# defines a polygon that is defined by the given points.
# If no points are given, the range 0-z is assumed.
# Points can either be listed individually, like:
# :poly abc efg x
# or with the range operator '-':
# :poly a-c, e-f, x
# The range operator adds all points in the ASCII-value order.
# Non existing points are simply skipped.
# You can specify a negative range for reverse direction:
# :poly c-a
# *** MAP ***
# :map
# Here, the point coordinates are given. Everything below the :map
# command is considered as part of the point list.
######################## EXAMPLE ################################
:font 7 18 # consolas
:origin 1 2
:scale 7
:poly A-Z
:poly a-d
:map
z __P--(Q)-----R # Example map for a C64 Thrust-Style game
A-------B O--- # 'z' is only used as the player start position
| |
| | # 'A' to 'Z' is the cave polyon.
| 0 | # 0 indicates the origin of coord system
| |
| |
___C N
/ b {M_____ # The { } are cannons
D : : ---L
| a. :...c K # 'a' to 'd' form a second polygon -> an island
| d... J
E} I/
F---------[G]--------H/ # Base of cave
I'm trying to do a C64 Thrust remake. Maybe.
bigsofty:
It's a nice format, Thrust is such a classic. Are you going to use Box2D or emulate the original physics?
Kitty Hello:
Nah, that's why I'm doing the remake ;)
nabz32:
I like the idea of possible ascii art connections between Nodes for better readability. :good:
Moru:
Good timing for a Thrust remake! I tried this one and it's pretty fun https://store.steampowered.com/app/727020/Arcade_Moonlander/
Except it's not very well made. Apparently the world is made of a gigantic .png file and collisions were handmade separately so very hard to make new levels.
Looking forward to see your version!
Navigation
[0] Message Index
[#] Next page
Go to full version