Giter VIP home page Giter VIP logo

proputils's Introduction

Only the PropUtils.py and sprite-data files are required.

Usage

import dustmaker
from PropUtils import PropUtils, Pivot

with open('map.file', 'rb') as f:
	map = dustmaker.read_map(f.read())

# If props are scaled, make sure to set use_scale=True
prop_utils = PropUtils()

# Get prop data by index
set_index = 1
group_index = 0
sprite_index = 1
prop_data = prop_utils.prop_data[set_index][group_index]['sprites'][sprite_index]

# Get prop data by name.
# Format: "GROUP_NAME PROP_NAME"
# See sprite-data.json for sprite names
prop1_data = prop_utils.name_prop_map['lighting city_lamp_standing']
prop2_data = prop_utils.name_prop_map['foliage flower_red']

# Create a prop from data
prop1 = PropUtils.from_data(prop1_data)
prop2 = PropUtils.from_data(prop2_data)

# Place a prop centred at a 0, 0
pos = prop_utils.set_prop_location(0, 0, prop1, Pivot.CENTRE, prop1_data)
map.add_prop(19, pos[0], pos[1], prop1)

# Other pivot points can be used, eg. TOP_LEFT, BOTTOM
# Some props also have a more "logical" pivot defined. Use Pivot.ATTACHMENT
pos = prop_utils.set_prop_location(10, 0, prop2, Pivot.ATTACHMENT, prop2_data)
map.add_prop(19, pos[0], pos[1], prop2)

# Find the centre of props
for id, value in map.props.items():
	layer, x, y, prop = value
	prop_centre = prop_utils.get_prop_location(x, y, prop, Pivot.CENTRE)
	print(prop_centre)

proputils's People

Contributors

cmann1 avatar

Stargazers

Mark Gordon avatar

Watchers

 avatar bhansen95 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.